Knitr preamble error results in "pandoc document conversion failed with error 43"
Asked Answered
S

4

8

Rstudio Version 0.99.441; Windows 7 enterprise; knitr 1.10.5; MiKTex 0.4.5 r.1280 (2.9 64-bit)

I have a an error on my office computer when trying to knit PDF's in Rstudio, there are no problems knitting to HTML or word. The problem may be related to updates because knitting used to work fine and my home computer can knit to pdf without issue, however I took my computer home to update and the problem is still there.

My error message was as follows "pandoc.exe: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43"

I created a new file using the template example in Rstudio attempted to knit, then inspected the TEX output. I traced the error to the last paragraph of the preamble.

\setlength{\droptitle}{-2em}
 \title{Untitled}
 \pretitle{\vspace{\droptitle}\centering\huge}
 \posttitle{\par}
 \author{user name}
 \preauthor{\centering\large\emph}
 \postauthor{\par}
 \predate{\centering\large\emph}
 \postdate{\par}
 \date{\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\setcounter{enumi}{14}
\itemsep1pt\parskip0pt\parsep0pt
\item
  juni 2015
\end{enumerate}}

by removing the last 7 lines to do with enumerate and the date then running the TEX code the document prints as a PDF. Why is this happening and what can I do about it so the document knits at first click from Rstudio?

Spotlight answered 17/6, 2015 at 11:52 Comment(0)
B
3

You should show the YAML frontmatter of the R Markdown document. Guessing from my experience, the error was caused by

---
date: "14. Juni 2015"
---

Any number followed by a period (e.g. 14.) will be treated as an item in a numbered list. You need to either remove or escape the period . (by \\.) in the date field. The same issue has been reported before.

Baerman answered 17/6, 2015 at 15:56 Comment(4)
Yes that was the problem. In older scripts and on my home computer the date had been auto-completed using a different formatting so didn't have the problem. Thank you!Spotlight
@Yihui: Why is this still not fixed in RStudio? A brand newly created document in RStudio produces date: 12. Januar 2016 instead of date: 12\. Januar 2016.Acetal
@Acetal I didn't realize this problem could come from a newly created document (perhaps your system language is not English). I'll report to the team and change the default date format to avoid . in the date. Thanks!Baerman
@Yihui: RStudio has the English menu, so... otherwise it might be German.Acetal
J
1

This error can also be form having a curly quote or certain other characters. I spent ages on this pandoc error 43 before realising it was a block of text I had copied over form word.

e.g. Bob’s vs bob's

Jankell answered 12/10, 2015 at 11:29 Comment(0)
P
1

Another way to create this error is from having 'æ', 'ø' or 'å' in the file name.

Prototype answered 5/9, 2016 at 8:55 Comment(0)
S
0

My screw-up that resulted in this error was forgetting to put dollar signs around some inline latex code. I did

\theta

Instead of

$\theta$
Stingaree answered 16/11, 2017 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.