Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeat ListItem Numbering #1935

Open
bhavink21 opened this issue Sep 17, 2020 · 1 comment
Open

Repeat ListItem Numbering #1935

bhavink21 opened this issue Sep 17, 2020 · 1 comment

Comments

@bhavink21
Copy link

Is there a way to repeat the ListItem numbering (lettering)?
Currently, the output is:

1. One
2. Two
   A. Alpha
   B. Beta
3. Three
   A. Charlie

I want to output this:

1. One
2. Two
   A. Alpha
   B. Beta
2. Three
   A. Charlie
@DigArtRoks
Copy link

To achieve this, there is a workaround but not a real clean solution. It consists of defining a second numbering styles where the start number is set to 2 for level 0. At the moment you need the deviation in the numbering, start to use the second style.

Something like this:

$multilevelList1 = 'multilevel list 1'; // Normal numbering style
$multilevelList2 = 'multilevel list 2'; // Same style as previous one, but level 0 starts at 2 instead of 1

$phpWord->addNumberingStyle(
    $multilevelList1,
    array(
        'type'   => 'multilevel',
        'levels' => array(
            array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360, 
                  'start' => 1),
            array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
        ),
    )
);

$phpWord->addNumberingStyle(
    $multilevelList2,
    array(
        'type'   => 'multilevel',
        'levels' => array(
            array('format' => 'decimal', 'text' => '%1.', 'left' => 360, 'hanging' => 360, 'tabPos' => 360,
                  'start' => 2),
            array('format' => 'upperLetter', 'text' => '%2.', 'left' => 720, 'hanging' => 360, 'tabPos' => 720),
        ),
    )
);


// New section
$section = $phpWord->addSection();

// Lists
$section->addListItem('One',     0, null, $multilevelList1);
$section->addListItem('Two',     0, null, $multilevelList1);
$section->addListItem('Alpha',   1, null, $multilevelList1);
$section->addListItem('Beta',    1, null, $multilevelList1);
$section->addListItem('Three',   0, null, $multilevelList2);
$section->addListItem('Charlie', 1, null, $multilevelList2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants