I am using rticle
package by RStudio to write an article in R using rmarkdown
package.
In the draft template there is an option
...
preamble: >
% Any extra latex you need in the preamble
output: rticles::rjournal_article
...
Where I suspect I can add lines like \usepackage{package_name}
or set a file name in which I load all desired Latex packages.
The first approach
I've tried to add one single package to preamble
section like this but have stacked on an error
---
title: Capitalized Title Here
author:
- name: Author One
affiliation: Affiliation
address:
- line 1
- line 2
email: author1@work
- name: Author Two
affiliation: Affiliation
address:
- line 1
- line 2
email: author2@work
abstract: >
An abstract of less than 150 words.
preamble: >
\usepackage{rotating}
% Any extra latex you need in the preamble
output: rticles::rjournal_article
---
\begin{sidewaystable}
\centering
\caption{Your caption here}
\begin{tabular}{ll}
First First & First Second\\
Second First & Second Second
\end{tabular}
\end{sidewaystable}
The first approach code end
BŁĄD: running 'texi2dvi' on 'RJwrapper.tex' failed
LaTeX errors:
D:\RTCGA.data\Untitled\Untitled.tex:11: LaTeX Error: Environment sidewaystable
undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
D:\RTCGA.data\Untitled\Untitled.tex:13: Package caption Error: \caption outside
float.
See the caption package documentation for explanation.
Type H <return> for immediate help
D:\RTCGA.data\Untitled\Untitled.tex:18: LaTeX Error: \begin{article} on input l
ine 20 ended by \end{sidewaystable}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
Dodatkowo: Warning message:
uruchomione polecenie '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texi2dvi.exe" --quiet --pdf "RJwrapper.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-32~1.0/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-32~1.0/share/texmf/bibtex/bst"' otrzymało status 1
Wykonywanie wstrzymane
I've seen the same preamble
- ignoring behavior in this issue https://github.com/rstudio/rticles/issues/11, but there was no response for that.
I've also tried to specify file named header.tex
that contains a line \usepackage{rotating}
in a last argument of a yaml like this but also there happend to be an error.
---
title: Capitalized Title Here
author:
- name: Author One
affiliation: Affiliation
address:
- line 1
- line 2
email: author1@work
- name: Author Two
affiliation: Affiliation
address:
- line 1
- line 2
email: author2@work
abstract: >
An abstract of less than 150 words.
preamble: >
\usepackage{rotating}
output:
rticles::rjournal_article:
includes:
in_header: header.tex
---
BŁĄD: running 'texi2dvi' on 'RJwrapper.tex' failed
LaTeX errors:
D:\RTCGA.data\rticle\rticle.tex:145: LaTeX Error: Environment sidewaystable und
efined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
D:\RTCGA.data\rticle\rticle.tex:147: Package caption Error: \caption outside fl
oat.
See the caption package documentation for explanation.
Type H <return> for immediate help
D:\RTCGA.data\rticle\rticle.tex:192: LaTeX Error: \begin{article} on input line
20 ended by \end{sidewaystable}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
Dodatkowo: Warning message:
uruchomione polecenie '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texi2dvi.exe" --quiet --pdf "RJwrapper.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-32~1.0/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-32~1.0/share/texmf/bibtex/bst"' otrzymało status 1
Wykonywanie wstrzymane
EDIT
When I specify yaml in a way it is intended to work for pdf_document
output
...
preamble: >
\usepackage{rotating}
output:
rticles::rjournal_article:
includes:
in_header: header.tex
...
I receive an error that
Error in (function () :
unused (includes = list(in_header = "header.tex"))
EDIT 2
Even for an empty new document I get the same error
---
title: Capitalized Title Here
author:
- name: Author One
affiliation: Affiliation
address:
- line 1
- line 2
email: author1@work
- name: Author Two
affiliation: Affiliation
address:
- line 1
- line 2
email: author2@work
abstract: >
An abstract of less than 150 words.
preamble: >
% Any extra latex you need in the preamble
output:
rticles::rjournal_article:
includes:
in_header: header.tex
---
Hello World
The header.tex
document (which is in the same directory as saved empty new file) contains only 1 line:
\usepackage{rotating}
I am aware of in_header
option in regular pdf_document
output format (see even my files with RMD extensions on github) but it looks like to does not work with rticles::rjournal_article
EDIT 3
I am interested in adding other latex package than those that are included automatically in the RJwrappter.tex
file which is generated after render of the .RMD file.
\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{RJournal}
\usepackage{amsmath,amssymb,array}
\usepackage{booktabs}
%% load any required packages here
\begin{document}
%% do not edit, for illustration only
\sectionhead{Contributed research article}
\volume{XX}
\volnumber{YY}
\year{20ZZ}
\month{AAAA}
\begin{article}
\input{rticle}
\end{article}
\end{document}
Anyone maybe knows how to solve this? I am using MiKTeX 2.9.