简体   繁体   English

如何在 R markdown 中居中图形标题

[英]How to center figure caption in R markdown

I am using knitR to import my image into my rmarkdown and I wrote captions using fig.cap.我正在使用 knitR 将我的图像导入我的 rmarkdown 并使用 fig.cap 编写标题。 My image is already centered but my caption is always left-aligned.我的图像已经居中,但我的标题始终是左对齐的。 Is there anyway to also align my caption under my image?无论如何也可以在我的图像下方对齐我的标题?

```{r, echo=FALSE, fig.align='center', fig.cap="tmap with multiple data classification methods and classes"}
knitr::include_graphics("tmap01.png")

编织图像

Inspecting the document shows that the caption is in a p tag with class caption , and there's no CSS associated to this class. So you can set some CSS properties to the caption class, by adding this CSS chunk (eg at the beginning of the document):检查文档显示标题在带有 class captionp标签中,并且没有与此 class 相关联的 CSS。因此您可以通过在 chunkegg3 的开头添加此 883998889171888888888112195188 属性来设置caption ):

```{css}
.caption {
  margin: auto;
  text-align: center;
}
```

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM