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

Support customisable indentation of nested lists in .docx output #6586

Open
ant-222 opened this issue Aug 2, 2020 · 13 comments
Open

Support customisable indentation of nested lists in .docx output #6586

ant-222 opened this issue Aug 2, 2020 · 13 comments

Comments

@ant-222
Copy link

ant-222 commented Aug 2, 2020

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
@mb21
Copy link
Collaborator

mb21 commented Aug 3, 2020

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...

@ant-222
Copy link
Author

ant-222 commented Aug 3, 2020

Well, as a practical user of Pandoc, I will be satisfied with any solution that will let me customize the indentation of enumerated lists—first 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.

@ant-222
Copy link
Author

ant-222 commented Aug 3, 2020

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.

@mb21
Copy link
Collaborator

mb21 commented Aug 4, 2020

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

@ant-222
Copy link
Author

ant-222 commented Aug 4, 2020

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?

@mmatrosov
Copy link

mmatrosov commented Aug 11, 2020

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.

@mmatrosov
Copy link

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.

@ant-222
Copy link
Author

ant-222 commented Sep 4, 2020

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.

@mb21
Copy link
Collaborator

mb21 commented Sep 5, 2020

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

@ant-222
Copy link
Author

ant-222 commented Sep 6, 2020

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...

@tarleb
Copy link
Collaborator

tarleb commented Sep 6, 2020

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?

@agusmba
Copy link
Contributor

agusmba commented Sep 7, 2020

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).

@ant-222
Copy link
Author

ant-222 commented Sep 7, 2020

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.

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

No branches or pull requests

5 participants