1

I have a huge table that covers multiple pages:

\documentclass[10pt]{article}

\usepackage{ltablex}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{bibentry}
\usepackage{etoolbox}
\usepackage{helvet}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{color}  
\usepackage{colortbl}
\usepackage{url}
\usepackage{fancyhdr}
\usepackage{datenumber}
\usepackage{xspace}
\usepackage{blindtext}

%Column width for tables
\def \firstColumnWidth {3.5cm}
\def \secondColumnWidth {12.5cm}

\begin{document}

\noindent\begin{tabularx}{\textwidth}{p{\firstColumnWidth}p{\secondColumnWidth}}
\multicolumn{2}{c}{\cellcolor[gray]{0.75}2015}\\
Foo & \blindtext\\
Bar & \blindtext\\
\multicolumn{2}{c}{\cellcolor[gray]{0.75}2014}\\
Foo & \blindtext\\
Bar & \blindtext\\
Bar & \blindtext\\
\multicolumn{2}{c}{\cellcolor[gray]{0.75}2013}\\
Foo & \blindtext\\
Bar & \blindtext\\
\end{tabularx}

\end{document}

In this example, the page break is directly after the 2013 column. However, I want to have the page break either bevor the 2013 column, or after the Foo column. Is there any way to specify in a table where potential page breaks can be. I don't want to add page breaks manually, since the content is dynamic.

6

You can use \\* to prevent a page break

\multicolumn{2}{c}{\cellcolor[gray]{0.75}2013}\\*

If lines are involved you need to change the commands for the lines too:

Prevent page break after \midrule in \longtable

How to disable pagebreak on \hline in longtable?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.