Stop "sanitizing" characters in the header - includes

I am creating a document in which some tables have some columns that benefit from this solution to force alignment of records with wrapped text.

To implement this solution, we include the following in our preamble:

\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1\linewidth}}

To implement this with help knitr, I tried:

---
output:
  pdf_document:
    keep_tex: yes
header-includes:
  - \usepackage{array}
  - \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1\linewidth}}
---

But this is not an error:

! LaTeX error: missing \ begin {document}.

...

l.83 \ newcolumntype {R} {[} 1

pandoc: error creating pdf

Error: pandoc document conversion failed with error 43

Studying the .tex output, it is clear what went wrong:

\usepackage{array}
\newcolumntype{R}{[}1{]}\{\textgreater{}\{\raggedleft\arraybackslash\}p\{\#1\linewidth\}\}

knitr > \textgreater{}, { \{, }' \}, [ {[}, ] {]} # \#. , , .

, , ( YAML) - \ , \ " ".

knitr ?

+6
1

( ) includes (. ). , LaTeX LaTeX. header-includes YAML, , . Rmd HTML.

BTW, knitr YAML. Pandoc .

+2

Source: https://habr.com/ru/post/1016062/


All Articles