简体   繁体   中英

How to put floating image (wrapped around text) aligned to the right with a centered caption in RMarkdown?

So far this gives me the result I want.

<img align="right" src="images/cobre.png">

But I'd like to put a centered caption below the image. How can I do that?

HTML output can be styled via CSS. The styles can either be included directly in the text, or put into a separate CSS stylesheet.

Here is how to use inline CSS:

```{=html}
<style type="text/css">
  .figure {
    float: right;
    text-align: center;
  }
</style>
```

``` {r fig.cap = "Insert caption here", echo=FALSE}
knitr::include_graphics("images/cobre.png")
```

The advantage of using knitr::include_graphics over raw HTML is that include_graphics will also work for other output formats like word and pdf (although the figure won't be right aligned for these formats).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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