How to make landscape tables - pbs-assess/csasdown GitHub Wiki

To make tables on landscape pages, make your call to csasdown::csas_table() as usual and wrap the code chunk in the LaTeX environment landscapepage (note the environment is 'landscapepage' not 'landscape'):

\begin{landscapepage}
```{r chunkname}
 csas_table(data, format = "latex")
```
\end{landscapepage}

Note that you will need to also set format = "latex".

This will work for any of the three documents types.

If you have more than one landscape table in a row, wrap them all in the latex macro:

\begin{landscapepage}
```{r table-1}
 csas_table(data_1, format = "latex")
```
```{r table-2}
 csas_table(data_2, format = "latex")
```
```{r table-3}
 csas_table(data_3, format = "latex")
```
\end{landscapepage}

If you need to have the landscape table at the beginning of a section, your section header will appear on a different page. For example code like this:

# TABLES, GRAPHICS, REFERENCES, AND LABELS {#ref-labels}

## TABLES

\begin{landscapepage}
```{r chunkname}
 csas_table(data, format = "latex")
```
\end{landscapepage}

will produce the table on a landscape page with the headers on the preceding portrait page. This is undesirable. To make those headers appear on the landscape page immediately before the first table, you need to convert them from Markdown to latex and wrap them inside the latex landscape macros like this:

\begin{landscapepage}
\hypertarget{ref-labels}{%
\section{TABLES, GRAPHICS, REFERENCES, AND LABELS}\label{ref-labels}}

\hypertarget{tables}{%
\subsection{TABLES}\label{tables}}

```{r chunkname}
 csas_table(data, format = "latex")
```
\end{landscapepage}

If you don't feel like typing out the LaTeX, you can get the correct code by compiling your document using the previous configuration, where the headers appear on the wrong page, and then looking at the .tex file output. Copy and paste the LaTeX from there into this LaTeX chunk.