【发布时间】:2015-10-08 19:17:20
【问题描述】:
我正在使用 RStudio 的 rticle 包在 R 中使用 rmarkdown 包编写文章。
在草稿模板中有一个选项
...
preamble: >
% Any extra latex you need in the preamble
output: rticles::rjournal_article
...
我怀疑我可以添加像\usepackage{package_name} 这样的行,或者设置一个文件名来加载所有需要的 Latex 包。
第一种方法
我尝试像这样将一个包添加到preamble 部分,但出现错误
---
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}
第一种方法代码结束
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
我也看到了相同的 preamble - 忽略此问题中的行为 https://github.com/rstudio/rticles/issues/11,但没有对此作出回应。
我还尝试指定名为header.tex 的文件,该文件在这样的yaml 的最后一个参数中包含\usepackage{rotating} 行,但也发生了错误。
---
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
编辑
当我以某种方式指定 yaml 时,它适用于 pdf_document 输出
...
preamble: >
\usepackage{rotating}
output:
rticles::rjournal_article:
includes:
in_header: header.tex
...
我收到一个错误
Error in (function () :
unused (includes = list(in_header = "header.tex"))
编辑 2
即使对于一个空的新文档,我也会遇到同样的错误
---
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
header.tex 文档(与保存的新空文件位于同一目录中)仅包含 1 行:
\usepackage{rotating}
我知道in_header 选项采用常规pdf_document 输出格式(甚至可以使用RMD extensions on github 查看我的文件),但它看起来不适用于rticles::rjournal_article
编辑 3
我有兴趣添加其他乳胶包,而不是自动包含在 .RMD 文件渲染后生成的 RJwrappter.tex 文件中的那些。
\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}
可能有人知道如何解决这个问题吗? 我正在使用 MiKTeX 2.9。
【问题讨论】:
-
你有什么版本的 (La)TeX 系统?一个基本的 MickTeX?
-
MiKTeX 2.9 - 我已经编辑了我的问题
标签: r rstudio r-markdown