I have a markdown document that defines a LaTeX macro and then calls it. When
I use pandoc to convert this document to LaTeX, I don't get the result that I
expect. The problem is related to a %
sign (LaTeX comment sign) at the end of
my macro definition. For example, consider this markdown file:
\newcommand\myMacro{Hello!}%
\myMacro
When I run pandoc example.md --to latex-latex_macros
, I expect it to produce a LaTeX file
that looks just like the code block above. Instead, I get
\newcommand\myMacro{Hello!}
\% \myMacro
If I add the hard_line_breaks
option by calling
pandoc example.md --to latex --from markdown-latex_macros+hard_line_breaks
, I get better
output, but still not what I expect:
\newcommand\myMacro{Hello!}
\%\\
\myMacro
(Using --wrap=preserve
produces a similar result.) I am using pandoc 2.9.2,
and I get the same result on Ubuntu and on Windows. I've experimented with
other pandoc options, and they don't seem to help. In particular, I've used
the eol
pandoc option; it doesn't make a difference, which leads me to think
that this problem isn't due line breaks being LF or CRLF.
Why is pandoc parsing my .md file in this way? And what can I do to get it to produce a LaTeX file that looks like the first code block in this post? I've read SO posts, the pandoc user guide, and issues on the pandoc Github site. Some of them are related: for example, this Github issue and Preserve Line Breaks in Pandoc Markdown -> LaTeX Conversion. But I can't see that any of them speak directly to this problem.