jgm / pandoc

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

LaTeX error with link in header #781

Closed Hocdoc closed 8 years ago

Hocdoc commented 11 years ago

When a markdown document contains anywhere in the text a link inside a header I get this LaTeX error when producing a PDF:

pandoc: Error producing PDF from TeX source.
! File ended while scanning use of \@@BOOKMARK.
<inserted text> 
                \par 
l.42 \begin{document}

Document:

# Hello <http://yahoo.de>

world.

Pandoc Call:

pandoc document.markdown -o result.pdf

I use pandoc 1.9.4.1.

jgm commented 11 years ago

The latex produced is:

\section{Hello \url{http://yahoo.de}}

Apparently there is some incompatibility between \url and \section. Try searching for a solution to this on LaTeX forums (like tex.stackexchange.com). If you figure out how to get a link in a section header in LaTeX, I can change pandoc to produce code that works.

+++ Hocdoc [Mar 12 13 01:52 ]:

When a markdown document contains anywhere in the text a link inside a header I get this LaTeX error when producing a PDF: pandoc: Error producing PDF from TeX source. ! File ended while scanning use of \@@BOOKMARK.

\par l.42 \begin{document} Document: # Hello http://yahoo.de world. Pandoc Call: pandoc document.markdown -o result.pdf I use pandoc 1.9.4.1. — Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-Xfk2hCWY6txMT4gXDF_IkMsPE4CX_M3Wun5obF514R.gif] References 1. https://github.com/jgm/pandoc/issues/781
scottgwald commented 11 years ago

If you instead ask pandoc for tex output, running pdflatex on that output actually produces the desired pdf with a link in its section header (with some warnings from the hyperref package). The problem occurs on the second run of pdflatex, where it finds a .out file (beginning with "\BOOKMARK") that is apparently malformed. I don't know what that .out is actually supposed to be used for, but I thought this observation might be helpful.

On Tue, Mar 12, 2013 at 12:06 PM, John MacFarlane notifications@github.comwrote:

The latex produced is:

\section{Hello \url{http://yahoo.de}}

Apparently there is some incompatibility between \url and \section. Try searching for a solution to this on LaTeX forums (like tex.stackexchange.com). If you figure out how to get a link in a section header in LaTeX, I can change pandoc to produce code that works.

+++ Hocdoc [Mar 12 13 01:52 ]:

When a markdown document contains anywhere in the text a link inside a header I get this LaTeX error when producing a PDF: pandoc: Error producing PDF from TeX source. ! File ended while scanning use of \@@BOOKMARK.

\par l.42 \begin{document} Document: # Hello http://yahoo.de world. Pandoc Call: pandoc document.markdown -o result.pdf I use pandoc 1.9.4.1. — Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-Xfk2hCWY6txMT4gXDF_IkMsPE4CX_M3Wun5obF514R.gif] References 1. https://github.com/jgm/pandoc/issues/781

— Reply to this email directly or view it on GitHubhttps://github.com/jgm/pandoc/issues/781#issuecomment-14784532 .

jgm commented 11 years ago

Interesting. It might be worth posting on pandoc-discuss; there are some people there who know LaTeX better than I do, and they might have an aswer.

+++ swgreen [Mar 12 13 10:01 ]:

If you instead ask pandoc for tex output, running pdflatex on that output actually produces the desired pdf with a link in its section header (with some warnings from the hyperref package). The problem occurs on the second run of pdflatex, where it finds a .out file (beginning with "\BOOKMARK") that is apparently malformed. I don't know what that .out is actually supposed to be used for, but I thought this observation might be helpful. On Tue, Mar 12, 2013 at 12:06 PM, John MacFarlane notifications@github.comwrote:

The latex produced is:

\section{Hello \url{http://yahoo.de}}

Apparently there is some incompatibility between \url and \section. Try searching for a solution to this on LaTeX forums (like tex.stackexchange.com). If you figure out how to get a link in a section header in LaTeX, I can change pandoc to produce code that works.

+++ Hocdoc [Mar 12 13 01:52 ]:

When a markdown document contains anywhere in the text a link inside a header I get this LaTeX error when producing a PDF: pandoc: Error producing PDF from TeX source. ! File ended while scanning use of \@@BOOKMARK.

\par l.42 \begin{document} Document: # Hello http://yahoo.de world. Pandoc Call: pandoc document.markdown -o result.pdf I use pandoc 1.9.4.1. — Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-Xfk2hCWY6txMT4gXDF_IkMsPE4CX_M3Wun5obF514R.gif] References 1. https://github.com/jgm/pandoc/issues/781

— Reply to this email directly or view it on GitHubhttps://github.com/jgm/pandoc/issues/781#issuecomment-14784532 .

— Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-Xfk2hCWY6txMT4gXDF_IkMsPE4CX_M3Wun5obF514R.gif]

References

  1. https://github.com/jgm/pandoc/issues/781#issuecomment-14788100
kirelagin commented 11 years ago

I bet this has something to do with the fact that hyperref makes section headers in the TOC link to their sections. Having a link inside another link kinda doesn't make much sense.

For the same reason there is no easy way to use \MakeUppercase in chapter/section/… titles.

skillachie commented 10 years ago

Using R studio and R markdown which uses pandoc. I was able to redproduce a similar error if email was used in the heading.

pandoc-1.13.0.1

# test13@gmail.com 
! File ended while scanning use of \@@BOOKMARK.
<inserted text> 
                \par 
l.91 \begin{document}

pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
Execution halted

Results in the error below

It goes away when I remove the email as a heading

jgm commented 10 years ago

This works fine:

echo "# test13@gmail.com" | pandoc -o my.pdf

Of course, it may be that some combination of options that R Studio uses when it calls pandoc produces the error. In order to help further, we'd need to know the exact pandoc command R Studio used in this case.

I would suggest reporting this to the R Studio developers, who can then let us know if it turns out that there is a problem with pandoc.

skillachie commented 10 years ago

It does work. Will have to look further into R studio and reach out to them. Thank you for your time

malcook commented 9 years ago

I came here in search for a solution to the same

! File ended while scanning use of \@@BOOKMARK.
<inserted text> 
                \par 
l.91 \begin{document}

Though I did not (yet) get my solution, the following this may be diagnostic to, erhm, others...

$ echo "# test13@gmail.com" | pandoc -o my.pdf --from markdown

works fine, but adding the option autolink_bare_uris errors out:

$ echo "# test13@gmail.com" | pandoc -o my.pdf --from markdown+autolink_bare_uris
! Undefined control sequence.
\Url Error ->\url used in a moving argument. 

l.52 ...@gmail.com}{\nolinkurl{test13@gmail.com}}}

pandoc: Error producing PDF from TeX source

autolink_bare_uris is one of the pandoc options that knitr rmarkdown::render uses (at least by default in my hands today)

FWIW:

$ Rscript  -e 'packageVersion("rmarkdown")'
[1] ‘0.5.3.1’

and

 pandoc -v
pandoc 1.13.1
Compiled with texmath 0.8, highlighting-kate 0.5.9.
Syntax highlighting is supported for the following languages:
    abc, actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c,
    changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css,
    curry, d, diff, djangotemplate, dot, doxygen, doxygenlua, dtd, eiffel,
    email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, haskell,
    haxe, html, ini, isocpp, java, javadoc, javascript, json, jsp, julia, latex,
    lex, lilypond, literatecurry, literatehaskell, 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
Default user data directory: /home/mec/.pandoc
Copyright (C) 2006-2014 John MacFarlane
Web:  http://johnmacfarlane.net/pandoc
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
adunning commented 8 years ago

I cannot reproduce this with Pandoc 1.15.1.1 and TeX Live 2015.

jgm commented 8 years ago

Yes - this seems to have been resolved.