【问题标题】:Change the caption title of a figure in markdown在 Markdown 中更改图形的标题标题
【发布时间】:2017-08-19 10:05:43
【问题描述】:

我目前正在用德语写一份小型报告。因此,我希望将我的图形标题标题从 Figure 1 更改为 Abbildung 1 等等。

---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output:
  pdf_document: default
---


```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```

问题:如何更改 R Markdown 中的默认图形标题(不确定它是否实际上是这样调用的)?

【问题讨论】:

标签: r latex r-markdown markdown pandoc


【解决方案1】:

如果您使用英语以外的任何语言写作,您可以使用lang YAML 选项更改输出 pdf 的语言选项。这将覆盖所有标题、标签、目录等。

---
output: pdf_document
lang: de
---

```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```

其他语言选项包括fr(法语)、it(意大利语)等。有关详细信息,请参阅http://pandoc.org/MANUAL.html#language-variables。

【讨论】:

  • 如果未安装语言,您可能会收到 Package babel 错误。在 Debian/Ubuntu 上安装以“texlive-lang-”开头的软件包以安装新语言。
【解决方案2】:

按照this question 中的示例,您可以定义自己的tex 文件,您可以在其中更改图形标题默认值。

header.tex:

\usepackage{caption}
\captionsetup[figure]{name=Abbildung}

这是主要的 .Rmd 文件:

---
title: "Untitled"
author: "me"
date: '`r format(Sys.time(), "%d %B, %Y")`'
output: 
  pdf_document:
    includes:
      in_header: header.tex
---


```{r iris, fig.cap='Iris sepal lengths'}
hist(iris$Sepal.Length)
```

【讨论】:

  • @andrasz 如果您想修改 pdf 输出,您可能需要学习一些基本语法。有关更多信息,请参见 tex.stackexchange.com。
  • @RomanLuštrik:是否也可以用斜体打印 Abbildung 1?请注意,我也包括 1。因为 afaik apa6h 样式需要以下内容:图 1. 一些图形标题
  • 没关系。我找到了:只需使用此标题设置:\captionsetup[figure]{name=Figure,labelfont=it,labelsep = period}
  • @Jaynes01 请搜索答案或提出新问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-14
  • 1970-01-01
  • 2015-09-03
  • 2018-09-01
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多