首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用multirow命令在顶部对齐文本

使用multirow命令在顶部对齐文本
EN

Stack Overflow用户
提问于 2012-09-25 21:14:28
回答 1查看 11.4K关注 0票数 2

我对以下代码有问题:

代码语言:javascript
复制
\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}% 

我希望这张照片能帮助你理解我的问题:

我想在单元格的顶部对齐文本"Targets“,就像第二个表格一样。我相信这一定很简单,但我似乎不太明白。请帮我把这个对准。

EN

回答 1

Stack Overflow用户

发布于 2012-09-25 21:26:50

不要显式地指定列的宽度,而是使用l说明符(这可能需要数组包)。它的用法示例如下

代码语言:javascript
复制
\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}

这将提供如下输出

注意所有列的顶部对齐方式。

我希望这能帮到你。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12583760

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档