在 R Bookdown 中如何 prevent/edit 自动 table 数字

In R Bookdown how to prevent/edit automatic table numbers

我想让我的 tables 显示带有显示章节编号和 table 编号的标题。 SO post 说 bookdown 当前不支持该选项。所以我尝试将标题直接添加到我的 flextable 中,其中一行像 set_caption(caption = "Table 8.6")。当页面呈现时,它包括自动 table 数字标题和我的自定义标题。

我看到了如何在 pdf 中禁用自动字幕,但不知道如何从 HTML 中删除它们。如何阻止 bookdown 分配自动 table 字幕?

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

我的 YAML header 在这里:

--- 
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"
---

一个丑陋的方法是在 table 之前添加文本,格式看起来像标题。例如:

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

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

```{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>.