Questions tagged [pandoc]

Pandoc is an open-source, command-line, universal document converter for converting between various markup formats.

If you need to convert files from one markup format into another, pandoc is your swiss-army knife. Pandoc can convert documents in any of thirty supported input formats, e.g., Markdown, reStructuredText, textile, HTML, DocBook, or LaTeX, to more than fifty output formats:

Pandoc understands a number of useful Markdown syntax extensions, including document metadata (title, author, date); footnotes; tables; definition lists; superscript and subscript; strikeout; enhanced ordered lists (start number and numbering style are significant); running example lists; delimited code blocks with syntax highlighting; smart quotes, dashes, and ellipses; Markdown inside HTML blocks; and inline LaTeX. If strict Markdown compatibility is desired, all of these extensions can be turned off.

LaTeX math (and even macros) can be used in Markdown documents. Eight different methods of rendering math in HTML are provided, including MathJax and translation to MathML. LaTeX math is rendered in docx using native Word equation objects.

Pandoc includes a powerful system for automatic citations and bibliographies, using Andrea Rossato’s citeproc-hs. This means that you can write a citation like

[see @doe99, pp. 33-35; also @smith04, ch. 1]

and pandoc will convert it into a properly formatted citation using any of hundreds of CSL styles (including footnote styles, numerical sytles, and author-date styles), and add a properly formatted bibliography at the end of the document. Many forms of bibliography database can be used, including bibtex, RIS, EndNote, ISI, MEDLINE, MODS, and JSON citeproc. Citations work in every output format.

Pandoc includes a Haskell library and a standalone command-line program. The library includes separate modules for each input and output format, so adding a new input or output format just requires adding a new module.

Pandoc is free software, released under GPL2-or-later. © 2006-2020 John MacFarlane.

2486 questions
27
votes
5 answers

Converting all files in a folder to md using pandoc on Mac

I am trying to convert an entire directory from html into markdown. The directory tree is quite tall, so there are files nested two and three levels down. In answering this question, John MacFarlane suggested using the following…
apc
  • 1,497
  • 3
  • 13
  • 19
27
votes
6 answers

How to convert Markdown + CSS -> PDF?

I'm trying to convert a Markdown file into a PDF. I'm looking for only two things: A way to easily change the style of the pdf (for example with a CSS file) A syntax highlighter for code blocks What tools can I use for that? I tried Pandoc, but it…
pimpampoum
  • 5,816
  • 6
  • 24
  • 27
26
votes
1 answer

How do I specify tables in my Markdown document using pandoc syntax?

I have a markdown document I'm processing with the pandoc tool to generate HTML and PDF documents. I'm trying to include a table in the document. Regular markdown doesn't support tables, but pandoc does. I've tried copy-pasting the definition of a…
mpvvliet
  • 293
  • 1
  • 3
  • 8
26
votes
5 answers

How can I specify pandoc's markdown extensions using a YAML block?

Background Pandoc's markdown lets you specify extensions for how you would like your markdown to be handled: Markdown syntax extensions can be individually enabled or disabled by appending +EXTENSION or -EXTENSION to the format name. So, for…
briandk
  • 6,749
  • 8
  • 36
  • 46
25
votes
3 answers

Inserting a page break within a code chunk in rmarkdown (converting to pdf)

I am using rmarkdown, pandoc and knitr to create a pdf including chunks of r code. Within a code chunk I have a for loop which prints a number of graphs and some statistical output. I would like to insert a page break into the loop (to appear in…
Rachel
  • 305
  • 1
  • 4
  • 8
25
votes
3 answers

Preserve Line Breaks in Pandoc Markdown -> LaTeX Conversion

I want to convert the following *.md converted into proper LaTeX *.tex. Lorem *ipsum* something. Does anyone know lorem by heart? That would *sad* because there's always Google. Expected Behavior / Resulting LaTeX from Pandoc Lorem \emph{ipsum}…
maxheld
  • 3,963
  • 2
  • 32
  • 51
25
votes
2 answers

How to use latex equation environment in Pandoc Markdown?

In Pandoc markdown, I can use '$$' to start a display math environment. However, these equations are not numbered in latex so I hope to use the equation environment instead, like this: \begin{equation} x+1 = 2 \\ y+2 = 3 \end{equation} That's fine…
Stan
  • 2,010
  • 3
  • 16
  • 12
24
votes
5 answers

Pandoc generation of pdf from markdown 4th header is rendered differently

I am using pandoc to generate a pdf from some markdown. I am using h1 through h4 via hash symbols. Example h1=#, h4=####. When I generate my document like this: pandoc input.md -o output.pdf I get a document where h1, h2 and h3 have a newline after…
storrgie
  • 379
  • 2
  • 3
24
votes
1 answer

pandoc "cannot parse yaml header" when converting md to pdf

I am trying to convert a markdown document to pdf using pandoc, and it was working fine until it just started to show an error: pandoc: Could not parse YAML header: did not find expected alphabetic or numeric character "source" (line 32, column…
DarkKight666
  • 321
  • 1
  • 3
  • 7
23
votes
2 answers

How to cite multiple papers in RMarkdown

How do I cite multiple papers in RMarkdown as I would do in LaTex with \cite{Bartel2004, Bartel2009a} I tried [@Bartel2004, @Bartel2009a] which renders to (D. P. Bartel 2004, David P. Bartel (2009)) which is not too bad, but the second brackets…
Gregor Sturm
  • 2,792
  • 1
  • 25
  • 34
23
votes
4 answers

How to convert HTML to PDF using pandoc?

Which libraries do I need? Which command line parameters do I need to pass? I've installed wkhtml2pdf and I've tried to run: pandoc reports/7/report.html -t pdf -o reports/7/report.pdf Which reports an error of: To create a pdf with pandoc, use…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
22
votes
3 answers

Image centering with pandoc markdown

I need to create documents periodically for Word-using administrators. How can I centre an image using pandoc markdown? I see mention of div blocks, but I have no idea what they are. ![](myimage.png){.center} With image code such as that above,…
user2023370
  • 10,488
  • 6
  • 50
  • 83
22
votes
1 answer

Docker : Can a container A call an executable located on an other container B?

I have two Docker images, one containing pandoc (an utility to convert documents in different formats to many formats), and an other containing pdflatex (from texlive, to convert tex files into pdf). My goal here is to convert documents from md to…
norbjd
  • 10,166
  • 4
  • 45
  • 80
22
votes
4 answers

Level 1 and level 2 slides in reveal.js using pandoc

I am generating a slideshow in markdown to be converted by pandoc into html (with pandoc -s -S -t revealjs test.md -o test.html). The reveal.js framework allows a 2D setup: grouping of slides within slide subsets "vertically", and grouping of the…
January
  • 16,320
  • 6
  • 52
  • 74
22
votes
4 answers

Figure sizes with pandoc conversion from markdown to docx

I type a report with Rmarkdown in Rstudio. When converting it in html with knitr, there is also a markdown file produced by knitr. I convert this file with pandoc as follows : pandoc -f markdown -t docx input.md -o output.docx The output.docx file…
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225