答案1
这将自动列出 R 会话的包,具有所需的格式:
测试.Rnw在 Rstudio 中(或测试版在 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}