Centering image in RMarkdown for Word export

白昼怎懂夜的黑 提交于 2019-12-12 05:54:11

问题


I would like to include an image in a RMarkdown document and have it centered in the output Word.

Is this possible?

As suggested here, I have used:

<center>![My caption](myImage.png)</center>

without success.


回答1:


This is not fully satisfactory, but what I did in the end was to add a macro in my styles document:

Sub Center_All_Images()
'
' Center_All_Images Macro
'
'
For Each oILShp In ActiveDocument.InlineShapes
    oILShp.Select
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Next

End Sub

I still need to run the macro manually. I wish it was run automatically when the document is created from the template.



来源:https://stackoverflow.com/questions/42228002/centering-image-in-rmarkdown-for-word-export

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!