3
votes

When generating a PDF from markdown using pandoc, the markdown is converted into LaTeX. I am using a customized template to style my PDF.

When I create an image link:

![Alt text](image.png)

the following LaTeX is generated.

\begin{figure}[htbp]
\centering
\includegraphics{image.png}
\caption{Alt text}
\end{figure}

The image is, not surprisingly, centered on the PDF.

How do I prevent the \centering tag from being generated?

1

1 Answers

1
votes

Probably you can't, but if your document does not use \centering for any other purpose, you can redefine it at as "void" (\relax) before it is used. You can do this in several ways:

  • Include the line \def\centering{\relax} at the beginning of your pandoc document. Pandoc passes all latex code "as is" to the resulting .tex file.
  • Modify your latex template and include the definition of \centering at the appropiate point (for example, just before \begin{document}
  • If you are using pandoc's standard template, you can still insert code into it at compile-time, using pandoc's --variable option to define the variable header-includes. For example:

    pandoc -s --variable:header-includes="\\def\\centering{\\relax}" yourdoc.markdown -o yourdoc.tex