设置Rmarkdown的YAML标题中数字的标题字体大小

设置Rmarkdown的YAML标题中数字的标题字体大小,r,yaml,rstudio,knitr,r-markdown,R,Yaml,Rstudio,Knitr,R Markdown,我正在使用Rstudios markdown编写一份报告,我想使用latex将其编译为pdf以及html 是否有可能调整中包含的图像的标题字体大小![说明](figure.jpg)environment?目前,html中的标题看起来与文本的其余部分类似。您可以使用css控制这一点。例如: <style type="text/css"> .caption { font-size: x-small; } </style> ![caption](figure.jpg)

我正在使用Rstudios markdown编写一份报告,我想使用latex将其编译为pdf以及html


是否有可能调整
中包含的图像的标题字体大小![说明](figure.jpg)
environment?目前,html中的标题看起来与文本的其余部分类似。

您可以使用css控制这一点。例如:

<style type="text/css">
.caption {
    font-size: x-small;
}
</style>

![caption](figure.jpg)

.标题{
字体大小:x-small;
}
![说明](图.jpg)

有关可用的
字体大小
选项,请参见css指南。

这个答案显然已经被接受,但为了完整起见,我添加了问题的PDF部分

如果您希望更改PDF文档的标题字体大小,我建议您通过以下两种方法之一使用
caption
软件包:

标题包括-选项:

---
title: "Title"
author: "Jorge Luis Borges"
header-includes:
  - \usepackage[font={small}]{caption}
output:
  pdf_document
---
---
title: "Title"
author: "Jorge Luis Borges"
output:
  pdf_document:
    includes:
      in_header: style.tex
---
这里的重点是
font={}

在标题中-选项:

---
title: "Title"
author: "Jorge Luis Borges"
header-includes:
  - \usepackage[font={small}]{caption}
output:
  pdf_document
---
---
title: "Title"
author: "Jorge Luis Borges"
output:
  pdf_document:
    includes:
      in_header: style.tex
---
其中
style.tex
包含在包含.Rmd文件的同一目录中。
style.tex
文件需要包含
\usepackage[font={small}]{caption}

与前面一样,这里的重点是
font={}


使用
标题
软件包,您可以获得大量定制选项,仅举几个例子,请参见以下内容:

  • scriptsize
    =非常小的大小
  • footnotesize
    =通常用于脚注的大小
  • small
    =小尺寸
  • large
    =大尺寸
  • it
    =斜体
  • bf
    =粗体
如需详细参考,请访问

此外,此处还交叉引用了TexSE网站上的文章:


多亏了@Johnny之前的评论,我想对我的pdf报告中的数字标题做更多的修改。我希望标题如下所示:

图1。这是一张解释生产率的图表

要获得此信息,请添加YAML:

---
title: "Title"
author: "Author"
header-includes:
  - \usepackage[font={small,it}, labelfont={bf}]{caption}
output:
  pdf_document
---