2

I have a problem with the following code:

\begin{table}[!h]
  \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 coloums}\\
        \hline
        Explanation & \multicolumn{2}{p{\textwidth-3\tabcolsep-\widthof{test}-2\fboxrule}}
            {Explanation which goes over two coloums}\\
        \hline
        \multirow{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}% 

I hope this photo helps to understand my problem:

Problem Example

I would like to align the text "Targets" on the top of the cell, like the second table. I'm sure this must be simple to do, but I can't seem to put my finger on it. Please help me with this alignment.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
newbie_Tex
  • 121
  • 1
  • 1
  • 3

1 Answers1

1

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

Example

Note the top alignment of all columns.

I hope this helps.

MoonKnight
  • 23,214
  • 40
  • 145
  • 277