disney82231
disney82231

Reputation: 199

How can I center image in R markdown in knit word

I want to center image in R markdown in knit word.

I search result almost is CSSor HTML code.

But I need center image in word.

This my code

![avatar](C:/Users/user/Desktop/picture1.jpg){ width=5cm }

Thanks!

Upvotes: 4

Views: 5284

Answers (1)

Annesohie
Annesohie

Reputation: 61

I encountered the same problem and managed to solve it using a .docx file template that I declared at the beginning of the document:

---
output:
    word_document:
        reference_docx: template.docx
---

Just open your template file, select a figure, then press Ctrl + Shift + s to display the style panel for Microsoft Word. Change the alignment style of the text to "centered". Save your template.docx then knit your document as usual.

Upvotes: 6

Related Questions