0

I'm trying to print the results of a data frame as a table in a PDF using knitr, and more specifically kable. When I pass the data frame using kable(df, format = 'latex') it produces a basic, unformatted table. As soon as I try to add any styling (e.g. booktab = T or kable_styling), I receive a series of errors once R tries to call:

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS Payments.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc2b922cfdb1c9.pdf --template /Library/Frameworks/R.framework/Versions/3.3/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in'

When I Google the resulting error, the suggestion is usually to include a -/usepackage{} statement with a certain package. However, every time I do that, a new error appears at the same step next time I run my script.

Here are the errors I've received so far, and the packages I used to resolve them:

1)

! LaTeX Error: Unknown float option `H'.
l.87 \begin{table}[H]

  - \usepackage{float}

2)

! Undefined control sequence.
l.89 \centering\rowcolors

- \usepackage[table]{xcolor}

3)

<argument> ...r}{lllllll} \hiderowcolors \toprule 
l.100 \end{tabular}}

- \usepackage[table]{\centering}

At this point I got tired of whack-a-mole, and I feel like there's a bigger underlying issue. I also regularly receive:

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

Anyone have any insight as to why such a basic function that appears to be relatively stable is causing me so many errors? Is there a way to force the program to try to run everything so I can see how many errors there are?

Nicholas Hassan
  • 949
  • 2
  • 10
  • 27

1 Answers1

1

You could try to narrow down the issue by producing an intermediate tex file

---
output:
  pdf_document:
    keep_tex: yes
---

And then try to run this file in your tex application (e.g. texworks).

Note that I've also provided an answer to your question (how to add a link to the bookstab package) there

Cedric
  • 2,412
  • 17
  • 31