Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Please, how to break headers titles in a table ?

\begin{table}[H]
\begin{tabular}[h]{|p{2cm}||p{2cm}} 
\hline
{title one} & {title two}   \\ \hline\hline
\end{tabular}
\caption{title}
\end{table}

Thank you.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can use \parboxes with line changing commands; inside the boxes you can use \centering to center the contents:

\documentclass{article}

\begin{document}

\begin{table}
\centering
\begin{tabular}{|p{2cm}|p{2cm}|} 
\hline
\parbox[t]{2cm}{\centering title \\ one} & \parbox[t]{2cm}{\centering title \\ two} \\[3ex]
some text & some text \\
some text & some text \\
\hline
\end{tabular}
\caption{title}
\end{table}

\end{document}

enter image description here

I used the vertical rules as visual reference points. On a side note, with such narrow columns, you could consider setting them ragged right.

share|improve this answer
    
Thank you so much, it works :) please, one more question how can center the titles in the cellule ? –  researcher Aug 31 '12 at 22:47
    
@researcher You're welcome" For your new requirement, see my updated answer; I assumed you wanted to center only the title cells; if you wanted to center all the column, let me know. –  Gonzalo Medina Aug 31 '12 at 22:53
    
Thank you so much for help :), yes how center all the column ? –  researcher Sep 1 '12 at 9:09
    
@researcher load the array package: usepackage{array} and instead of p{2cm} use >{\centering\arraybackslash}p{2cm} –  Gonzalo Medina Sep 1 '12 at 13:37
    
thank you so much Gonzalo :) my table is well, but i have a little problem, i have one title of coloumn is a bit long so it is written on the table row, i wish you understand me .. –  researcher Sep 1 '12 at 21:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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