gpt4 book ai didi

r - 如何将 latex 包从 R 中的文章包添加到 R 期刊模板

转载 作者:行者123 更新时间:2023-12-04 12:32:06 25 4
gpt4 key购买 nike

我正在使用 rticle RStudio 打包使用 rmarkdown 在 R 中编写文章包裹。
在草稿模板中有一个选项

...
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 的文件包含一行 \usepackage{rotating}在像这样的 yaml 的最后一个参数中,但碰巧出现了错误。
---
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

我有兴趣添加其他胶乳包,而不是自动包含在 RJwrappter.tex 中的胶乳包。 .RMD 文件渲染后生成的文件。
\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。

最佳答案

不,那是错误的。在 YAML header 中声明您想要一个包含。

rmarkdown reference :

---
title: "Habits"
output:
pdf_document:
includes:
in_header: header.tex
before_body: doc_prefix.tex
after_body: doc_suffix.tex
---

我用过 header.tex为此目的在几个文件中。

编辑:当您似乎迷失在树林中时,这里是一个从默认 useR 抽象模板开始的简单示例:
---
title: "Title of Your Submission"
author:
- name: FirstNameA LastNameA
keywords: First, Second, ... up to 5 keywords
output:
pdf_document:
includes:
in_header: marcin_header.tex
---

Content to be added here.

我将它与名为 marcin_header.tex 的最简单的标题结合起来(放置在同一目录中)并且只包含
\usepackage{booktabs}

为我工作。

编辑 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
\usepackage{booktabs}
output: rticles::rjournal_article
---

## Introduction

Rest omitted.

关于r - 如何将 latex 包从 R 中的文章包添加到 R 期刊模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31503418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com