I have a .Rnw file that looks like this:
\documentclass[a4paper,11pt]{article}
\begin{document}
\title{}
\author{me}
\date{\today}
\maketitle
\section{Header}
<<table_mtcars, results = "asis">>=
stargazer(rbind(mtcars, mtcars, mtcars), summary = F)
@
\FloatBarrier
\end{document}
I can use knitr::knit
to produce a .tex file and then convert this to a PDF. The resultant PDF looks like this:
Note how the table disappears off the end of page 2 and doesnt resurface on page 3. How can I get the table to continue on page 3 of the PDF using stargazer?
As far as I know this is not currently supported by stargazer. I would recommend emailing the developer, who is usually very open to suggestions. The issue is that you need to use LaTeX's longtable
environment instead of tabular
, but this is the part that Stargazer doesn't seem to support.
You can create a workaround by doing:
\documentclass[a4paper,11pt]{article}
\usepackage{longtable}
\begin{document}
\title{}
\author{me}
\date{\today}
\maketitle
\section{Header}
\Sexpr{library(knitr);gsub('tabular','longtable',knit(text="<<results = 'asis'>>=\nlibrary(stargazer)\nstargazer(rbind(mtcars, mtcars, mtcars), summary = FALSE, float = FALSE)\n@"))}
\end{document}
Basically, you're calling knitr within your .Rnw file in order to build the table, and gsub
the tabular
environment to longtable
. When I run this, it comes out as three pages long.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With