gpt4 book ai didi

r - 如何更改 bookdown 中的图形标题格式

转载 作者:行者123 更新时间:2023-12-03 20:51:08 38 4
gpt4 key购买 nike

使用 bookdown(单个文档)时,数字自动编号为:

Figure 1 Text of figure caption.


在化学中,惯例是将主要图形标记为:

Figure 1. Text of figure caption.


对于支持信息文件:

Figure S1. Text of figure caption.


同样在我们需要的文本中的图引用中:

...as can be seen in Figure 1, ...


所以引用文本不应该是粗体。
问题
我怎样才能让 bookdown(或 rmarkdown)产生像这样的图形和表格标题:“ 图 S1。 一些文本。”和“ 表 S1。 一些文本。” ?
我需要这个在 微软字 格式。
示例/尝试的解决方案
到目前为止,我尝试将 _bookdown.yml 文档修改如下:
language:
label:
fig: "**Figure S**"
tab: "**Table S**"
这给出: 图S 1 一些文字......以及使用时的内联引用:
Figure S\@ref(fig:Xray)
是图S1,没关系。
这是一个最小的例子:
---
title: Supporting Information
subtitle: "Iron(I) etc"
author: "Some people here"
abstract: "Added the addresses here since there is no abstract in the SI"
output:
bookdown::word_document2:
fig_caption: yes
toc: yes
toc_depth: 1
---

## Reaction of etc.
Some text (Figure S\@ref(fig:Xray)). Some text followed by a figure:

```{r Xray, fig.cap="Single-crystal X-ray structure of some text", echo=FALSE}
plot(cars)
```
Some text etc. followed by a table:

```{r DipUVvis, echo=FALSE, tab.cap="Table caption"}
df<-data.frame(Entry=c('AMM 51$3^a$','AMM 52^*a*^'),
Precat=c('[FeBr~2~(dpbz)~2~] (4.00)','[FeBr~2~(dpbz)~2~]
(2.00)'))

kable(head(df), format = "markdown")
```
上面的代码产生 图S 图标题中的 1 但不是 图 S1。 (请注意,这一切都是粗体,最后是句号)。

最佳答案

自问题发布以来已经有一段时间了,但是要将数字的编号从“图 1”更改为“图 S1”,您可以使用以下命令:

- \usepackage{caption}                            
- \DeclareCaptionLabelFormat{Sformat}{#1 S#2}
- \captionsetup[table]{labelformat=Sformat}
- \captionsetup[figure]{labelformat=Sformat}

关于r - 如何更改 bookdown 中的图形标题格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51945079/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com