Skip to content

Instantly share code, notes, and snippets.

@c-x
Created August 26, 2014 13:21
Show Gist options
  • Save c-x/2e5c6e39b334676378c1 to your computer and use it in GitHub Desktop.
Save c-x/2e5c6e39b334676378c1 to your computer and use it in GitHub Desktop.
Markdown to PDF with automatic wrapping

Conversion of a Markdown to a PDF file using Pandoc

# pandoc -s -S README.md -o /tmp/README.pdf

However, when you have very long lines (code, logs, etc), the lines are not automatically wrapped (so you loose information).

To automatically wrap long lines using nice arrows, edit the pandoc PDF template (default.latex by default).
See http://johnmacfarlane.net/pandoc/demo/example9/templates.html

From

$if(listings)$
\usepackage{listings}
$endif$

To

$if(listings)$
\usepackage{listings}
\lstset{
    breaklines  = true,
    postbreak   = \mbox{$$\hookrightarrow$$},
    basicstyle  = \small\ttfamily
    }
$endif$

Now change you command line to :

# pandoc --listings -s -S README.md -o /tmp/README.pdf

You should have lines wrapped with nice arrows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment