Richard Sherman
2025-Nov-23 07:03 UTC
[R] Best practice for copying statistical output from RStudio to Word using Times New Roman
> Colleagues > > I am writing an article using Microsoft Word for a journal that requires > Times New Roman for all text (including tables and statistical outputs). > However, copying console output from RStudio (e.g., summary(lm())) into Word > retains the RStudio monospace font, and Word does not automatically convert > it to Times New Roman. Manually restyling each pasted block is > time-consuming and error-prone. > > s there a recommended workflow for preserving proper alignment while > achieving Times New Roman text formatting when transferring statistical > results from RStudio into Word? > > System: > Windows 11 > R 4.5.1 > RStudio 2024.12.0+ > > Thanks for any guidance or best practices. > > Best regards, > Thomas Subia >Rmarkdown, with this in the YAML: mainfont: Times New Roman It might be necessary to specify output: pdf_document: latex_engine: xelatex mainfont: Times New Roman If necessary one could specify output: word_document but I?ve had less success with that (in placing figures, for example). In graphs and so on, it might be necessary to specify the font in the code that creates them. -Richard --- Richard Sherman Associate Professor of International Relations and Political Science Asian University for Women https://asian-university.org [[alternative HTML version deleted]]
Boris Steipe
2025-Nov-23 08:30 UTC
[R] Best practice for copying statistical output from RStudio to Word using Times New Roman
Thomas - Times is a proportionally spaced font, that means e.g. letters like i and m, or numbers like 1 and 0 have different widths, thus the width of text depends on its contents, not just the number of letters. You cannot align such a font on a regular grid - or rather, if you do by moving the individual letters around, the result looks horrible. There are other mono-spaced fonts that have times-like serifs, but they all look more like Courier, rather than Times itself. RStudio and other code environments use monospaced fonts for layout since it is easy to compute, and in many contexts the number of spaces are not just for positioning text but have semantic meaning. Creating tables in Times is certainly possible, and the Coefficients: part of the lm() output is indeed a right-aligned table with one header row and one data row. However, the _only_ way you can align text in a Times font for a table or similar is by using tabs - standard-, left-aligned, centred, right-aligned, or decimal tabs, whatever your layout requires. You can't emulate this by pushing things around with spaces, this can't align precisely when you are using a proportionally spaced font. This leaves you with three options: - use tabs, not spaces for tables (that's the right way); - use a monospaced font, like Courier (and fight with your publisher); - declare these parts to be figures, not text (which they are, since you are looking to control their spatial arrangement. Tabs. You need to use tabs for tables. Cheers, Boris> On Nov 23, 2025, at 03:03, Richard Sherman <rss.pdx at gmail.com> wrote: > > [You don't often get email from rss.pdx at gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > >> Colleagues >> >> I am writing an article using Microsoft Word for a journal that requires >> Times New Roman for all text (including tables and statistical outputs). >> However, copying console output from RStudio (e.g., summary(lm())) into Word >> retains the RStudio monospace font, and Word does not automatically convert >> it to Times New Roman. Manually restyling each pasted block is >> time-consuming and error-prone. >> >> s there a recommended workflow for preserving proper alignment while >> achieving Times New Roman text formatting when transferring statistical >> results from RStudio into Word? >> >> System: >> Windows 11 >> R 4.5.1 >> RStudio 2024.12.0+ >> >> Thanks for any guidance or best practices. >> >> Best regards, >> Thomas Subia >> > > Rmarkdown, with this in the YAML: > > mainfont: Times New Roman > > It might be necessary to specify > > output: > pdf_document: > latex_engine: xelatex > mainfont: Times New Roman > > If necessary one could specify > > output: > word_document > > but I?ve had less success with that (in placing figures, for example). > > In graphs and so on, it might be necessary to specify the font in the code that creates them. > > -Richard > > --- > Richard Sherman > Associate Professor of International Relations and Political Science > Asian University for Women > https://asian-university.org/ > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide https://www.r-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.