【问题标题】:In R Bookdown how to prevent/edit automatic table numbers在 R Bookdown 中如何防止/编辑自动表格编号
【发布时间】:2023-03-23 19:11:01
【问题描述】:

我想让我的表格显示带有章节号和表格号的标题。 SO post 说 bookdown 目前不支持该选项。所以我尝试用set_caption(caption = "Table 8.6") 之类的行直接将标题添加到我的弹性表中。当页面呈现时,它包括自动表格编号标题和我的自定义标题。

我知道如何禁用 pdf here 中的自动字幕,但不知道如何从 HTML 中删除它们。如何阻止 bookdown 分配自动表格标题?

另外,有没有人找到将章节编号添加到自动字幕的方法?

我的 YAML 标头在这里:

--- 
title: "Intro to Categorical Data Analysis 3rd Edition Notes"
author: "me"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
output:
  bookdown::gitbook: 
    config: 
      toc:
        collapse: false
    number_sections: false
    css: "style.css"
description: "Notes for Agresti's Introduction to Categorical Data Analysis"
---

【问题讨论】:

  • 如果您要渲染为 pdf,这是可能的,因为您可以为表格定义自定义标签。请参阅此处开始:stackoverflow.com/questions/47173279/…。添加 - \renewcommand{\tablename}{Table \arabic{section}.} 将在标签中包含部分名称。

标签: r r-markdown bookdown


【解决方案1】:

一种丑陋的做法是在表格前面添加文本,格式化为看起来像标题。例如:

```{r echo=FALSE}
htmltools::p("Table 8.6: This is a new caption.", style="text-align:center")
flextable::flextable(head(mtcars))
```

这不会出现在表格列表中(如果有的话),您需要从文本中手动链接到它,例如

```{r echo=FALSE}
htmltools::a(name="newtab")
htmltools::p("Table 8.6: This is a new caption.", style="text-align:center")
flextable::flextable(head(mtcars))
```

That was Table <a href="#newtab">8.6</a>.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 1970-01-01
    • 1970-01-01
    • 2016-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-09-16
    相关资源
    最近更新 更多