簡體   English   中英

RStudio 編織到 pdf 書籍的文章在交叉引用方程時失敗

[英]RStudio rticles knit to pdf book fails when cross-referencing equations

准備一篇新的會議文章,我想使用 rticles 並利用 bookdown 的交叉引用功能。 這最初在使用標准方程和交叉引用示例時失敗(例如,比較https://bookdown.org/yihui/bookdown/cross-references.html )。

原始錯誤消息如下:

! Undefined control sequence.
l.430 See equation \eqref
                         {eq:linear} for more insights. 

消除交叉引用指針\@ref(eq:linear)使 knit 完成。 然而,我 - 顯然 - 失去了對等式的交叉引用。

在更新所有 R 包之后,Rmd 被編織而不會引發錯誤。 但是,不會自動插入交叉引用,而是打印\@ref(eq:linear)

我認為這個問題與在編織過程中如何處理這些引用(又名控制序列)有關。 :( 我不知道如何處理這個。

這個 SO-question Cross-reference in rticles提供了指向官方文檔的指針,該示例從中被接管。

感謝您讓我了解如何格式化方程式參考。

---
title: "rticles fails knitting equation references"
keywords: ["keyword 1", "keyword 2"]
abstract: |
  The abstract goes here.
  On multiple lines eventually.
## hook up rticles as base format with bookdown for referencing, etc
output:
  bookdown::pdf_book:
    base_format: rticles::ieee_article
---

Introduction
=============

To add math, I do the following

See equation \@ref(eq:linear) for more insights.

\begin{equation}
a + bx = c  (\#eq:linear)
\end{equation}

More cool text.

使用\eqref引用方程需要amsmath Tex package。

對於這種特定格式ieee_article , amsmath 的使用amsmath變量。 您需要將此添加到您的 yaml header

with_amsmath: true

您可以使用格式為 output 的extra_dependencies參數為任何 rmarkdown 格式添加任何 Tex 包。

在這里它也可以這樣工作

output:
  bookdown::pdf_book:
    base_format: rticles::ieee_article
    extra_dependencies: amsmath

(但這里不建議遵守 IEEE 要求,因為模板包含amsmath的配置)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM