# How do you display table headers that are wider than the rest of the column?

I have a table with lots of columns, which only contain a short values, but have long headings. I think this table would fit width-wise on a single (landscape) page, if I could get the headings sit on alternating rows, with the ends overlapping.

How can I achieve this?

(I've tried writing two header rows, with half the column names in one row and half in another, using \multicolumn, but I can't get them to then align neatly with the columns.)

\documentclass[]{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{ccc}
\toprule
Lengthy words which & make my  columns too wide like & antidisestablishmentarianism\\
\midrule
1 & 0 & 0\\
3 & 7 & 5\\
\bottomrule
\end{tabular}

\end{document}


Or, alternatively, is Big table with rotated column labels using booktabs the preferred layout for tables with long headings? I am reluctant to use it, because there are enough rows that the headers will need to be repeated on multiple pages already; making them taller will exacerbate this problem.

## 2 Answers

I first thought in an answer like that:

\documentclass{article}
\usepackage{array}
\usepackage{rotating}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ccc}
\toprule
\begin{sideways} Lengthy words which  \end{sideways} &
\begin{sideways} make my columns too wide like  \end{sideways} &
\begin{sideways} antidisestablishmentarianism \end{sideways} \\
\midrule
1  & 0  & 0\\
3  & 7  & 5\\
\bottomrule
\end{tabular}
\end{document}


But I believe that this is point again to the wrong target. Although you can wrap the headings with p columns, or tabularx or using multicolumns, o rotate 90º the headings, o some other trick, there are not a good LaTeX solution for this, because the table still will have probably a bad looking design. Just compare these four tables:

The first table made with tabularx have horrible headings expanding in four lines and still a lot of space between columns. If you want reduce this space (second table) the headngs are even longer (more than horrible). And rotate headings as in the above MWE force to the reader to do some fun neck exercises. LaTeX can do the best with the given text, but not a miracle. The main problem is the bad design of the table, and the solution is the re-desing of the table. What table is better?

I know that this is too obvious, and surely is not considered for some good reason in this case, but in general the best solutions for long headings just are (1) use shorter headers (including using acronyms, predefined labes, etc.) or (2) transposing columns and rows:

\documentclass[]{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{lcc}
\toprule
Some long to explain & a & b \\
\midrule
Lengthy words which & 1 & 3 \\
make my  columns too wide like & 0 & 7 \\
antidisestablishmentarianism & 0 & 5 \\
\bottomrule
\end{tabular}

• The headings are as short as they can be without become obscure, given how many there are. It is an adaption of a table taken from another source, so I had simply kept the same rows and columns, for ease of cross-reference; but transposing them may help in this instance. What if the row names are also long though? It would be good to have a more general solution. Aug 26 '13 at 12:58
• Another source?. May be a spreadsheet is that you need to transpose easily columns in rows. With respect to a very long row name, as wide as possible, that still expand in 2-3 lines, IMHO is not the optimal scenario. But it is much better than columns names filling 6-8 lines.
– Fran
Aug 26 '13 at 19:30
• Sorry, I mean: in this instance, it will help me to transpose rows and columns, so thank you. But what if next time, both the row names and the column names are long? Transposing will not help. Aug 27 '13 at 11:04
• But help a meaningful abbreviation (that ise explained in the caption, the main text, or even in a footnote under the table). You can reduce repetition, improve reading efficiency and maintain the table in a reasonable size. Sure, a simple label as "Growth" is more obscure than "Percentage of growth population in Siberia in 1992" but this should be already clear by the context.
– Fran
Aug 27 '13 at 17:26

Edit: There were a problem to hyphenate properly long words in the table in the first solution. It is because if there is one single long word, LaTeX won't hyphenate it because it never hyphenates the first word of a paragraph. The workaround is to tell LaTeX that this word is not the first word of the paragraph, simply adding a null space before the given word.

One solution would be to use p instead of c for your columns definition.

\begin{tabular}{p{.2\textwidth} p{.2\textwidth} p{.2\textwidth}}
\toprule
Lengthy words which & make my  columns too wide like & \hspace{0pt}antidisestablishmentarianism\\
\midrule
1 & 0 & 0\\
3 & 7 & 5\\
\bottomrule
\end{tabular}


As far as I can tell it seems to work, but it has problem to cut properly long words like anti...; unfortunately \hyphenation did not help me a lot with this problem...

Another possibility would be to use \multicolumn, like that:

\begin{tabular}{c c c c c}
\toprule
\multicolumn{2}{c}{Lengthy words which} & & \multicolumn{2}{c}{antidisestablishmentarianism} \\
& \multicolumn{3}{c}{make my  columns too wide like} & \\
\midrule
1 & \multicolumn{3}{c}{0} & 0\\
3 & \multicolumn{3}{c}{7} & 5\\
\bottomrule
\end{tabular}


You can improve the output by changing some of the c by some well defined p.

• The first one doesn't help with long words, only multiple words. The second one is similar to what I have tried, and I think is what my question was aiming at. Unfortunately, I think it is going to required editing every other entry to be multicolumned? I'm not sure it's worth the effort, given the size of the table... Aug 27 '13 at 11:06
• I finally got why there was an hyphenation problem and found a workaround for the first solution. For the second solution, it could be fairly easy if you edit your source file with Emacs (with Ctrl+r rt you can insert a column, so you could very easily insert a bunch of \multicolumn{3}{c}{... see Emacs documentation for more details).
– MBR
Aug 27 '13 at 11:47