Centering image and text in R Markdown for a PDF report

后端 未结 9 1678
情深已故
情深已故 2020-12-28 12:10

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)<-         


        
9条回答
  •  我在风中等你
    2020-12-28 12:23

    I had the same question. I have tried all solutions provided above and none of them worked... But I have found a solution that works for me, and hopefully for others too.

    ![your image caption](image.png)

    This code will center both the image and the caption. It is essential that you leave lines between

    , the image code, and
    , otherwise the image will be centered but the caption will disappear.

    If you want your image to have a clickable link, you can embed things like

    [![your image caption](image.png)](www.link_to_image.com)
    

    However, the caption will no longer appear.

    So if you want a clickable caption you will have to do it in two steps:

    ![](image.png) [your image caption](www.link_to_image.com)

    Same here, make sure there are empty lines in between each command ones. If you want both the image and the caption to be clickable, then combine the middle and the last codes above. I hope this helps a bit.

提交回复
热议问题