I am creating a .Rnw file in Rstudio. I then knit it using:
knit("code.Rnw","code.tex")
I am trying to get two tables side-by-side. In case they are long, I would like them to automatically page break. I have tentative syntax that seems to work (when using the \quad command) as shown below:
\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage{longtable}
\begin{document}
<<echo=FALSE,results='asis'>>=
library(xtable)
@
\begin{tabular}{cc}
\hline
& vals \\
\hline
a & 3.39 \\
b & 4.35 \\
c & 6.16 \\
d & 9.17 \\
e & 2.82 \\
\hline
\end{tabular}
\quad % separates first and second table
\begin{tabular}{cc}
\hline
& vals \\
\hline
a & 3.39 \\
b & 4.35 \\
c & 6.16 \\
d & 9.17 \\
e & 2.82 \\
\hline
\end{tabular}
\end{document}
This creates the desired output as follows:
However, I am running across a problem when the tables become long. In the example above, there were only 5 rows per table. However, if I increase the number of rows so that each table can no longer fit on a single page, then rather than automatically page-break, it will simply run off the page. It looks something like this (there are more rows, y2, z2, etc, but these simply run off the page):
I tried to remedy this problem by using the "longtable" option (instead of the "tabular" option), as this is supposed to help with page-breaks:
\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage{longtable}
\begin{document}
<<echo=FALSE,results='asis'>>=
library(xtable)
@
\begin{longtable}{cc} % CHANGED FROM "TABULAR" TO "LONGTABLE"
\hline
& vals \\
\hline
a & 3.39 \\
b & 4.35 \\
c & 6.16 \\
d & 9.17 \\
e & 2.82 \\
\hline
\end{longtable} % CHANGED FROM "TABULAR" TO "LONGTABLE"
\quad % separates first and second table
\begin{longtable}{cc} % CHANGED FROM "TABULAR" TO "LONGTABLE"
\hline
& vals \\
\hline
a & 3.39 \\
b & 4.35 \\
c & 6.16 \\
d & 9.17 \\
e & 2.82 \\
\hline
\end{longtable} % CHANGED FROM "TABULAR" TO "LONGTABLE"
\end{document}
Even though it did solve the page-break issue (prevented text from falling off the page) in long table, it also made the tables no longer side by side (instead, placing them top to bottom). This was the undesired output:
My question therefore is: How can I retain the side-by-side format of the two tables, while also allowing page-breaks?
EDIT:
I accepted an answer here, although my real question has a second problem with it. I originally did not include it to keep my problem simple, but realize that if I only state one part of the problem, then the solutions will not really solve my set of problems.
Hence, I opened a new post with my more-complete question here: (Two tables (not hard-coded) side-by-side in LaTeX that will page break).