Pandoc Latex


Learn how to write a Makefile in order to generate professional looking documents from human-friendly Markdown sources.

  1. Pandoc Latex Block
  2. Pandoc Latex Tape

Browse other questions tagged latex pandoc or ask your own question. How often do people actually copy and paste from Stack Overflow? To create a LaTeX document, you just need to change the command slightly: pandoc -f markdown -t latex -s -o test1.tex Try opening test1.tex in your text editor. Pandoc can often figure out the input and output formats from the filename extensions.

Feb 12, 2020 Set Up iMessage on your iPhone 11/11 Pro/11 Pro Max From the Home screen, go to iPhone Settings. Tap on Messages Turn on the “iMessage” toggle. Scroll down and turn on/off the “Send as SMS” option. Nov 12, 2020 With iMessage apps, you can collaborate with others in a conversation, decorate messages with stickers, share a song, and more—without leaving Messages. Get started Download the latest version of iOS or iPadOS for your iPhone, iPad, or iPod touch. Imessage

LaTeX is a great markup language to write documents such as scientific articles or lessons,but writing directly in LaTeX sometimes results in very complex documents with many packages and macros.100% of the writing time isn’t focused on content as you have to format with the markup language.

Pandoc is a powerful multi-format document converter, and it is able to convert Markdown1 to LaTeX.So Pandoc is capable of writing the LaTeX corresponding to what you wrote as Markdown saving your time.And if you need a complex LaTeX command that Pandoc doesn’t support you can directly put LaTeX in the Markdown.

I am going to guide you through the creation of a Makefile2 to compile Markdown documents to PDF through XeTeX3.

  • Add some custom LaTeX header commands

Do I really need a Makefile?

Coming soon…

Basic Makefile

The idea is to create a directory in which you will be able to call make command to compile all Markdown documents inside.

The following is the content of a minimal Makefile file that builds and document2.mdto build/document1.pdf and build/document2.pdf using XeTeX.

DEP contains all files that may be included in documents.Changes to those files (here those who end in .sty, .tex, .jpg or .png) will imply a new compilation next time make is called.

Add some custom LaTeX header commands

To modify Pandoc LaTeX output, you can modify Pandoc LaTeX template, or more simply just append commands in the header.I personally prefer the second method which seems cleaner and doesn’t touch Pandoc internal files.

You can append code in the header directly in a parameter or pass a file.

Include a file in LaTeX header

The following shows an example creating a page footer using fancyhdr package.

First of all, create a file header.tex containing the custom LaTeX header:

Now pass the file to Pandoc by appending a parameter in the Makefile:

Directly add commands to LaTeX header

Pandoc latex machine

It’s quite the same that previously except everything is done inside the Makefile:

Change document font family

The following describes how to change the font to TeX Gyre Pagella.

XeLaTeX uses OpenType fonts so you have to download your font in an OpenType format and place it in a fonts directory. You will have a structure like this one:

Then in the Makefile add four parameters to Pandoc:

Resulting Makefile

TL;DR. To summarise, the following Makefile groups all previous modifications. That is actually my daily driver:

Bonus: convert your old documents to Markdown

Pandoc is able to convert many types of document such as Word (.docx) and LaTeX (.tex) to Markdown (.md).

Pandoc Latex

Just try something like:

  1. According to Wikipedia: “Markdown is a lightweight markup language with plain text formatting syntax.” All this website content was written in Markdown! ↩

  2. According to Wikipedia: “A Makefile is a file containing a set of directives used with by make build automation tool to generate a target/goal.” ↩

  3. XeTeX is a TeX/LaTeX engine using Unicode and supporting OpenType font. ↩

Pandoc Latex Block

This release includes breaking changes.

Pandoc Latex Tape

  • Merged changes from the pandoc default LaTeX template.

  • Fix broken travis build by modifying the --resource-path

    When specifying the resource path via --resource-path the template will be searched there since pandoc
    To fix the broken travis build (Could not find data file templates/eisvogel.latex) the current working directory . is included in the resource path for pandoc to find the template again.

    For more information visit the pandoc issue jgm/pandoc#6618.

  • Rename template to eisvogel.latex after release (#182). There is no need for renaming the template file after the download.

    This is a breaking change because there will be no file eisvogel.latex in the released artifacts anymore.

  • Option logo-width has no hard coded unit pt anymore (#221).

    The width of the logo can be specified with various units e.g. pt, in, mm.

    This is a breaking change because a previously specified logo-width without a unit needs a unit now. If there is no unit LaTeX will emit an error Illegal unit of measure (pt inserted) and no document will be created.

    The default value for logo-width has also changed from 100pt to 35mm.