# Write column header on multiple line [duplicate]

Possible Duplicate:
How to add a forced line break inside a table cell

I would like to write the header of a column on multiple line. I tried with this commands but it doesn't work:

\begin{tabular}{|c|l|l|l|l|l|l|}
\hline \\
$\alpha$
& \multicolumn{1}{|c|}{GallusGallus \\ CC \\ t = 104}
& \multicolumn{1}{|c|}{GallusGallus \\ MF \\ t = 124}
& \multicolumn{1}{|c|}{GallusGallus \\ BP \\ t = 110}
& \multicolumn{1}{|c|}{BosTaurus \\ CC \\ t = 99}
& \multicolumn{1}{|c|}{BosTaurus \\ MF \\ t = 217}
& \multicolumn{1}{|c|}{BosTaurus \\ BP \\ t = 205}
\end{tabular}


How can I fix?

-

## marked as duplicate by egreg, Andrew Swann, Thorsten, lockstep, Stefan Kottwitz♦Oct 29 '12 at 11:55

See this answer: tex.stackexchange.com/a/19678/4427 – egreg Oct 29 '12 at 11:19

You can use P{<width>}{<contents>} instead of using c column. In p (paragraph) column, usual \centering can be used to center the contents.

\documentclass{article}

\begin{document}
\begin{tabular}{|c|l|}
\hline
$\alpha$
& \multicolumn{1}{|p{3cm}|}{\centering GallusGallus \\ CC \\ t = 104}\\\hline
\end{tabular}
\end{document}


\documentclass{article}
\usepackage[margin=2.5cm]{geometry}
\begin{document}
\noindent
\begin{tabular}{|c|l|l|l|l|l|l|}
\hline
$\alpha$
& \multicolumn{1}{|p{2cm}|}{\centering GallusGallus \\ CC \\ t = 104}
& \multicolumn{1}{|p{2cm}|}{\centering GallusGallus \\ MF \\ t = 124}
& \multicolumn{1}{|p{2cm}|}{\centering GallusGallus \\ BP \\ t = 110}
& \multicolumn{1}{|p{2cm}|}{\centering BosTaurus \\ CC \\ t = 99}
& \multicolumn{1}{|p{2cm}|}{\centering BosTaurus \\ MF \\ t = 217}
& \multicolumn{1}{|p{2cm}|}{\centering BosTaurus \\ BP \\ t = 205}\\\hline
\end{tabular}
\end{document}


-
Why does removing \centering cause all sorts of errors? – Cyrille Mar 16 '15 at 11:53
@Cyrille What sort of error do you get? – Harish Kumar Mar 16 '15 at 12:49
It creates the PDF fine with the centering. I remove \centering and run again and get the following repeated a ~hundred times until a fatal error occurs: Missing } inserted.<inserted text>} ...|p{2cm}|}{ GallusGallus \\ CC \\ t = 104} and Extra }, or forgotten \endgroup.<recently read> \egroup ...|p{2cm}|}{ GallusGallus \\ CC \\ t = 104} – Cyrille Mar 17 '15 at 14:06
@Cyrille It compiles fine for me after removing \centering. – Harish Kumar Mar 17 '15 at 14:26
That's what I would have expected... Hmm oh well. A bug perhaps. Using a OS X 10.10.1 for the record. I will update Tex... Thanks! – Cyrille Mar 18 '15 at 13:46