使用四开中的表格列表和图形列表来引用代码块的输出

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

我想生成一个 PDF 论文文档,在四开文档的开头有一个表格列表和一个图形列表。这似乎不是一个简单的方法。我看到了这篇post,它提供了一些指导。

我的问题: 有没有办法自动将从代码块生成的表(来自 gt、gtsummary 或 flextable)添加到表列表中?关于情节同样的问题。

latex r-markdown quarto flextable gt
1个回答
0
投票

我们来总结一下。要在文档中包含表格列表/图形列表,我们必须在标题的格式部分添加

lof: true
和/或
lot: true
。它对应于 LaTeX
\listoftables
\listoffigures
宏。为了将条目包含在列表中,表格/图形必须有标题。对于那些使用 r/python 生成的表/图,我们可以使用块的
fig-cap
tbl-cap
选项。

---
title: "Untitled"
format: 
  pdf:
    lof: true
    lot: true
---

## Quarto

```{r}
plot(1)
```

```{r}
#| fig-cap: Figure caption

plot(2)
```

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

plot(3, pch = 3)
```

And the same for tables

```{r}
#| echo: false
#| tbl-cap: Table caption

cars |>
  head() |>
  kableExtra::kbl() |> 
  kableExtra::kable_classic_2()
```

产生所需的输出:

© www.soinside.com 2019 - 2024. All rights reserved.