I am running into an issue in the process of generating PDFs through R/Sweave/tinytex on a CentOS server. Here is the command that runs the process:
(generateReport.R)
Sweave(rnwFile, encoding = "UTF-8", output=filename)
tools::texi2pdf(filename)
The error occurs once the .tex is being converted into a .pdf via the tools:texi2pdf command and reads as follows:
! Missing \endcsname inserted.
<to be read again>
\egroup
l.118 \begin
{threeparttable}
! ==> Fatal error occurred, no output PDF file produced!
Calls: <Anonymous> -> texi2dvi
After chopping up my code to figure out where the error occurs from, I can tell it is originating from within its huxtable. I will post the important part of the RNW file here:
\documentclass[letterpaper,12pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{array}
\usepackage{lastpage}
\usepackage{multirow}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{array}
\usepackage{caption}
\usepackage{siunitx}
\usepackage[normalem]{ulem}
\usepackage{colortbl}
\usepackage{hhline}
\usepackage{calc}
\usepackage{tabularx}
\usepackage{threeparttable}
\usepackage{wrapfig}
\usepackage{adjustbox}
\usepackage[hmargin=1cm,top=5cm,headheight=6cm,footskip=40pt]{geometry}
<<external-code, warning=FALSE, message=FALSE, echo=FALSE>>=
options(width=60)
library(dplyr)
library(stringr)
library(mongolite)
library(huxtable)
library(knitr)
# r code for getting data here, works fine
#....................
huxTable <- as_hux(df1)
huxTable <- huxTable %>%
set_align(1, everywhere, "center") %>%
set_all_borders(brdr(0.5, "solid", "black")) %>%
set_align(-1, 1, ".") %>%
#set_colspan(1, 2, 5) %>%
set_font_size(everywhere, everywhere, 8)
@
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{%
#the header is full of other fields/data, but I have confirmed it is unrelated to this issue.
}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<results=tex, include=TRUE, warning=FALSE, message=FALSE, echo=FALSE>>=
print_latex(huxTable)
@
\end{document}
I have confirmed that the text inside the huxtable does not have any special characters that caused it to error out. I also ensured that the .aux and .out files generated with the failed attempts were deleted, too. I have generated other PDFs with similar dependencies, and so I am stumped with what's going on here. Any ideas?