r - 交叉引用方程时,RStudio rticles knit to pdf book 失败
问题描述
准备一篇新的会议文章,我想使用 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)
使编织完成。然而,我 - 显然 - 失去了对等式的交叉引用。
在更新所有 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 包。
对于这种特定格式ieee_article
,使用amsmath
是有条件的 pandoc 变量。您需要将其添加到您的 yaml 标头中
with_amsmath: true
extra_dependencies
您可以使用格式输出中的参数为任何 rmarkdown 格式添加任何 Tex 包。
在这里它也可以这样工作
output:
bookdown::pdf_book:
base_format: rticles::ieee_article
extra_dependencies: amsmath
(但这里不建议遵守 IEEE 要求,因为模板包含用于 的配置amsmath
)
推荐阅读
- c++ - 如何在图像中找到正方形的坐标?
- java - Java 异常消息长度
- c++ - 如何在 C++ 中的变量中存储任何类型的函数?
- excel - 当我将它传递给变量时,日期更改格式(天变成月,月变成天)
- react-native - React-native TypeError:'nativeInterface.configure
- angular - 嵌套在主路由中时辅助路由不起作用
- c# - 有一个只有属性的基本接口是错误的吗?
- flutter - Navigator.pop(context) 在 Flutter 中完成堆栈中的最后一个 Activity 时显示黑屏
- node.js - 如何在 Opsworks (AWS) 中使用 Apollo 服务器包部署 Nodejs 应用程序
- unit-testing - 模拟 perl 反引号的返回码和输出