By default, Pandoc will preserve raw LaTeX code in Markdown documents when converting the document to LaTeX, so you can use LaTeX commands or environments in Markdown. However, sometimes your LaTeX code might be too complex for Pandoc to parse, in which case Pandoc will treat the content as normal Markdown. The consequence is that special LaTeX characters may be escaped, e.g., Pandoc may convert a backslash \
to \textbackslash{}
.
To make sure that Pandoc does not touch the raw LaTeX code in your Markdown document, you may wrap the code in a fenced code block with the attribute =latex
, e.g.,
```{=latex}
\begin{tabular}{ll}
A & B \\
A & B \\
\end{tabular}
```
Do not forget the equal sign before latex
, i.e., it is =latex
instead of latex
. This feature requires a Pandoc version higher than 2.0 (check rmarkdown::pandoc_version()
).