Skip to content

Latest commit

 

History

History
154 lines (101 loc) · 3.39 KB

multi-page tables.md

File metadata and controls

154 lines (101 loc) · 3.39 KB

Multi-Page Tables -- Using Longtable

Click here for regular tables (tabular)

Implementation

If you want a table to spill onto a new line vertically while maintaining the previous appearance (e.g. column widths, center, etc.), you can use the package longtable.

At the top with the rest of the packages, make sure to have longtable imported.

\usepackage{longtable}

Besides that, the useage is extremly similar to tabular.

\begin{longtable}{rc|c}
    \# & \textbf{Statement} & \textbf{Reason} \\
    \hline
    
    1. & insert statement & insert reason \\
    2. & ... & ... \\
    .  & ... & ... \\
    .  & ... & ... \\
    .  & ... & ... \\
\end{longtable}

{rc|c} means right-alight, centre, separating line, centre for the columns, just like with tabular.

I usually have the rc|c structure so I have a column for the numbering lines 1, 2, 3...

Note: longtable will auto-centre the table in the page to ensure that the table lines up with a new page when it spills over. Tabular will not and just cut.

Example

Here's some code. If say the following where to involve going over the end of one page, this would be the correspondig output...

\begin{longtable}{lr|c}
   \# & \textbf{Statement} & \textbf{Reason} \\
   \hline
   
   1. & statement   & reason \\
   .  & ...         & ... \\
   .  & Obi:        & Hello There! \\
   .  & Grievous:   & General Kenobi. \\
   .  & Grievous:   & You are a bold one. \\
   .  & Grievous:   & Back away! I will deal with this Jedi slime \textit{myself}. \\
   .  & Background: & \textit{Insert clanker noises here} \\ 
   .  & Obi:        & Your move. \\
   .  & Grievous:   & You \textit{fool}. I've been trained in your Jedi arts by Count Dooku. \\
   .  & Grievous:   & Attack Kenobi! \\
   .  & Background: & \textit{Insert lightsaber vrms} \\
   .  & ...         & ... \\
\end{longtable}

alt text


Tabular vs Longtable

Click here for tabular

Here are the two side by side to see the differences. As you can see, it's not that much. The implementations besides the initial \usepackage{} and \begin{} header are identical.

Tabular Longtable
% no package to import


% ...

\begin{tabular}{rc|c}
   \# & \textbf{Statement} & \textbf{Reason} \\
   \hline

   1.  & statement & reason \\
   2.  & ... & ... \\
   .   & ... & ... \\
   .   & ... & ... \\
   .   & ... & ... \\
\end{tabular}
% make sure this is at the top
\usepackage{longtable}

% ...

\begin{longtable}[c]{rc|c}
   \# & \textbf{Statement} & \textbf{Reason} \\
   \hline
   
   1. & statement & reason \\
   2. & ... & ... \\
   .  & ... & ... \\
   .  & ... & ... \\
   .  & ... & ... \\
\end{longtable}
Tabular Screenshot Longtable Screenshot

They look the exact same. :p