Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restrict the size of my \multicolumn cells in a longtable?

I have a really long table in LaTeX that spans several pages and is (as it is now) also too wide for the page.

I am using the longtable package with every column width specified with the p{width} command.

The problem is, that most of the rows contain a multicolumn call, and thus are not adhering to the preamble p{width} command, which causes the total width of the table to be too large.

Minimal example:

\begin{longtable}{|p{1in}|p{0.75in}|p{0.5in}|p{0.5in}|>{p{1in}|p{1in}|}
\caption{some cap} \label{somelable}\\
\hline
\multicolumn{2}{|c|}{\textbf{Text Header One}} & \multicolumn{2}{|c|}{\textbf{Text Header Two}} & \multirow{2}{*}{\textbf{Three}} & \multirow{2}{*}{\textbf{Four}} \tabularnewline \cline{1-4}
\textbf{Five} & \textbf{Six} & \textbf{Seven} & \textbf{Eight} &  & \tabularnewline \hline
Some Text String & Longer Text String Here & More Text Here & Text Example & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hlineExample Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & \multicolumn{2}{|l|}{Multi-column Text String that doesn't fit column width} & Text & Text \tabularnewline \hline
Example Text String Two & Longer Text String Example Two & width of box & text & Text & Text  \tabularnewline \hline
\end{longtable} 

I am loading longtable in my preamble, and running pdflatex several times (as outlined in the longtable documentation). It compiles with 0 warnings and 0 errors.

How can I get normal "narrow" cells?

like image 780
Mica Avatar asked Jul 10 '09 17:07

Mica


1 Answers

Have you tried using |p{<sum of widths>}| for the formatting option to \multicolumn?

Just guessing here.

like image 76
dmckee --- ex-moderator kitten Avatar answered Oct 23 '22 15:10

dmckee --- ex-moderator kitten