通过rmarkdown交叉引用章节编号或名称

时间:2015-11-30 16:41:48

标签: latex knitr r-markdown pandoc cross-reference

尝试在Rmarkdown中找到一种方法,用于交叉引用自动编号的章节和/或通过其命名来执行类似

的操作
"As I explained hundred pages ago in \ref{ch:Chapter_Label}....."

然后生成的pdf文档有:

"As I explained hundred pages ago in Chapter 3....."

"As I explained hundred pages ago in <Chapter Name> ....."

我在考虑某种机制,如:

\chapter{My_Title} \label{ch:1}

然后在文本中的每个地方我使用\ref{ch:1}我会得到&#34; My_Title&#34;或者&#34;第1章&#34; (或者它得到的任何自动编号)由文本嵌入。

看来hyperref包不能正常使用Rmarkdown,或者我错过了什么。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

此问题已在bookdown中解决,并记录在Section 2.5中。基本上您使用语法\@ref(label),而label是您的章节标识符。