jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.02k stars 3.35k forks source link

Problem in beamer with certain formatting in section titles #2935

Closed todd-a-jacobs closed 3 years ago

todd-a-jacobs commented 8 years ago

Problem

The following results in an error:

pandoc -t beamer -o slides.pdf -V theme:Szeged --slide-level=2 *md

The error is:

 Argument of \@gobble has an extra }.
 <inserted text> 
                \par 
l.73 (10 min)}{Meeting Overview (10 min)}}

pandoc: Error producing PDF

However, removing the theme declaration allows the PDF to build, but (obviously) with the theme. This appears to be true regardless of what theme is selected. I also tried it with Frankfurt to be sure it wasn't just the one theme.

Environment

$ pandoc --version
pandoc 1.17.0.3
Compiled with texmath 0.8.5, highlighting-kate 0.6.2.
Syntax highlighting is supported for the following languages:
    abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c,
    changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css,
    curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd,
    eiffel, elixir, email, erlang, fasm, fortran, fsharp, gcc, glsl,
    gnuassembler, go, hamlet, haskell, haxe, html, idris, ini, isocpp, java,
    javadoc, javascript, json, jsp, julia, kotlin, latex, lex, lilypond,
    literatecurry, literatehaskell, llvm, lua, m4, makefile, mandoc, markdown,
    mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2,
    modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave,
    opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r,
    relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci,
    sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl,
    xml, xorg, xslt, xul, yacc, yaml, zsh
jgm commented 8 years ago

Can you provide a markdown file for us to use in input in testing, that allows the problem to be reproduced with the command line you provided?

todd-a-jacobs commented 8 years ago

@jgm Not one that's for public consumption. I will try to email you instead.

todd-a-jacobs commented 8 years ago

@jgm This tends to break when headers have embedded newlines for visual effect. For example:

# Break\
(10 min)

will cause the error. However, simply removing the backslash seems to resolve the issue, but prevents one from putting in sensible line breaks in long slide titles.

jgm commented 8 years ago

This has nothing to do with themes. You can reproduce it with pandoc -t beamer -o my.pdf on this simple input:

# foo\
bar

Although section headers containing line breaks seem to work in LaTeX, they don't work in Beamer. I don't know why, but I don't see anything pandoc can do about this.

Note: although this method of getting a line break in a header works in pandoc, it's not at all portable, and may not work in the future. I would avoid this.

jgm commented 8 years ago

OK, it's slightly more complex than I thought! Using test.md:

# foo\
bar

we get the error. But with test2.md:

# foo\
bar

ok

we do not.

The difference in the latex source produced can be illustrated thus:

% pandoc -t beamer 
# foo\ 
bar
^D
\section{\texorpdfstring{foo\\
bar}{foo bar}}\label{foo-bar}
% pandoc -t beamer 
# foo\
bar

ok
^D
\begin{frame}{foo\\
bar}

ok

\end{frame}
jgm commented 8 years ago

Relevant thread here: http://tex.findincity.net/view/63539927362983362659384/using-textit-in-section-with-beamer-class

Note that we get similar problems if instead of a line break we use, say, an emphasized word:

# Foo *bar* baz

I've tried inserting \protect in the generated tex, but it doesn't seem to help.

jgm commented 7 years ago

Really this has to do with \texorpdfstring.

heathermiller commented 6 years ago

Same problem here.

tarleb commented 3 years ago

This seems to have been fixed, I can no longer reproduce the issue. Both of the following compile fine with pandoc 2.13:

pandoc -t beamer -f html -o out.pdf <<< '<h1>foo<br/>bar</h1>foo'
pandoc -t beamer -f html -o out.pdf <<< '<h1>foo<br/>bar</h1>'