-
-
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
Starting in pandoc 2, figures without captions are left-justified in PDF output #4483
Comments
Here's the relevant changelog entry:
+ Require nonempty alt text for `implicit_figures` (#2844).
A figure with an empty caption doesn't make sense.
See #2844 for background.
If you want to make the image a figure anyway, then add a nonbreaking
space as the alt text, or (somewhat hackish and not guaranteed to be
future-proof:) add a title beginning with `fig:`.
Nathan Sheffield <notifications@github.com> writes:
… In pandoc 1, images without captions were centered by default. In pandoc 2, images without captions are left-justified.
Was this change intended? I did not see documentation of this change in the release notes. I believe this is a bug and images without captions should be centered in pandoc 2.
Reproducible example:
image.md:
```
# Here's an image:
![](example_figure.png)
```
example_figure.png:
![example_figure](https://user-images.githubusercontent.com/5271009/37775189-a7042726-2db8-11e8-8ea2-93918e1b33f3.png)
command: `pandoc image.md -o image.pdf
Result under pandoc1: [image.pdf](https://github.com/jgm/pandoc/files/1837819/image.pdf)
Result under pandoc2: [image-pandoc2.pdf](https://github.com/jgm/pandoc/files/1837820/image-pandoc2.pdf)
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#4483
|
Unfortunately, adding a non-breaking space still triggers "Figure 1:" as the caption. Any other suggestions for a work around here? It seems odd that images in pdfs are centered with a caption and left justified without; would you consider a pull request to center all images in pdfs? Thanks! |
For those having the problem, adding a Zero-width space does the trick. |
I wonder if there have been any developments on this. I have tried a thousand ways to do it and still can't make it work. |
You could achieve this with a Lua filter: |
Alright. I finally found a way. I'll leave the answer here for everyone else to see (worked for me in Pandoc 3.1.9): Using the Lua filter alone will add an unnecessary caption (images with captions are centered by default), so you need to:
-- Filter images with this function if the target format is LaTeX.
if FORMAT:match 'latex' then
function Image (elem)
-- Surround all images with image-centering raw LaTeX.
return {
pandoc.RawInline('latex', '\\hfill\\break{\\centering'),
elem,
pandoc.RawInline('latex', '\\par}')
}
end
end
pandoc --lua-filter=center.lua <YOUR FILE>.md -fmarkdown-implicit_figures -o <OUTPUT FILE>.pdf Adding a fake caption and then removing the plugin, as some in StackOverflow have suggested, won't work (image sticks to the left). |
Instead of |
I am producing PDF output from markdown source.
In pandoc 1, figures without captions were centered by default. In pandoc 2, figures without captions are left-justified.
Was this change intended? I did not see documentation of this change in the release notes. I believe this is a bug and figures without captions should be centered in pandoc 2.
Reproducible example:
image.md:
example_figure.png:
command: `pandoc image.md -o image.pdf
Result under pandoc1: image.pdf
Result under pandoc2: image-pandoc2.pdf
The text was updated successfully, but these errors were encountered: