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

Pandoc conversion: is it possible to display some pages in landscape format? #1165

Open
Yuri05 opened this issue Jan 4, 2024 · 8 comments
Open

Comments

@Yuri05
Copy link
Member

Yuri05 commented Jan 4, 2024

While the word report converted via pandoc still should be in the portrait format: is it possible to display only the pages with tables in landscape format?

Theoretically should be possible via openXML, but I did not manage to get it working.

E.g. this did not work for me (in the converted word document all pages still had the same (portrait) orientation:

# My Document

This is some text. This page is in Portrait layout.

::: {custom-style="PageBreak"}
\ 
:::

```{=openxml}
<w:sectPr>
  <w:pgSz w:w="16838" w:h="11906" w:orient="landscape"/>
</w:sectPr>

Landscape Section

This is some text. This page is in Landscape layout.

::: {custom-style="PageBreak"}
\
:::

<w:sectPr>
  <w:pgSz w:w="11906" w:h="16838" w:orient="portrait"/>
</w:sectPr>

Portrait Section

This is some text. The page is back to Portrait layout.

@Yuri05
Copy link
Member Author

Yuri05 commented Jan 4, 2024

s. also jgm/pandoc#7255

@Yuri05
Copy link
Member Author

Yuri05 commented Jan 4, 2024

There is a solution with lua filter, but as described in this discussion it destroys header/footer.

I tried it out: indeed, required pages are inserted as landscape, but the header is destroyed (e.g. "Page X/Y" is not displayed on some pages):
pandoc --toc --from=markdown+tex_math_dollars+superscript+subscript+raw_attribute --reference-doc=reference2.docx -t docx -o test2.docx test2.md --lua-filter=docx-landscape.lua
Landscape_Lua.zip

@pchelle
Copy link
Collaborator

pchelle commented Jan 4, 2024

@Yuri05 I had a look at the .lua file.
It includes <w:p><w:pPr><w:sectPr></w:sectPr></w:pPr></w:p> to end a portrait section and it includes

<w:p>
  <w:pPr>
    <w:sectPr>
      <w:pgSz w:h="11906" w:w="16838" w:orient="landscape" />
    </w:sectPr>
  </w:pPr>
</w:p>

to end a landscape section.

I tested that out including the raw openxml code block ```{=openxml} and it worked.
But we have to be cautious of the positionning of these blocks to make them work the right way.

@Yuri05
Copy link
Member Author

Yuri05 commented Jan 4, 2024

I tested that out including the raw openxml code block ```{=openxml} and it worked.
But we have to be cautious of the positionning of these blocks to make them work the right way.

Did you use our references.docx during the conversion and were the headers/footers (particularly the page numbering) kept?

@pchelle
Copy link
Collaborator

pchelle commented Jan 4, 2024

Did you use our references.docx during the conversion and were the headers/footers (particularly the page numbering) kept?

I used the reference, I get the same results as test2.docx: page number is only printed on the last page

@pchelle
Copy link
Collaborator

pchelle commented Jan 4, 2024

To include the footer/header from the default, we need to add the following within the section break (ie between <w:sectPr>)

<w:headerReference w:type="default" r:id="rId9"/>
<w:footerReference w:type="default" r:id="rId10"/>

I got the header/footer identifiers from the openxml content of the reference document, so it is not certain that the trick will work for user-defined reference documents.

@Yuri05
Copy link
Member Author

Yuri05 commented Jan 4, 2024

Risky...

@pchelle
Copy link
Collaborator

pchelle commented Jan 5, 2024

When I first tested, I did not check the reference openxml content, so I used the wrong ids (1, 2, 3).
It simply resulted in the header and footer not present without corrupting the word document.

I also tried to modify the reference document by changing header and footer, both were rendered correctly.

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

2 participants