markdown additional Image width parameter for HTML/Epub, LaTeX/PDF output formats #350

wants to merge 5 commits into


None yet
rwst commented Nov 21, 2011

this resolves #332 and provides implementations in the HTML and LaTeX writers.
It is dependent on the two patches

What does it do? The markdown


will produce markdown output


or HTML output

<div class="figure">
<img src="image.jpg" width="100%" alt="alttext" /><p class="caption">alttext</p>

or LaTeX output


Any digits after the @ character will be interpreted as width percentage, atm

jgm commented Nov 21, 2011

I do appreciate the patch, but it is not going to be merged. In the future it would be better to discuss proposed syntax extensions on the pandoc-discuss list first, before coding anything. Image size syntax has been discussed before, and there are a number of intertwined issues that I haven't resolved. I don't want to make changes to the Pandoc type or especially the markdown syntax until I'm really convinced they're the best option. I think there are a couple of more natural and markdownish proposals than the one you implement here.

zhou13 commented Sep 21, 2012

I really hope that we can adjust image's size in pandoc. This bug has already lasted for 2 years.... And this patch really solve the problem.


Since everyone is having an issue with the image sizing in Pandoc, I think it is really necessary to have this included in Pandoc.


This is a +1 feature. We have been waiting for long time

jgm commented Mar 29, 2013

Why is it such a problem to resize the image itself? It just takes one call to ImageMagick's convert or mogrify command to do this. You can also set the DPI, so that a single image will render at the right size in both HTML and LaTeX. For example,

mogrify -density 150 -resize 300x300 my.jpg

will give you an image that displays on the web as 300x300 pixels, and as a 2 inch (300/150) square in LaTeX/PDF. Is the problem that the PDF image will then be too low-res? If so, one could easily create two images, one for the PDF and one for the HTML.

adityam commented Mar 30, 2013

Or just use a preprocessor like gpp. When I need more control over an image, I write

<##externalfigure filename|caption|height|width>

where externalfigure is a gpp macro that translates to the appropriate HTML and (in my case) ConTeXt syntax.


It is a problem because it is not intuitive and simple and it is contrary to what one expects out of pandoc markdown - simplicity. The whole purpose of using pandoc is to shred hard syntax or else one could have just used LaTeX itself.
Resizing an image is such a simple thing and it shouldn't require to install any third-party libraries/ modules.

qris commented May 3, 2013
  • Yes I can manually munge each image file, but couldn't Pandoc behave sensibly by default, as @shrutikapoor08 suggested? That would make it easier to use.
  • What if I can't find a single DPI setting that's appropriate for all output formats? e.g. a Beamer presentation and a printable document might want images at different sizes, but changing the DPI value in the image file affects both.
  • A documented means of controlling/overriding the image size would be extremely useful. (I don't know Latex well)
  • A solution independent of markup language would be useful, as I use RST and not Markdown, so the above patches won't help me.
  • Something I can add to the Pandoc template would be ideal.

The image size could depend on output format, so coding it in Markdown may be the wrong place. Pandoc is for text - maybe we need some kind of "panimage" to convert one image to different output formats, suitable for inclusion in PDF, HTML etc. One could also include videos this way. Anyway this feature is important but out of the core scope of Pandoc.

jgm commented May 21, 2013

+++ Jakob Voss [May 21 13 09:43 ]:

The image size could depend on output format, so coding it in Markdown
may be the wrong place. Pandoc is for text - maybe we need some kind of
"panimage" to convert one image to different output formats, suitable
for inclusion in PDF, HTML etc.

There is -- it's called ImageMagick!


Use of convert or mogrify together with Pandoc could still be simplified. For instance one should be able to scale an image to a specific width and height in mm or inch without having to calculate DPI and pixel. To improve usability we might need to collect use cases. For instance for slides one might want to scale some images to 100% width or 100% height, for PDF image size should be set in cm or inch, and for HTML/EPUB one needs size in pixel. Having to set all these values manually for all images feels wrong, both if specified in Markdown or if set in the image files.


I've looked at a lot of solutions, and this is by far the cleanest. nicely done

metasim commented Jan 28, 2014

+1 for /some/ sort of solution.


It would be great to have an elegant solution for this problem.


I second the call for an implementation of this. It doesn't have to be super fancy. Just a percentage is fine.

mb21 commented Oct 6, 2014

Note that the discussion on image dimensions is concentrated in this issue.

strout commented Feb 21, 2016

Is this PR still relevant now that #261 is closed? Should it be closed?

jgm commented Feb 21, 2016

This can be closed.

@jgm jgm closed this Feb 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment