gpt4 book ai didi

r - knitr/pandoc : Cross-references to sections, 小节

转载 作者:行者123 更新时间:2023-12-01 10:34:39 25 4
gpt4 key购买 nike

[环境:Win 7,R 3.2.3,RStudio,最新]

我有一个 knitr .Rmd 文档作为文章,我想在其中标记部分,如

## Mean differences {#sec:meandiff}

然后引用该部分,使其在文本中显示为“在第 3.2 节中,我讨论了......”我可以看到使用 bookdown 可以实现类似的事情,并且在 pandoc 文档中提到了“内部链接”,http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#links ,但我无法让它发挥作用。我记得在与 RStudio 相关的文档或博客中看到过有关此内容的内容,但现在找不到了。

我尝试了很多东西

In Section (@#sec:meandiff) ...
In Section (@sec:meandiff) ...
In Section (#sec:meandiff) ...

但是,生成的 PDF 将其呈现为

In Section (@#sec:meandiff) ...
In Section (???) ..., with: pandoc-citeproc: reference sec:meandiff not found
In Section (#sec:meandiff) ...

我使用的 YAML header 是:

---
title: "My title"
author: Moi Meme
date: '`r format(Sys.time(), "%B %d, %Y")`'
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
includes:
in_header: mystyles.tex

没有太多这样的交叉引用,我无法手动完成它们,但如果我遗漏了一些关于语法的东西,让它们由 pandoc 完成会更容易。

最佳答案

啊,因为我正在生成 LaTeX,所以我可以用它来做交叉引用,而 \label 是由 markdown/pandoc 生成的

在序言中,

\newcommand*{\secref}[1]{Section~\ref{#1}}

然后在正文中

In \secref{sec:mean-diff} ...
...

## Mean differences {#sec:meandiff}

关于r - knitr/pandoc : Cross-references to sections, 小节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37870033/

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