I want to print a latex table generated with stargazer()
in monospaced font, and I want to do it in a reproducible way with knitr
(i.e., no manual latex coding). I tried to define an environment called mymono
and then wrap the knitr chunk in this environment via \begin{}
and \end{}
. It does not work; the table prints in the default font style.
\documentclass{article}
\newenvironment{mymono}{\ttfamily}{\par}
\begin{document}
<<lm, echo=FALSE>>=
df <- data.frame(x=1:10, y=rnorm(10))
library(stargazer)
lm1 <- lm(y ~ x ,data=df)
@
% reproducible
\begin{mymono}
<<table_texstyle, echo=FALSE, results='asis', message=FALSE>>=
stargazer(lm1, label="test")
@
\end{mymono}
\end{document}
I don't think there is a font setting in stargazer()
except for font.size
.
# > sessionInfo()
# R version 3.0.2 (2013-09-25)
# Platform: x86_64-apple-darwin10.8.0 (64-bit)
# other attached packages:
# [1] stargazer_5.1
Even better than wrapping the entire table{}
in the new font style would be to wrap just tabular{}
so that the caption remains the default style. I don't know if there is a way to insert latex code into the stargazer()
output programmatically.