1
votes

I cannot figure out how to center a figure caption in RMarkdown with MS Word output. I'm pointing the Markdown document to a reference Word template, and the figure captions in the template are correct. The problem is that RMarkdown doesn't know that the captions are supposed to be captions. It's treating them as just normal text.

---
title: "Title"
author: "Author"
date: "June 5, 2020"
output:
  bookdown::word_document2:
    fig_caption: yes
    reference_docx: Template.docx
subsubtitle: Test
subtitle: Subtitle
---

# My Plots

Sample Plot

{r pressure,fig.cap="Sample Caption", echo=FALSE}
plot(pressure)

How do I tell RMarkdown that "Sample Caption" is actually figure text and not just normal text?

1
It does know it's a caption, when I open it in LibreOffice writer that text has the "Image Caption" style attached to it. So presumably that style needs to be centered in Template.docx? (Sorry, I don't know bookdown.) Does it matter if you use fig.align="center" in your code chuck options? - Axeman

1 Answers

0
votes

Try specify fig.id = "pressure" and it should generate automatically numbered captions.