rr-markdownknitrr-flextable

LaTeX formatting in Word using Rmarkdown and flextable


I have a table that contains column headers with LaTeX formatting (e.g., Lower CI$_{95\\%}$). When I render the table in HTML or PDF format using knitr::kable, they display the correct formatting, but prints verbatim using flextable::regulartable.

Does flextable::regulartable not handle LaTeX, or am I missing the argument (e.g., escape = T) to specify LaTeX? And if it's not supported, will it be eventually?

It works in pander, but flextable provides much better formatting options (aside from the apparent lack of LaTeX support).


Solution

  • Flextable is designed to output using Word's bespoke xml formatting. It is not designed to interpret LaTeX formatting, so you've not missed out arguments which would turn this functionality on or off.

    The package and the officeR package which goes along with it are written and supported by David Gohel, and as you've mentioned flextable does a very good job of outputting tables to Word, which R Markdown does not do well at all. As far as I can tell there are no plans to implement LaTeX formatting in flextable. David Gohel's flextable GitHub page is linked here for reference: https://davidgohel.github.io/flextable/index.html