【问题标题】:How to reference sections in rmarkdown with pdf output如何使用 pdf 输出引用 rmarkdown 中的部分
【发布时间】:2020-06-28 16:57:13
【问题描述】:

请在输出为 pdf 时如何使用 \label\ref 链接 rmarkdown 中的部分。我尝试了https://bookdown.org/yihui/bookdown/cross-references.htmlhttps://bookdown.org/yihui/rmarkdown-cookbook/cross-ref.html 的各种排列,但没有成功。

一次尝试

---
title: "Untitled"
output: pdf_document
---
See Section \@ref(sec:label).

# Section One  (\#sec:label)

给了

【问题讨论】:

    标签: r latex r-markdown


    【解决方案1】:

    您可以按如下方式修改您的文档:

    ---
    title: "Untitled 1"
    date: "28 de junio de 2020"
    link-citations: yes
    output:
      pdf_document:
        includes:
          keep_tex: yes
        number_sections: yes
        toc_depth: 2
    ---
    
    \section{This is the first section} \label{section1}
    
    You will be some in \ref{section1}
    

    然后你可以看到数字是如何出现的,只需将\label{}添加到您的部分并使用\ref{}进行调用。另外,我建议使用\section{},并修改YAML。希望这能有所帮助。

    【讨论】:

    • 非常感谢。因此,似乎是 number_sections: yes 选项具有允许标准乳胶引用工作的魔力
    猜你喜欢
    • 2020-08-25
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-18
    • 2017-01-09
    • 2018-03-23
    • 2022-12-28
    相关资源
    最近更新 更多