Need to split some wide tables across multiple pages using longtable. The code below provides an example of what I’m trying to do. Some of the column names need to vary by page. Specifically, columns 4-7 should be labelled “IB”, “IIA”, “II”, and “ ” on odd numbered pages of the table and “IIB”, “IIIA”, “Other”, and “Overall” on even numbered pages. (Note though that the table itself could start on an odd or an even numbered page in a document.)
The code below produces correct output on pages 1, 2, and 4, but not on page 3. There, columns 4-7 read “IIB”, “IIIA”, “Other”, and “Overall” when they should say “IB”, “IIA”, “II”, and “ ”. Imagine there’s some way to fix this, but it seems well beyond my current abilities. Any help with this will be greatly appreciated.
\documentclass[11pt]{article}
%% Margins %%
\setlength{\textwidth}{6.25in}
\setlength{\oddsidemargin}{0in}
%%%% Packages %%%%
\usepackage[font={bf}]{caption}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage[newcommands]{ragged2e}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{booktabs}
\usepackage[pdfview=Fit]{hyperref}
%%%% Table Captions %%%%
\DeclareCaptionLabelSeparator{period-newline}{. }
\captionsetup{singlelinecheck=false,labelsep=period-newline,aboveskip=3pt}
\begin{document}
{
\scriptsize
\begin{landscape}
\begin{ThreePartTable}
\begin{TableNotes}
\item[]
A footnote I might want to add to the bottom of each page
at a later date.
\end{TableNotes}
\begin{longtable}[l]{ c c p{3.5in} *{4}{>{\centering}m{0.75in}} }
\caption[Treatment Regimens by Line]{Treatment Regimens by Line and Regimen} \\ \hline \addlinespace[3pt]
& & & \multicolumn{3}{c}{Disease Substage} & \\ \cmidrule(l){4-6}
Line & Regimen & Agents & IB & IIA & II & \\ \hline
\endfirsthead
\caption[]{Treatment Regimens by Line and Regimen (Continued)} \\ \hline \addlinespace[3pt]
& & & \multicolumn{3}{c}{Disease Substage} & \\ \cmidrule(lr){4-6}
Line & Regimen & Agents & IIB & IIIA & Other & Overall \\ \hline
\endhead
\hline \multicolumn{7}{r}{\emph{Continued on next page}} \\ \hline
\insertTableNotes
\endfoot
\hline
\insertTableNotes
\endlastfoot
%%%% Pages 1 and 2 %%%%
\addlinespace
1 & 1 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace
& 2 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace
& 3 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace
& 4 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace
2 & 1 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace[3pt]
\newpage
\addlinespace
1 & 1 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace
& 2 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace
& 3 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace
& 4 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace
2 & 1 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace[3pt]
\newpage
%%%% Pages 3 and 4 %%%%
\addlinespace
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace
& 2 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & \\ \addlinespace[3pt]
\newpage
\addlinespace
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace
& 2 & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\
& & Lengthy text description of regimen $\ldots$ & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) & xxx (xx.x\%) \\ \addlinespace[3pt]
\end{longtable}
\end{ThreePartTable}
\end{landscape}
}
\end{document}
longtable
, and approach like this one tex.stackexchange.com/questions/108494/… might be adapted.