渲染为 PDF 时,如何更改 R 中的四开表格中的行距?

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

我正在创建一本四开本书籍,我计划将其渲染为 PDF。文档类别为

scrbook
。在本书中,我想在文本中保留双倍行距,但在表格中保留单倍行距。我怎样才能做到这一点? 项目的_quarto.yml文件中的YAML规范如下:

project:
  type: book

book:
  title: "Book Title"
  author: "Eva"
  date: today
  chapters:
    - index.qmd
format:
  pdf:
    number-sections: true
    number-depth: 3
    documentclass: scrbook
    pdf-engine: lualatex
    geometry:
      - top=1in
      - bottom=1in
      - left=1in
      - right=1in
      - heightrounded
    linestretch: 2
    keep-md: true
    keep-tex: true

linestretch: 2
确保输出中有双倍间距(审阅者需要在书籍的打印输出中写注释)。但它也会影响从代码块生成的表。因此,我尝试将
linestretch:1
应用于代码块,但没有效果。

{r}
#| echo: false
#| label: tbl-cars
#| tbl-cap: "Details of Cars"
#| linestretch: 1
head(mtcars) |> knitr::kable()

即使我想将其保持为单倍行距,渲染的 PDF 在生成的表格中仍然具有 2 行距。这可以吗?如果可能的话,我该怎么做?

r latex quarto
1个回答
0
投票

我会尝试使用

kableExtra::kbl()
并在文档中的某处添加
\renewcommand{\arraystretch}{1}

\renewcommand{\arraystretch}{1}

```{r}
#| echo: false
#| label: tbl-cars
#| tbl-cap: "Details of Cars"
head(mtcars) |> kableExtra::kbl(booktabs = TRUE)
```
© www.soinside.com 2019 - 2024. All rights reserved.