1

I'm an extreme beginner. I would like to write the names of R packages like "lavaan" in the screenshot attached, but I really don't know how to achieve that. Can anyone help? I would only format one word at a time like this. enter image description here

1 Answers1

2

This list the packages of a R session automatically, with the required format:

mwe

test.Rnw in Rstudio (or test.Rtex in Overleaf):

\documentclass{article}
\begin{document}

<<foo,echo=F>>=

library(xtable) # loaded only for test library(ggplot2) # loaded only for test

@

\subsection*{A hard R work}

<<morefoo,echo=T>>= 2+3 @

\subsection*{Materials and Methods}

<<info,echo=F>>= a <- knitr::combine_words(.packages(), before = "\texttt{", after ="}") @

For this hard work we used the \Sexpr{sessionInfo()$R.version$version.string} with the packages \Sexpr{a}.

\end{document}

Fran
  • 80,769