在四开本的附录编号中添加字母

问题描述 投票:0回答:1

有没有办法重新开始Quarto文档附录中的章节编号、图形编号和表格编号?我需要编织成 PDF。在下面的 reprex 中,我希望部分标题看起来像...

  • 第 1 节
  • 第 2 节
  • 一个。第一附录
  • A.1 更多结果
  • A.2 更多结果
---
title: "Test"
format: 
  pdf:
    number-sections: true
    number-depth: 4
editor: visual
---

# Section 1

Text

# Section 2

Text

# First Appendix {.appendix}

## More Results

Text

## Even More Results

Text

这是输出的样子:

r pdf latex quarto
1个回答
1
投票

在附录部分之前重新启动部分计数器并更改数字格式。对图形和表格也做同样的事情!

---
title: "Test"
format: 
  pdf:
    number-sections: true
    number-depth: 4
editor: visual
---

# Section 1

Text

# Section 2

Text

See @fig-plot

See @fig-another-plot

see @tbl-my-tab

\setcounter{section}{0}
\renewcommand{\thesection}{\Alph{section}}

\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}

\setcounter{figure}{0}
\renewcommand{\thefigure}{A\arabic{figure}}

# First Appendix {.appendix}

## More Results

Text

## Even More Results

Text

## Plot

\newpage

```{r}
#| label: fig-plot
#| fig-cap: A plot

plot(1:10)
```

\newpage

```{r}
#| label: fig-another-plot
#| fig-cap: Another plot

plot(rnorm(100))

```

## Table

\newpage

```{r}
#| label: tbl-my-tab
#| tbl-cap: A table

knitr::kable(head(mtcars))
```

另外,您可以使用乳胶包

chngcntr
对附录中的图形和表格进行更改计数器。

---
title: "Test"
format: 
  pdf:
    number-sections: true
    number-depth: 4
    include-in-header:
      text: |
        \usepackage{chngcntr}
editor: visual

---

# Section 1

Text

# Section 2

Text

See @fig-plot

See @fig-another-plot

see @tbl-my-tab

\setcounter{section}{0}
\renewcommand{\thesection}{\Alph{section}}


# First Appendix {.appendix}

\counterwithin{figure}{section}

\counterwithin{table}{section}


## More Results

Text

## Even More Results

Text

\newpage


## Plot

```{r}
#| label: fig-plot
#| fig-cap: A plot

plot(1:10)
```

\newpage

```{r}
#| label: fig-another-plot
#| fig-cap: Another plot

plot(rnorm(100))

```

\newpage

## Table

```{r}
#| label: tbl-my-tab
#| tbl-cap: A table

knitr::kable(head(mtcars))
```

如果您希望表格和图形的编号嵌套在附录小节中,请改用,

\counterwithin{figure}{subsection}
\counterwithin{table}{subsection}
© www.soinside.com 2019 - 2024. All rights reserved.