Latex Rmarkdown:在pdf或word输出中将Figure X标签修改为Figure SX
我试图使用Rmarkdown自动标记图形的标题,但我不想计算Latex Rmarkdown:在pdf或word输出中将Figure X标签修改为Figure SX,latex,r-markdown,knitr,Latex,R Markdown,Knitr,我试图使用Rmarkdown自动标记图形的标题,但我不想计算图1,而是希望它是图S1,即只在那里添加s。这表明使用pdf输出是不可能的。好的,我可以使用.doc文件,但我的图形标题仍然没有打印出来?我想知道会出什么问题 R降价的最低示例: --- title: Supporting Information subtitle: "Iron(I) etc" author: "Some people here" abstract: "Added
图1
,而是希望它是图S1
,即只在那里添加s
。这表明使用pdf输出是不可能的。好的,我可以使用.doc文件,但我的图形标题仍然没有打印出来?我想知道会出什么问题
R降价的最低示例:
---
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:
word_document:
fig_caption: yes
---
```{r, include=F}
library(captioner)
figS<- captioner(prefix = "Figure S", auto_space = TRUE, levels = 1, type = NULL, infix = ".")
figS("Figure S1", "Single-crystal X-ray structure of some text (1)", display=FALSE)
```
```{r Xray, fig.cap=figS("This is my figure description"), echo=FALSE}
plot(cars)
```
---
标题:支持信息
副标题:“铁(I)等”
作者:“这里有些人”
摘要:“在此处添加地址,因为SI中没有摘要”
输出:
word_文件:
图片说明:是的
---
```{r,include=F}
图书馆(船长)
图您可以在YAML部分的标题includes:
下使用一些LaTeX命令,如下所示:
---
title: "Untitled"
output: pdf_document
header-includes:
- \renewcommand{\figurename}{Figure S}
- \makeatletter
- \def\fnum@figure{\figurename\thefigure}
- \makeatother
---
```{r, fig.cap="This is my figure description", fig.height=3}
plot(pressure)
```
```{r, fig.cap="Another figure description", fig.height=3}
plot(iris$Sepal.Length, iris$Petal.Width)
```
(R代码块中的参数fig.height
是不必要的;我使用它只是为了在同一页中获得两个绘图并截图)您可以在标题下使用一些LaTeX命令,包括:
在YAML部分,如下所示:
---
title: "Untitled"
output: pdf_document
header-includes:
- \renewcommand{\figurename}{Figure S}
- \makeatletter
- \def\fnum@figure{\figurename\thefigure}
- \makeatother
---
```{r, fig.cap="This is my figure description", fig.height=3}
plot(pressure)
```
```{r, fig.cap="Another figure description", fig.height=3}
plot(iris$Sepal.Length, iris$Petal.Width)
```
(R代码块中的参数<代码>图高度> /代码>不是必需的;我只使用它获得同一页中的两个图并使用截图)
我编辑了我的答案,以删除<代码> s>代码>和空白之间的空白。所以,代替<代码>图S 1 现在我们有了<代码>图S1。我编辑了我的答案,去掉了<代码> s>代码>和空白之间的空白。因此,现在我们有了图S1
而不是图S1
非常感谢@canovajsm!好的、简单的解决方案。我已经为此挣扎了好几天了!拯救了我的一天:)非常感谢@canovajsm!好的、简单的解决方案。我已经为此挣扎了好几天了!救了我一天:)