-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
New approach to preventing image overflow in LaTeX (fixes #9660) #9666
Conversation
An approach like this might make it necessary to reconsider #8249. Or maybe to publish a |
@tarleb I think I'd rather not publish a pandoc CTAN package; that's one more maintenance step required in every release. Big changes like this are relatively rare, but in general one does have to keep an eye on template changes if one uses custom templates. I don't remember why I haven't merged this yet. I suppose it's because I'm worried about people who will use custom templates with the new pandoc and get errors about undefined #8249 is still a cool idea and would largely avoid issues like this; I just haven't gotten around to exploring it. |
I'm torn. On one hand I worry about how much this would impact the usefulness of LaTeX snippets, and how the snippets are becoming more pandoc-specific. On the other hand, I fully agree that this solves a real problem, and I'm aware that some people, all of whom know much more about LaTeX than I do, have been complaining about the current image scaling method. Adding a |
We're already using some pandoc-specific things in our output, e.g. |
In principle, we could omit the |
It's also a possibility to patch Maybe it's okay to do something slightly painful and start using |
I've just been facing issues with the pandoc and SVG files, so this would be a welcome change. Thanks for the hardwork on this! |
Note that up to 2014 we did redefine includegraphics in the template: see commit a3cce8d |
b48c90c
to
ab875ea
Compare
I agree that this is preferable over the current system. I can open a new issue to discuss something like a |
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 mrpiggi/svg#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. 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. - Documents that specify explicit dimensions for an image may render differently, if the dimensions are greater than the line width or page height. Previously pandoc would shrink these images to fit, but the new behavior takes the specified dimensions literally. In addition, pandoc previously always enforced `keepaspectratio`, even when width and height were both specified, so images with width and height specified that do not conform to their intrinsic aspect ratio will appear differently. Closes #9660.
Instead of relying on graphicx internals, we now define a macro that gets used with images when explicit size information is not provided. This macro prevents the image from overflowing vertically or horizontally.
Templates will have to be updated to include the new macro.
Closes #9660.
The macro should be credited to @mrpiggi. See mrpiggi/svg#60 for discussion.