【问题标题】:R Markdown pdf_document2 PDF figure and table numbers by sectionR Markdown pdf_document2 PDF图形和表格编号按部分
【发布时间】:2019-05-20 16:29:33
【问题描述】:

我想在 R Markdown 中生成一个pdf_document2 PDF 文档,其中的表格和图形根据它们的节号进行标记。例如,第 2 节中的第一个图是图 2.1。我可以用html_document2 做到这一点,但不能用pdf_document2

请参阅下面的代码,了解我编写的代码。现在,代码生成连续的图形编号(图 1、2、3、4),而不是图 1.1、1.2、2.1、2.2。


title: "Testing Section Numbers"
author: "Authors"
date: "January 2019"
output:
  bookdown::pdf_document2:
    fig_caption: yes
    latex_engine: xelatex
    number_sections: true
    toc: yes
    toc_depth: 2
editor_options:
  chunk_output_type: console
link-citations: yes
linkcolor: blue
subparagraph: yes
citecolor: blue
urlcolor: blue
---

# R Markdown

```{r pressure1, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

```{r pressure2, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

# Including Plots

You can also embed plots, for example:

```{r pressure3, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

```{r pressure4, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

【问题讨论】:

    标签: latex r-markdown bookdown


    【解决方案1】:

    笨拙的解决方案是在标题中添加一些 LaTeX 命令:

    header-includes:
      \let\counterwithout\relax
      \let\counterwithin\relax
      \usepackage{chngcntr}
      \counterwithin{figure}{section}
    

    【讨论】:

    • 对于如何使用 PDF 输出执行此操作是否有任何更新,这不是“kludgey”?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多