r rticle 包在最近更新后停止编译

标签 r latex r-markdown xetex

以下代码在我今年夏天提交一篇文章时运行良好,但在最近更新后不再运行。 (R 版本 4.2.2(2022-10-31,R Studio 2022.12.0 Build 353,文章 0.24)。

---
title: "test"
author:
  - name: JB MD PhD
    email: jb@mcgill.ca
    affiliation: McGill University Health Center
    correspondingauthor: true
    footnote: 1
  - name: LN MSc
    email: 
    affiliation: McGill University Health Center
address:
  - code: McGill University Health Center
    address: McGill University Health Center, Centre for Health Outcomes Research (CORE), 5252 Boul. de Maisonneuve West Room 2B.37, Montreal,  QC, H4A 3S5
footnote:
  - code: 1
    text: "JMB is a research scholar supported by Les Fonds de Recherche Québec Santé"
abstract: |
  Background:  Atrial fibrillation is one of the most common arrhythmias but the optimal drug choice for a rate control strategy remains uncertain.   
      Methods:  This was a retrospective cohort claims database study. Patients with a new diagnosis of atrial fibrillation and a discharge date between 2011 and 2015 were included. The exposure variables of interest were a discharge prescription for beta blockers with and without digoxin. The average treatment effect for the composite of total mortality or a repeat cardiovascular (CV) hospitalization was the primary outcome. Sensitivity analyses with other treatment effect metrics were performed. Baseline covariate imbalance between the groups were adjusted using propensity score methods with inverse probability weighting.      
keywords: 
  - Atrial fibrillation
  - Amiodarone
  - Dronedarone
journal: "CJC Open submission"
date: "Original date 2022-12-19,  Updated - `r Sys.Date()`"
bibliography: references.bib
linenumbers: false
numbersections: true
#classoption: preprint, 3p, authoryear
csl: vancouver-brackets.csl
# csl: https://www.zotero.org/styles/elsevier-harvard
# geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm"
geometry: margin = 2cm
header-includes:
   - \usepackage{setspace}
   - \doublespacing
output: 
  rticles::elsevier_article:
    keep_tex: true
    citation_package: natbib
    latex_engine: xelatex
editor_options: 
  markdown: 
    wrap: 72
---

这给出了以下错误

processing file: Untitled.Rmd
  |......................................................................| 100%
   inline R code fragments


/Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/pandoc +RTS -K512m -RTS Untitled.knit.md --to latex --from markdown+tex_math_single_backslash-autolink_bare_uris --output Untitled.tex --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --template /Library/Frameworks/R.framework/Versions/4.2/Resources/library/rticles/rmarkdown/templates/elsevier/resources/template.tex --highlight-style tango --pdf-engine xelatex --natbib --include-in-header /var/folders/vz/g1j5pr8n7tg786zcwmv2dx8c0000gp/T//RtmpifKb24/rmarkdown-str8d9913e20bf4.html 
output file: Untitled.knit.md

! LaTeX Error: Command \gather already defined.
               Or name \end... illegal, see p.192 of the manual.

Error: LaTeX failed to compile Untitled.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Untitled.log for more info.
Execution halted

我查看了日志文件,但鉴于我对 LaTex 的理解水平较低,我看不出问题是什么

This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex 2022.12.21)  21 DEC 2022 22:48
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**Untitled.tex
(./Untitled.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2022-12-17> (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/elsarticle/elsarticle.cls
Document Class: elsarticle 2020/11/20, 3.3: Elsevier Ltd
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/l3kernel/expl3.sty
Package: expl3 2022-12-17 L3 programming layer (loader) 
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-xetex.def
File: l3backend-xetex.def 2022-10-26 L3 backend support: XeTeX
\g__graphics_track_int=\count181
\l__pdf_internal_box=\box51
\g__pdf_backend_object_int=\count182
\g__pdf_backend_annotation_int=\count183
\g__pdf_backend_link_int=\count184
)) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
Package: xparse 2022-12-17 L3 Experimental document command parser
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count185
)
\@bls=\dimen140
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2022/07/02 v1.4n Standard LaTeX file (size option)
)
\c@part=\count186
\c@section=\count187
\c@subsection=\count188
\c@subsubsection=\count189
\c@paragraph=\count190
\c@subparagraph=\count191
\c@figure=\count192
\c@table=\count193
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen141
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks16
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: xetex.def on input line 107.
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/graphics-def/xetex.def
File: xetex.def 2022/09/22 v5.0n Graphics/color driver for xetex
))
\Gin@req@height=\dimen142
\Gin@req@width=\dimen143
)
\c@tnote=\count194
\c@fnote=\count195
\c@cnote=\count196
\c@ead=\count197
\c@author=\count198
\@eadauthor=\toks17
\c@affn=\count199
\absbox=\box52
\elsarticlehighlightsbox=\box53
\elsarticlegrabsbox=\box54
\keybox=\box55
\Columnwidth=\dimen144
\space@left=\dimen145
\els@boxa=\box56
\els@boxb=\box57
\leftMargin=\dimen146
\@enLab=\toks18
\@sep=\skip50
\@@sep=\skip51
(./Untitled.spl) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/natbib/natbib.sty
Package: natbib 2010/09/13 8.31b (PWD, AO)
\bibhang=\skip52
\bibsep=\skip53
LaTeX Info: Redefining \cite on input line 694.
\c@NAT@ctr=\count266
)
\splwrite=\write3
\openout3 = `Untitled.spl'.

\appnamewidth=\dimen147
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/url/url.sty
\Urlmuskip=\muskip16
Package: url 2013/09/16  ver 3.4  Verb mode for urls, etc.
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/lineno/lineno.sty
Package: lineno 2022/07/30 line numbers on paragraphs v5.0
Invalid UTF-8 byte or sequence at line 297 replaced by U+FFFD.
\linenopenalty=\count267
\output=\toks19
\linenoprevgraf=\count268
\linenumbersep=\dimen148
\linenumberwidth=\dimen149
\c@linenumber=\count269
\c@pagewiselinenumber=\count270
\c@LN@truepage=\count271
\c@internallinenumber=\count272
\c@internallinenumbers=\count273
\quotelinenumbersep=\dimen150
\bframerule=\dimen151
\bframesep=\dimen152
\bframebox=\box58
\linenoamsmath@ams@eqpen=\count274
LaTeX Info: Redefining \\ on input line 3114.
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
LaTeX Font Info:    Trying to load font information for T1+lmr on input line 112.
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/lm/t1lmr.fd
File: t1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
)) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/lm/lmodern.sty
Package: lmodern 2015/05/01 v1.6.1 Latin Modern Fonts
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  OT1/cmr/m/n --> OT1/lmr/m/n on input line 22.
LaTeX Font Info:    Overwriting symbol font `letters' in version `normal'
(Font)                  OML/cmm/m/it --> OML/lmm/m/it on input line 23.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `normal'
(Font)                  OMS/cmsy/m/n --> OMS/lmsy/m/n on input line 24.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `normal'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 25.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 26.
LaTeX Font Info:    Overwriting symbol font `letters' in version `bold'
(Font)                  OML/cmm/b/it --> OML/lmm/b/it on input line 27.
LaTeX Font Info:    Overwriting symbol font `symbols' in version `bold'
(Font)                  OMS/cmsy/b/n --> OMS/lmsy/b/n on input line 28.
LaTeX Font Info:    Overwriting symbol font `largesymbols' in version `bold'
(Font)                  OMX/cmex/m/n --> OMX/lmex/m/n on input line 29.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `normal'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 31.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `normal'
(Font)                  OT1/cmss/m/n --> OT1/lmss/m/n on input line 32.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
(Font)                  OT1/cmr/m/it --> OT1/lmr/m/it on input line 33.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `normal'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 34.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `bold'
(Font)                  OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 35.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `bold'
(Font)                  OT1/cmss/bx/n --> OT1/lmss/bx/n on input line 36.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
(Font)                  OT1/cmr/bx/it --> OT1/lmr/bx/it on input line 37.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `bold'
(Font)                  OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 38.
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsfonts/amsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\@emptytoks=\toks20
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Redeclaring math symbol \hbar on input line 98.
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
)) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2022/04/08 v2.17n AMS math features
\@mathmargin=\skip54
For additional information on amsmath, use the `?' option.
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2021/08/26 v2.01 AMS text
(/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks21
\ex@=\dimen153
)) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen154
) (/Users/jay/Library/TinyTeX/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2022/04/08 v2.04 operator names
)
\inf@bad=\count275
LaTeX Info: Redefining \frac on input line 234.
\uproot@=\count276
\leftroot@=\count277
LaTeX Info: Redefining \overline on input line 399.
LaTeX Info: Redefining \colon on input line 410.
\classnum@=\count278
\DOTSCASE@=\count279
LaTeX Info: Redefining \ldots on input line 496.
LaTeX Info: Redefining \dots on input line 499.
LaTeX Info: Redefining \cdots on input line 620.
\Mathstrutbox@=\box59
\strutbox@=\box60
LaTeX Info: Redefining \big on input line 722.
LaTeX Info: Redefining \Big on input line 723.
LaTeX Info: Redefining \bigg on input line 724.
LaTeX Info: Redefining \Bigg on input line 725.
\big@size=\dimen155
LaTeX Font Info:    Redeclaring font encoding OML on input line 743.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 744.
\macc@depth=\count280
LaTeX Info: Redefining \bmod on input line 905.
LaTeX Info: Redefining \pmod on input line 910.
LaTeX Info: Redefining \smash on input line 940.
LaTeX Info: Redefining \relbar on input line 970.
LaTeX Info: Redefining \Relbar on input line 971.
\c@MaxMatrixCols=\count281
\dotsspace@=\muskip17
\c@parentequation=\count282
\dspbrk@lvl=\count283
\tag@help=\toks22
\row@=\count284
\column@=\count285
\maxfields@=\count286
\andhelp@=\toks23
\eqnshift@=\dimen156
\alignsep@=\dimen157
\tagshift@=\dimen158
\tagwidth@=\dimen159
\totwidth@=\dimen160
\lineht@=\dimen161
\@envbody=\toks24

! LaTeX Error: Command \gather already defined.
               Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1560 }
         
Here is how much of TeX's memory you used:
 3712 strings out of 478757
 54106 string characters out of 5849423
 1841979 words of memory out of 5000000
 23743 multiletter control sequences out of 15000+600000
 515285 words of font info for 34 fonts, out of 8000000 for 9000
 14 hyphenation exceptions out of 8191
 70i,0n,76p,233b,93s stack positions out of 10000i,1000n,20000p,200000b,200000s

No pages of output.

最佳答案

问题是当前版本的lineno包,需要在amsmath包之后加载(详见https://github.com/latex-lineno/lineno/issues/5)

已经为 rticles 实现了修复,你可以安装开发版本

remotes::install_github("rstudio/rticles")

(详见 https://github.com/rstudio/rticles/issues/513)

关于r rticle 包在最近更新后停止编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74889936/

相关文章:

用 R 读取二进制文件

r - 如何使用 magrittr::inset()?

r - 如何在 R Markdown 文档中指定默认书目 LaTeX/BibTeX 引用样式 "plain"或 "unsrt"?

latex - 将 beamer 幻灯片导出为 powerpoint 可编辑格式

r - 在 rmarkdown/knitr 中注释以防止 R 评估

r - 为什么Bookdown的index.Rmd中必须包含一些R代码?

R - 计算汇总列

r - 将 dplyr 链转换为函数

latex - LaTeX:引用,但不引用

r - 无法在 r markdown 中编译 tex