Word Table Style in RMarkdown

Dear Community

I would like to use Rmarkdown and a reference word.docx to easily apply text, figure & table styles and create an company report.

I've successfully customized text styles (e.g. title, heading 1/2, paragraph, ...) and use it in the entire reference document ("update heading 1 to match selection). After knitting, i can see that the customized text styles are applied in the company report. Nice & easy !

I've tried doing the same for table styles (grey color for top row, text centered, ...). I can create or modify an existing table style and apply this new format to the table in my reference document. However, I couldn't find a way to use it in the entire reference document (no possibility to update to match selection = the other tables in my reference document do not change).

Of course, after knitting, the tables in the company report are not updated accordingly.

title: "Report"
author: "MB"
date: "December 10, 2019"
    toc: yes
    fig_caption: yes
    reference_docx: "Template.docx" 

A <- c(1,2,3)
B <- c(2,3,4)
df <- data.frame(A,B)

Any idea how to proceed ? It is not quite straightforward ... Thanks a lot


I don't know if you know it yet, but flextable is really great package to format table and it works well for docx output

Thanks for the information. It works great even though it would have been easire to completely define eveything (i.e. text, table, ...) in the template word document.

You can change Table style in the reference document. You need to modify this specific style using menu Modify Style, and not apply a new style with a different name to your table. That is because pandoc will always apply the Table style to tables.

See this how-to

This will then apply this new style to all the tables.
Did you already tried that ? It works for me

I don't think pandoc custom style works also for Tables :thinking:

Yes, I've tried that in my reference document based on the github thread you copied above .. but it didn't work.

So I've downloaded the work template from the github thread and just copy-paste the table in my own reference document ... and it worked ! Thanks for your help !

Strange, it worked for me.

Glad you found a solution tough ! :+1::ok_hand:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.