Jeff Jeff - 2 months ago 27
LaTeX Question

What causes a pandoc document conversion error when blockquote follows header

I am using knitr in RStudio and I am looking for an explanation for an odd error when creating a document from an rmarkdown file. As in example, I have a file, pdf-test.Rmd:

---
title: "PDF knit error"
output: pdf_document
---

##Headers

> ###Quote 1
This results in an error; if the blockquote symbol ('>') in
preceeding line is removed, no error

> ###Quote 2
This line is fine


When I try to create a pdf using the Knit PDF button, this is the output:


|.................................................................| 100%
ordinary text without R code

processing file: pdf-test.Rmd
output file: pdf-test.knit.md

/usr/bin/pandoc +RTS -K512m -RTS pdf-test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pdf-test.pdf --template /home/jcoliver/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...

l.94 \end{quote}

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


As mentioned above, removing the block quote character (
>
) from the first instance makes the error go away (although so does the desired formatting).

---
title: "PDF knit error"
output: pdf_document
---

##Headers

###Quote 1
No error here

> ###Quote 2
This line remains fine


And there are no complaints from pandoc/LaTeX:


|.................................................................| 100%
ordinary text without R code

/usr/bin/pandoc +RTS -K512m -RTS pdf-test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pdf-test.pdf --template /home/jcoliver/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in'

processing file: pdf-test.Rmd
output file: pdf-test.knit.md

Output created: pdf-test.pdf


I can also avoid the error by changing the header level of the block quote to H4 or higher (H5, H6, etc.), while changing the header level of the first block quote to H1 or H2 still results in an error.

So why is this error occurring? Why can I not have a block quote with H3 immediately following a header? Note that I have tried different header levels on the header line(
#Headers
,
##Headers
,
###Headers
), varying spacing following the
##Headers
line, and a different output format (i.e. HTML), but the error always occurred.

A few system details:


  • Ubuntu 16.04

  • pandoc 1.17.2 (error also occurred with 1.16.0.2)

  • R 3.3.1

  • RStudio 0.99.489


CL. CL.
Answer

You want to quote a section header, directly after a section header? This sounds indeed special and it looks like pandoc cannot handle this.

As proposed in eipi10's answer, a solution is to add something between the header and the quote. However, I think you should not add white filler text to the document. For example, when you copy text from the PDF, the filler becomes visible.

Instead, just add an (empty) box: \mbox{}. Then, to avoid excessive vertical whitespace due to the extra line we introduced, add some negative vertical space: \vspace*{-1cm}.

---
output: pdf_document
---

##Headers

\mbox{}\vspace*{-1cm}

> ### Quoted Section

Foobar.

Output

Comments