Pandoc: Support customisable indentation of nested lists in .docx output

Created on 2 Aug 2020  路  13Comments  路  Source: jgm/pandoc

Pandoc does not seem to respect any styles or settings in the reference document while choosing the horizontal indentation of numbered lists. In fact, a handing indent 0.85 cm seems to be hard-coded for the list item and a mismatching indent of 1.27 cm for nested lists, which produces nested lists with the labels of the next level indented father than the body of the previous level.

Numbered lists being a basic typesetting element without which professional documentation is hardly possible, I propose to modify Pandoc so that it shall borrow both indentation parameters for each list level from a corresponding style in the reference document. The ability to customise the indentation of lists is crucial because no hard-coded constant can producer well-looking results with all paper- and font sizes.

I have tested this with Pandoc 2.10.1, using the following example:

1.  level one
    1. level two
Docx writer

All 13 comments

Agree this would be nice. I also have the vague feeling this has already been discussed in some issue and was somehow trickier to implement than expected...

Well, as a practical user of Pandoc, I will be satisfied with any solution that will let me customize the indentation of enumerated lists鈥攆irst make it work, then make it pretty. For a start, it seems possible to copy the indent and hanging indent from the List style of the corresponding level, in order not to hardcode them at least.

On the other hand, since the indentation of nested lists has very little reason to be irregular and the label of the next level should be indented as the body of the previous one, a single indentation step setting will do as well.

If the modification is too difficult, will you please change the hard-coded indentation settings so that nested list levels match, i.e. set the left indent fror nested list levels to multiples of 0.85 cm: 0.00, 0.85, 1.70, ... because they already have a hard-coded hanging indent of 0.85 cm.

Maybe this is indeed possible to implement, we'll have to check... meanwhile, there are a few related tickets around: https://github.com/jgm/pandoc/issues?q=is%3Aopen+is%3Aissue+label%3Aformat%3ADocx+label%3Awriter+list

Lots of stuff there, mb21. Do you think I could fix the indentation using a Lua filter? Should I have to hard-code the fixed indentations into the filter, or can it be passed down to the filter from the command line?

I had the very same issue. I was able to work around the problem by manually editing numbering.xml in the reference .docx file.
There is a number of <w:abstractNum> sections with w:abstractNumId from 0 to 14 in it. During the analysis of the generated .docx I found out Pandoc generates its own <w:abstractNum> sections, but those are copied from the original sections with numbers 0, 11 and 14. I have no idea why. Anyway, I added a bunch of <w:ind> tags to <w:abstractNum> sections in the reference .docx and this solved the problem for me.

Hmm. Just now I realized there is a problem with my solution. After I add lists to the reference, the generated lists go crazy. In particular, I have bullet lists instead of number lists and vice versa! Also, the starting numbers of the number lists are also messed up.

I tried adjusting <w:ind> for existing <w:abstractNum> sections, but it gave no effect whatsoever. So there is still no workaround present, I guess.

After thinking about it some more, I am fully convinced that the only simple and effective solution would be to modify Pandoc so that it

  1. uses the same length for the hanging and alignment indent for lists, and other structural indents in DOCX.
  2. make that length customisable via command-line and/or metadata.

I should be simple enough and will make Pandoc better by removing a couple of hard-coded constants.

@ant-222 feel free to make a pull request!

mb21:

@ant-222 feel free to make a pull request!

Do you think I can manage it without any knowledge of Haskell, on a Windows XP machine with MinGW? As far as I remeber, the latest Pandoc binary fow Winodws does not work on XP...

I believe what @mb21 thought that, after reading that the change "should be simple enough", that there would be a solution ready at hand.

Don't worry though, you can help even without a working Haskell installation. Describing the necessary changes to the XML output would already be an important contribution. Can you help us out with that?

Last year I investigated something related in #4321. I identified potential places to at least manage step and indentation via styles.
However I never got to anything tangible (no code written).

tarleb, Yes, I think I can specify the desired results in terms of XML output inside the .docx file. But I though I should rather search the Pandoc source (DOCX writer, probably) for the hard-coded values. Thanks for the suggestion. I will try do it this or tomorrow evening.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GiantCrocodile picture GiantCrocodile  路  54Comments

matthijskooijman picture matthijskooijman  路  54Comments

uvtc picture uvtc  路  47Comments

graymalkin picture graymalkin  路  54Comments

brainchild0 picture brainchild0  路  66Comments