Text alignment on top with multirow command
This is easily handled with the newly updated multirow command. There is an option that specifies vertical text alignment; put [t]
for top alignment.
In your example you would write:
\multirow[t]{3}{*}{Targets} & Target 1 is long text with two lines & not reached\\
Here is the code that should yield the desired output:
\begin{table}[!h]
\centering
\caption{Title}
\begin{tabular}{lll}
\hline
Name & \multicolumn{2}{l}{long title which goes over two columns}\\
\hline
Explanation & \multicolumn{2}{l}{Explanation which goes over two columns}\\
\hline
\multirow[t]{3}{*}{Targets} & Target 1 is long text with two lines & not reached\\
\cline{2-3}
& Target 2 & reached\\
\cline{2-3}
& Target 3 & reached\\
\hline
\end{tabular}%
\label{tab:test}%
\end{table}
P.S: Don't forget to add the multirow package.
Using \multirow
(from the multirow
package) pushes the contents down to the middle of 3
rows. Instead just drop the use of \multirow
to have the cell top-aligned:
\documentclass[12pt]{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
%\usepackage{multirow}% http://ctan.org/pkg/multirow
\usepackage{calc}% http://ctan.org/pkg/calc
\begin{document}
\begin{table}[!ht]
\centering
\caption{Titel}
\resizebox{.95\columnwidth}{!}{%
\begin{tabular}{p{4.5cm}p{10cm}p{3.5cm}}
\hline
Name & \multicolumn{2}{p{\textwidth-3\tabcolsep-\widthof{test}-2\fboxrule}}
{long title which goes over two columns}\\
\hline
Explanation & \multicolumn{2}{p{\textwidth-3\tabcolsep-\widthof{test}-2\fboxrule}}
{Explanation which goes over two columns}\\
\hline
Targets % Don't use \multirow{4}{*}{Targets} here
& Target 1 is long text with two lines exactly like this spans two lines & not reached\\
\cline{2-3}
& Target 2 & reached\\
\cline{2-3}
& Target 3 & reached\\
\hline
\end{tabular}%
}
\label{tab:test}%
\end{table}
\end{document}
Instead of specifying the widths of the columns explicitly use the l
specifier (which may require the array package). An example of its usage would be the following
\begin{center}
\begin{tabular}{ | l | l | l | p{5cm} |}
\hline
Day & Min Temp & Max Temp & Summary \\ \hline
Monday & 11C & 22C & A clear day with lots of sunshine.
However, the strong breeze will bring down the temperatures. \\ \hline
Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
across most of Scotland and Northern Ireland,
but rain reaching the far northwest. \\ \hline
Wednesday & 10C & 21C & Rain will still linger for the morning.
Conditions will improve by early afternoon and continue
throughout the evening. \\
\hline
\end{tabular}
\end{center}
this will provide an output like this
Note the top alignment of all columns.
I hope this helps.