Skip to content

inline code containing _ leads to an error in pdf output but works fine in html output #1613

Closed
helferthomas opened this Issue · 15 comments

6 participants

@helferthomas

Hi, my name is Helfer Thomas. I am a new user to pandoc.

I am trying to create a slideshow using pandoc. The following pandoc-markdown code leads to an error in pdf output but not in html output :

  • removing code introduced in the standard
    • enable\_if{.cpp}, typetraits{.cpp}, shared\_ptr{.cpp} <!-- end -->

I am using pandoc 1.12.4.2.

I used to following command to build the pdf:

pandoc -f markdown+tex_math_single_backslash --slide-level 2 --toc -t beamer -V theme:Warsaw test.md -o test.pdf

I used this command to build the html output :

pandoc -s -f markdown+tex_math_single_backslash --slide-level 2 --toc --mathjax -i -t revealjs -V theme:night test.md -o test.html

Helfer Thomas

@helferthomas

My example code seems to have been interpreted. The undersores in enable_if and shared_ptr shall not be escaped.

Sincerly

@mszep

I'm seeing this too on pandoc 1.13.0.1.

It seems to be a beamer specific issue, running

pandoc -f markdown -t beamer  test.md -o test.pdf 

results in the same error, but running

pandoc -f markdown -t latex  test.md -o test.pdf

works fine. However, the backslashes are showing in the pdf output, is that your intention?

@jgm
Owner
@jgm
Owner
@mszep

Also, the error persists when the backslashes are removed from the markdown source.

@jgm
Owner
@mszep

For anyone following along, the two beamer/latex outputs can be generated with:

pandoc -s -f markdown -t beamer  test.md -o test_beamer.tex

and

pandoc -s -f markdown -t latex  test.md -o test_latex.tex

Both contain unescaped underscores, so I'm actually more surprised that test_latex.tex compiles correctly.

@jgm
Owner
@u-fischer

beamer frames with verbatim content (that means a content which needs special \catcode settings) needs the option fragile:

If you wish to use a {verbatim} environment in a frame, you have to add the option [fragile] to the {frame} environment. In this case, you really have to use the {frame} environment (not the \frame command) and the \end{frame} must be alone on a single line. Using this option will cause the frame contents to be written to an external file and the read back. See the description of the {frame} environment for more details.

@helferthomas

Using the following page:
http://pbelmans.wordpress.com/2011/02/20/why-latex-beamer-needs-fragile-when-using-verbatim

I found a workaround is to use the option [fragile] after each begin{frame} containing verbatim code. Is this a satisfying solution ?

note : this was tested on the tex file generated by pandoc.

Sincerly,

Helfer Thomas

@jgm
Owner
@mszep

The LaTeX writer seems to already have this functionality, but it isn't getting triggered; see https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Writers/LaTeX.hs#L272

@helferthomas
@jgm
Owner
@olivuntu

Hello,
I am posting here because I've recently had the same issue using pandoc to produce beamer slideshows and found this thread. I was wondering if there is progress ? Would it be possible to add a 'fragile' option to markdown elements converted into frames for instance ? Message from @mszep suggests that pandoc already includes this, but it does not seem to perform well. But wonderful toolbox anyway !

@jgm jgm closed this in 2633dc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.