3

For example I have this table:

\begin{longtable}[c]{ p{1.0in} p{1.5in} p{2.0in} p{2.5in} }
   \multicolumn{3}{l}{ Partner } & \hfill Total \\ 
\end{longtable}

But the result is that the 'Partner' part will adjust depending on the length of the partner name. The total width should be fixed to 4.5 inches(1.0 + 1.5 + 2.0).

1 Answer 1

4

In the second argument of \multicolumn you can use a p{...} column type of the desired width. Since you need to take into account the padding for the columns (the space between the borders of the columns and their contents), the right width is 4.5in+4\tabcolsep:

\documentclass{book}
\usepackage{longtable}

\begin{document}

\begin{longtable}[c]{p{1.0in}p{1.5in}p{2.0in}p{2.5in}}
   \multicolumn{3}{p{\dimexpr4.5in+4\tabcolsep\relax}}{Partner} & \hfill Total \\
\end{longtable}

\end{document}

It's easy to give a general expression:

Let's say the multicolumn will span k columns, having format p{w1}, p{w2},...,p{wk} (here, w1,w2,...,wk are the lengths for each column); then you need to use w1+w2+...+wk+2(k-1)\tabcolsep as the width of the \multicolumn.

2
  • What's the use of "+4" part in p{\dimexpr4.5in+4\tabcolsep\relax}?
    – eggshot
    Commented Sep 10, 2013 at 2:52
  • @eggshot \dimexpr4.5in+4\tabcolsep\relax evaluates to 4.5in plus 4 times \tabcolsep Commented Sep 10, 2013 at 2:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .