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

Incorrect Headings Numbering for Docx #1305

Closed
nberglund opened this issue May 16, 2014 · 6 comments
Closed

Incorrect Headings Numbering for Docx #1305

nberglund opened this issue May 16, 2014 · 6 comments

Comments

@nberglund
Copy link

So it seems that Pandoc does not correctly handle numbering and positioning of sub headings (level 2+), in a docx output. From a post on the pandoc group by Helmut Zechmann:
<<<<<<<<<<<<<<<<
What I configure in my template is the following numbering style:
1 Section One
1.1 Subsection One in Section One
1.1.1 SubSubsection One in Subsection One in Section One
1.2 Subsection Two in Section One
No matter, what numbing style I configure, pandoc always produces the
following heading numbering style:
1 Section One
1 Subsection One in Section One
1 SubSubsection One in Subsection One in Section One
1 Subsection Two in Section One

I have attached two images showing the expected behaviour: .
proper_header_formatting

and the output from pandoc:
pandoc_header_formatting

The reference.docx file I use is extremely simple, I can share it / email it if anyone wants it.

Niels

@jgm
Copy link
Owner

jgm commented May 16, 2014

I see that I can change the Heading styles (in Word) so that
they are numbered in outline form. This works (you may want to
confirm). So the problem is that the numbering style given in
the template does not carry over?

It would be useful to have detailed instructions (including
any necessary files) on how to reproduce the problem.

@nberglund
Copy link
Author

John,

Well the problem is twofold:

  1. The template has the various headers with the same indent, when pandoc
    applies the template, the heading are being indented. I.e. heading 2 and 3
    are indented related to heading one, as well as each other.
  2. The numbering applied is off. I.e. the first heading 1 is correct: 1.
    Heading 1, however a heading 2 as subheader to heading one should be
    numbered 1.1 Heading2, but is comes out as 1. Heading 2, etc.

When I get back home this afternoon I can attach the reference.docx,
together with the markdown file I used, so you can repro.

Niels

On 16 May 2014 07:57, John MacFarlane notifications@github.com wrote:

I see that I can change the Heading styles (in Word) so that
they are numbered in outline form. This works (you may want to
confirm). So the problem is that the numbering style given in
the template does not carry over?

It would be useful to have detailed instructions (including
any necessary files) on how to reproduce the problem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1305#issuecomment-43299745
.

@nberglund
Copy link
Author

Hi,

OK, so here are four files, that hopefully should show the issue:
pandoc_header_formatting.md: the original markdown file
reference.docx: the --reference-docx file
expected_header formatting.docx: the expected outcome, i.e. write the text
straight in the reference.docx file and apply the various styles.
pandoc_header_formatting.docx: the doc pandoc produces.

In the pandoc output, notice how the sub-headers (level 2 and 3) are
indented and how the numbering on those are incorrect. The numbering on the
top level heading is correct though, apart from a dot is applied to the
number, i.e. "2." instead of "2".

Also, after having created the output from pandoc, the styles are messed
up; i.e. if you write something into the produced docx file and applies
either a Heading 2 or 3 heading, they now have the same format as what
pandoc produced.

Hope this can help in finding what the issue is.

Niels

On 16 May 2014 11:17, Niels Berglund niels.it.berglund@gmail.com wrote:

John,

Well the problem is twofold:

  1. The template has the various headers with the same indent, when pandoc
    applies the template, the heading are being indented. I.e. heading 2 and 3
    are indented related to heading one, as well as each other.
  2. The numbering applied is off. I.e. the first heading 1 is correct: 1.
    Heading 1, however a heading 2 as subheader to heading one should be
    numbered 1.1 Heading2, but is comes out as 1. Heading 2, etc.

When I get back home this afternoon I can attach the reference.docx,
together with the markdown file I used, so you can repro.

@jgm
Copy link
Owner

jgm commented Jun 3, 2014

Confirmed the reported behavior with these files (the files you uploaded to pandoc-discuss). It's very strange. If you look at the reference.docx you supplied, and view the Heading 2 style, it shows 0" indentation. If you then create my.docx using this reference.docx, and view the Heading 2 style in Word, it shows 0.5" indentation. That suggests that the style is somehow being changed. However, the style.xml files inside the zip containers are the same (well, one contains styles for syntax highlighting that the other lacks, but that is the only difference). So I have no idea what is going on.

@jgm
Copy link
Owner

jgm commented Jun 3, 2014

Ah, okay. I think I see what is happening. It has to do with numbering.xml, which is generated by pandoc (replacing what is found in the reference.docx). There are links in the styles.xml file to numIds, and these point to the wrong things when the numbering.xml file is replaced.

@nberglund
Copy link
Author

Ah, OK - glad you found the issue. Is there anything I can do to help?

Niels

jgm pushed a commit that referenced this issue Jun 3, 2014
This opens up the possiblity (with further code changes) of
preserving some numbering from the reference.docx (e.g. header
numbering.)  See #1305.
@jgm jgm closed this as completed in 0ddb4cd Jun 3, 2014
@jgm jgm reopened this Jun 3, 2014
@jgm jgm closed this as completed in 45f3851 Jun 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants