Centering image and text in R Markdown for a PDF report

Next Door Engineer picture Next Door Engineer · Jul 10, 2014 · Viewed 106.7k times · Source

I want to center an image and/or text using R Markdown and knit a PDF report out of it.

I have tried using:

->Text<-

->![](image1.jpg)<-

That does not do the trick! Any other way of getting this done?

Answer

Lincoln Mullen picture Lincoln Mullen · Jun 28, 2016

If you are centering the output of an R code chunk, e.g., a plot, then you can use the fig.align option in knitr.

```{r fig.align="center"}
plot(mtcars)
```