【发布时间】:2022-01-08 01:13:09
【问题描述】:
我正在通过bookdown 制作一本书。
我知道可以通过添加属性{.unlisted .unnumbered} 来省略目录中的标题,如Section 4.18 of the R Markdown Cookbook 所示。
但是,如何将任意内容添加到目录中?
如果我只需要为 PDF 输出添加它,我可以使用(例如)LaTeX 命令\addcontentsline,但我也需要在 HTML 内容侧边栏中显示它。
例如,如果您从 RStudio 设置一个新的默认 bookdown 项目,则它包含文件 01-intro.Rmd。
前几行是
# Introduction {#intro}
You can label chapter and section titles using `{#label}` after them, e.g., we can reference Chapter \@ref(intro). If you do not manually label them, there will be automatic labels anyway, e.g., Chapter \@ref(methods).
Figures and tables with captions will be placed in `figure` and `table` environments, respectively.
我需要能够创建添加到目录中的任意divs,如下所示:
# Introduction {#intro}
You can label chapter and section titles using `{#label}` after them, e.g., we can reference Chapter \@ref(intro). If you do not manually label them, there will be automatic labels anyway, e.g., Chapter \@ref(methods).
::: {#arbitrary-header <some other attribute?>}
Figures and tables with captions will be placed in `figure` and `table` environments, respectively.
:::
这将添加句子“带有标题的图形和表格将分别放置在figure 和table 环境中。”在 LaTeX 目录和 HTML 输出的侧边栏中。
这个问题的背景是我需要在另一个自定义div 中放置一个标题,该标题对颜色框中的内容进行格式化以使其脱颖而出。
否则,我当然可以在上面的句子之前通过##添加另一个标题。
【问题讨论】:
标签: r r-markdown pandoc bookdown