10

I used knitR to convert R Markdown files to Markdown, and I'm trying to use Pandoc to convert them into HTML/PDF.

Markdown to HTML includes all my images in the output, using

pandoc test.md -o test.html

However, Markdown to PDF doesn't include any of my images in the output, using

pandoc test.md -o test.pdf

(there are other options because I am doing syntax highlighting that will show up in printed output, but no combination of them seem to include images in the PDF output).

In the actual Markdown file, images are referenced as:

<img src="images/image_to_include.png" title="Default title" alt="alt text" style="display: block; margin: auto;" />

where image_to_include.png is in the images subdirectory. The alternate text is not displaying either.

I would like to know how to get images to appear in the PDF output of Pandoc, but I am also curious to know why HTML seems to allow it and PDF doesn't.

My OS is Yosemite and I have installed MacTeX.

closed as off-topic by egreg, Maarten Dhondt, Svend Tveskæg, barbara beeton, Jesse Jul 2 '15 at 14:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." – egreg, Maarten Dhondt, Svend Tveskæg, barbara beeton, Jesse
If this question can be reworded to fit the rules in the help center, please edit the question.

10

Pandoc includes raw HTML only if the output format is HTML-like. From the web-site:

The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous, DZSlides, EPUB, Markdown, and Textile output, and suppressed in other formats.

In order to get images to work for both, HTML and PDF writer, you have to use pandoc's own format:

 ![la lune](lalune.jpg "Voyage to the moon")
  • Not so nice solution when we want to use a bit more complex html blocks, e.g., to have the image next to text and further resize the image. So, this use case is just not supported by pandoc ? – xtof54 Nov 5 '17 at 9:39
  • Well, this is still off topic, but you still can do whatever you want in HTML blocks. You can also use raw LaTeX. But if you want to generate multiple output formats you have to stick to pandoc's own ways. If you read the manual, you can find out about sizing options etc. And you can always write your own filters to do fancy stuff. Maybe you should ask a new question here if your problem is about generating LaTeX output with PDF . . . – DG' Nov 5 '17 at 12:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.