# How does one split a column title into two lines?

\documentclass[12pt,a4paper]{book}
\usepackage{array}
\begin{document}
\begin{table}[H]
\setlength{\tabcolsep}{5mm}
\begin{tabular}[h]{|>{\centering\arraybackslash}p{2cm}||>      {\centering\arraybackslash}p{3cm}|>{\centering\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{2.5cm}|}
\hline
\rotatebox{90} {\centering case1}      & \rotatebox{90}{\centering Case2}   &  \rotatebox{90}{\centering This is the case 3?} & \rotatebox{90} {\centering Case 4}  \\ \hline\hline
a      &  b    & c  & d  \\ \hline
\end{tabular}
\caption{My table}
\end{table}
\end{document}


How can I split the title "This is the case 3" into two lines?

-
Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. – egreg Nov 21 '12 at 10:11
A MWE should start with \documentclass and call all the packages necessary to compile it. – egreg Nov 21 '12 at 10:17
Does this help: tex.stackexchange.com/questions/40465/… – Paul Stanley Nov 21 '12 at 10:21
Downvote: You are not a newbie here and should know to include an MWE. – Martin Schröder Nov 21 '12 at 10:48
but i have the packages that i have used , that's it ? – researcher Nov 21 '12 at 10:54

One way would be to use something like

\parbox{2cm}{\raggedright This is the case 3?}


or add a \\ to manually split the line:

\parbox{2cm}{\raggedright This is \\ the case 3?}


## Code:

\documentclass{article}
\usepackage{array}
\usepackage{graphicx}
\begin{document}
\setlength{\tabcolsep}{5mm}
\begin{tabular}[h]{|>{\centering\arraybackslash}p{2cm}||>      {\centering\arraybackslash}p{3cm}|>{\centering\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{2.5cm}|}
\hline
\rotatebox{90} {\centering case1}      & \rotatebox{90}{\centering Case2}   &
\rotatebox{90}{\centering \parbox{2cm}{\raggedright This is the case 3?}} & \rotatebox{90} {\centering Case 4}  \\ \hline\hline
a      &  b    & c  & d  \\ \hline
\end{tabular}

\begin{tabular}[h]{|>{\centering\arraybackslash}p{2cm}||>      {\centering\arraybackslash}p{3cm}|>{\centering\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1cm}|>{\centering\arraybackslash}p{2.5cm}|}
\hline
\rotatebox{90} {\centering case1}      & \rotatebox{90}{\centering Case2}   &
\rotatebox{90}{\centering \parbox{2cm}{\raggedright This is \\ the case 3?}} & \rotatebox{90} {\centering Case 4}  \\ \hline\hline
a      &  b    & c  & d  \\ \hline
\end{tabular}
\end{document}

-
Did you mean \rotatebox{90}\parbox{2cm}{\centering \raggedright This is the case 3?} ? it didn't work ;( – researcher Nov 21 '12 at 10:28
Can you first complete your code snippet in the question so that I can cut and paste and get it to compile. That way I can be sure I am using the same packages as you. – Peter Grill Nov 21 '12 at 10:32
\rotatebox{90}{\parbox{2cm}{ This is \\ the case 3?}} it works :) – researcher Nov 21 '12 at 10:42
thank you for answer, please i have one more question: how can i divide a line in a cellule ? simple cellule not the title. – researcher Dec 3 '12 at 18:35
@researcher: If I understand you correctly you could either use the p{} column type, as in the example here in which case it should already wrap. Or, use a \parbox{<length>}{} for the content. If that does not work, then you should post a separate question as it is not related to the title of this question. And as I am not quite the expert as some other people here, so I would have to actually see the table and try things to find the ideal solution. – Peter Grill Dec 3 '12 at 19:17

The \centering in

 \rotatebox{90}{\centering This is the case 3?}


is doing nothing, it is like

 \mbox{\centering This is the case 3?}


In both cases there is a single TeX horizontal (LR) box in which no linebreaking happens.

Depending on the appearance that you want any of the following work and give different effects

\rotatebox{90}{\parbox{2cm}{\centering This is the\\ case 3?}}


\rotatebox{90}{\parbox{2cm}{This is the\\ case 3?}}


\rotatebox{90}{This is the}
\rotatebox{90}{case 3?}}


-