I am running a process where I automatically produce a report. It has worked up until a point. But now knitr::opts_chunk$set(result='asis')
does not work when I cat
LaTeX code into the document. It replaces the \\
with \\textbackslash{}
when I knit
the document. Even though if you run the cat
command on its own, it produces the correct LaTeX
code:
---
title: "Untitled"
date: "October 15, 2017"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, comment = NA, background = NA, results='asis')
```
```{r}
cat("
\\begin{tabular*}{1\\textwidth}{c c}
\\parbox[c]{0.4\\linewidth}{
{\\HUGE{\\textcolor{blue}{\\textbf{\\uppercase{Headline}}} }}\\\\
\\Large{{\\textsc{Example}}}\\\\
}&
\\parbox{0.25\\textwidth}{
\\icontext{MapMarker}{12}{Global}\\\\
\\icontext{MobilePhone}{12}{999 666 23}\\\\
\\icontext{Send}{12}{someemail@gmail.com}\\\\
}
\\end{tabular*}")
```
The error being produced:
I have tried using knitr::asis_output()
, but it results in the same error
The Tex
being produced is the following:
\begin{document}
\maketitle
\textbackslash{}begin\{tabular\emph{\}\{1\textwidth\}\{c c\}
\parbox[c]{0.4\linewidth}{
{\HUGE{\textcolor{blue}{\textbf{\uppercase{Headline}}} }}\\
\Large{{\textsc{Example}}}\\
}\& \parbox{0.25\textwidth}{
\icontext{MapMarker}{12}{Glogab}\\
\icontext{MobilePhone}{12}{999 666 23}\\
\icontext{Send}{12}{someemail@gmail.com}\\
} \textbackslash{}end\{tabular}\}
\end{document}
There is finally a solution to these issues:
knitr::raw_latex("here all your tex content")
instead of cat() + results='asis'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.