jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.25k stars 3.36k forks source link

Loss of style for titles and/or subtitles in .docx output document #10282

Open sschaenz opened 4 hours ago

sschaenz commented 4 hours ago

I am using a customised ‘reference.docx’, which I created with the command ‘pandoc -o custom-reference.docx --print-default-data-file reference.docx’ and added individual styles for titles and subtitles. This file worked perfectly in Pandoc version 3.1.12 and formatted the title and subtitle as desired (e.g. frame with background colour and custom text colour).

However, after upgrading to Pandoc 3.5, the problem arises that titles and subtitles lose their formatting and the default formatting is used instead. The content is output correctly, but without the assigned formatting. This suggests that Pandoc may no longer recognise the custom styles or that the assignment of metadata to styles has been changed.

I am using a German version of Microsoft Word, so the style names in my ‘reference.docx’ file may correspond to the localised German names. Since I updated directly from Pandoc 3.1.12 to 3.5, I can't say exactly from which version the problem occurred. However, downgrading to 3.1.12 fixes the problem, so there seems to be a change in the newer Pandoc versions that affects the style assignment for metadata.

Regards Stefan

jgm commented 3 hours ago

Have you checked the changelog to see what relevant changes were made between 3.1.12 and 3.5? https://pandoc.org/releases

sschaenz commented 1 hour ago

Yes, I have read the release notes and found some possible clues, but they don’t help me resolve the issue as a user.

I have spent several hours researching and testing, but the documentation did not provide any insights to resolve my issue.

My understanding was that Pandoc’s reference file could be used to customize the layout of a Word document as long as only the Pandoc-supported styles were modified or utilized. This approach had always worked fine in the past. I also generated a new reference file using Pandoc 3.5 and ran targeted tests with it. However, when I modify the Title and Subtitle layouts (such as color or font), Word now uses the Standard layout style instead. This should not be happening.

I found the following relevant notes in the release history:

pandoc 3.2.1

“Clean up Abstract Title and Subtitle in default reference docx. Center Subtitle, remove color.”

pandoc 3.2

“Use current standard Word theme (#7280). This includes using the sans-serif font Aptos instead of the serif font Cambria, and default colors for headings. Remove duplicate DefaultParagraphFont in styles.xml.”

pandoc 3.1.12.2

Here’s one relevant note: “Detect caption by style name not id (#9518). The styleId can change depending on the localization.”

I suspect that my issue with Title and Subtitle formatting might be related to a change in how style names are detected in Pandoc. In earlier versions, Pandoc always processed the reference.docx file based on English style names, regardless of the language settings in Microsoft Word.

It would be helpful if Pandoc could provide a way to standardize style name recognition independently of localization. This would prevent issues for users working with different language versions of Word.

jgm commented 36 minutes ago

What lang are you using? Does specifying lang: en make the problem go away?