Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
5.95k stars 951 forks source link

Pandoc 3.2.1 introduced new LaTex macro \pandocbounded #391

Open sonic-martin opened 1 week ago

sonic-martin commented 1 week ago

Explain the problem.

Pandoc introduced in release 3.2.1 new LaTex macro \pandocbounded which custom templates needs to provide:

LaTeX writer:

New method for ensuring images don’t overflow (#9660). Previously we relied on graphicx internals and made global changes to Gin to force images to be resized if they exceed textwidth. This approach is brittle and caused problems with \includesvg (see #9660). The new approach uses a new macro \pandocbounded that is now defined in the LaTeX template. (Thanks here to Falk Hanisch in https://github.com/mrpiggi/svg/issues/60.) The LaTeX writer has been changed to enclose \includegraphics and \includesvg commands in this macro when they don’t explicitly specify a width or height. In addition, the writer now adds keepaspectratio to the \includegraphics or \includesvg options if height is specified without width, or vice versa. Previously, this was set in the preamble as a global option. Users should attend to the following compatibility issues: If custom templates are used with the new LaTeX writer, they will have to be updated to include the new \pandocbounded macro, or an error will be raised because of the undefined macro.

pandoc readme.md -o doc.pdf --template=eisvogel

with readme.md:

# Reproducer
![image](picture.png "Random test image")

Pandoc version?

Pandoc 3.2.1 using the pandoc:extra docker image.

Reproducer

See https://github.com/sonic-martin/pandoc3.2.1-eisvogel-reproducer

iandol commented 1 week ago

https://github.com/jgm/pandoc-templates/commit/6c0e7b0a4f990debcd38b5c3bd8599193ae8f5a6#diff-f218051b4ca8f740a9f585a149101d4a3025037c568b391b5216edf7b14cfadc

jvsteiner commented 1 week ago

Bump - I am stuck on on pandoc 3.2 because I use eisvogel extensively (thanks for the awesomeness BTW)

ingcsmoreno commented 1 week ago

Hi, did you find any workarounds in the meantime? Facing this right now.

iandol commented 1 week ago

Add the code changes yourself, the diff is quite small (see my post above).

iandol commented 1 week ago

Here is my modified eisvogel template that works with Pandoc 3.2.1 (but note I made other changes to support academic metadata etc.):

https://github.com/iandol/dotpandoc/blob/master/templates/eisvogel.latex#L375

changes around line 375 -- https://github.com/iandol/dotpandoc/commit/e51c7540bad66d9664a97eaec35eb32b5b4658a9#diff-7cbc217435a06b6e85d604d450361df236dbad23dba7b6c12daec404e82f1d8e

jvsteiner commented 1 week ago

I did it myself as well, however, I think it would be better to incorporate them into the repository. I will work up a PR later today.

jvsteiner commented 1 week ago

https://github.com/Wandmalfarbe/pandoc-latex-template/pull/392

sonic-martin commented 1 week ago

I looked into the build process of the docker container images, and when your PR https://github.com/Wandmalfarbe/pandoc-latex-template/pull/392 would be merged, then in the next build it would be included in the pandoc docker files as well.

See https://github.com/pandoc/dockerfiles/blob/8ba91aaf8b81b44351044f706d557b97ad39470d/alpine/Dockerfile#L184

jvsteiner commented 1 week ago

I think the next line, with the version number will need to be updated though.