如何在一个单元格中将单词分成两行?

如何在一个单元格中将单词分成两行?

表格太宽,我想通过包裹下方来使其变窄SecondFirst我该如何实现?

乳胶代码目前如下所示:

\begin{table*}[t]
  \centering
  \caption{Add caption}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multirow{2}[4]{*}{Case Study} & \multirow{2}[4]{*}{5} & \multicolumn{3}{c|}{IBEA} \bigstrut\\
\cline{3-5}        &     & FD & P & U \bigstrut\\
    \hline
    \multirow{3}[6]{*}{First Second} & Run (c.) & 6090 & 6605 & 7976\bigstrut\\
\cline{2-5}        & Run (nc.) & 6665 & 6187 & 6609 \bigstrut\\
\cline{2-5}        & \#Missed & 39332 & 46001 & 46765 \bigstrut\\
    \hline
    \multirow{3}[6]{*}{First Second} & Run (c.) & 4418 & 4459 & 4513 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4480 & 4384 & 443 \bigstrut\\
\cline{2-5}        & \#Missed & 21081 & 21897 & 21613\bigstrut\\
    \hline
    \multirow{3}[6]{*}{First Second} & Run (c.) & 4163 & 4251 & 4282 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4241 & 4186 & 4302\bigstrut\\
\cline{2-5}        & \#Missed & 1217 & 1456 & 2524 \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table*}%

在此处输入图片描述

答案1

例如,可以通过嵌套表来实现:

\documentclass{article}
\usepackage{multirow,bigstrut}

% The optional argument specifies the horizontal alignment:
% l = left aligned
% c = centered
% r = right aligned
\newcommand*{\tab}[2][c]{%
  \begin{tabular}{@{}#1@{}}%
    #2%
  \end{tabular}%
}

\begin{document}
\begin{table*}[t]
  \centering
  \caption{Add caption}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multirow{2}[4]{*}{\tab{Case\\Study}} & \multirow{2}[4]{*}{5} & \multicolumn{3}{c|}{IBEA} \bigstrut\\
\cline{3-5}        &     & FD & P & U \bigstrut\\
    \hline
    \multirow{3}[6]{*}{\tab{First\\Second}} & Run (c.) & 6090 & 6605 & 7976\bigstrut\\
\cline{2-5}        & Run (nc.) & 6665 & 6187 & 6609 \bigstrut\\
\cline{2-5}        & \#Missed & 39332 & 46001 & 46765 \bigstrut\\
    \hline
    \multirow{3}[6]{*}{\tab{First\\Second}} & Run (c.) & 4418 & 4459 & 4513 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4480 & 4384 & 443 \bigstrut\\
\cline{2-5}        & \#Missed & 21081 & 21897 & 21613\bigstrut\\
    \hline
    \multirow{3}[6]{*}{\tab{First\\Second}} & Run (c.) & 4163 & 4251 & 4282 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4241 & 4186 & 4302\bigstrut\\
\cline{2-5}        & \#Missed & 1217 & 1456 & 2524 \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table*}%
\end{document}

结果

答案2

我只是将需要堆叠的列条目放入堆栈中。堆栈对齐由堆栈的可选参数控制:[l][c][r]。此外,我使用 来设置前导中的垂直堆叠间隙\setstackgap{S}{length}

\documentclass{article}
\usepackage{multirow, bigstrut}
\usepackage{stackengine}
\setstackgap{S}{8pt}
\begin{document}
\begin{table*}[t]
  \centering
  \caption{Add caption}
    \begin{tabular}{|c|c|c|c|c|}
    \hline
    \multirow{2}[4]{*}{\Shortunderstack{Case Study}} & \multirow{2}[4]{*}{5} & \multicolumn{3}{c|}{IBEA} \bigstrut\\
\cline{3-5}        &     & FD & P & U \bigstrut\\
    \hline
    \multirow{3}[6]{*}{\Shortunderstack{First Second}} & Run (c.) & 6090 & 6605 & 7976\bigstrut\\
\cline{2-5}        & Run (nc.) & 6665 & 6187 & 6609 \bigstrut\\
\cline{2-5}        & \#Missed & 39332 & 46001 & 46765 \bigstrut\\
    \hline
    \multirow{3}[6]{*}{\Shortunderstack{First Second}} & Run (c.) & 4418 & 4459 & 4513 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4480 & 4384 & 443 \bigstrut\\
\cline{2-5}        & \#Missed & 21081 & 21897 & 21613\bigstrut\\
    \hline
    \multirow{3}[6]{*}{\Shortunderstack{First Second}} & Run (c.) & 4163 & 4251 & 4282 \bigstrut\\
\cline{2-5}        & Run (nc.) & 4241 & 4186 & 4302\bigstrut\\
\cline{2-5}        & \#Missed & 1217 & 1456 & 2524 \bigstrut\\
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table*}%
\end{document}

在此处输入图片描述

答案3

使用包的解决方案makecell:它的目的是专门允许多单元格,并且它的命令 \multirowcell的语法与 略有不同。我还建议用“cellspace \cellspacetoplimit \cellspacebottomlimit math”选项\multirow替换包。bigstrut; this package allows to define a minimal distance between the top of a row and the bottom of the row above () and symmetrically a. In order to make this setting effective, one has to prefix the alignment parameter of the columns with the letter S. It works in math mode with the

        \documentclass{article}

        \usepackage{array, makecell, multirow, bigstrut}
        \usepackage{cellspace} 
      \cellspacetoplimit = 4pt
       \cellspacebottomlimit  = 4pt

        \begin{document}

      \begin{table*}[t]
        \centering
        \caption{Add caption}
        \begin{tabular}{|Sc|Sc|Sc|Sc|Sc|}
        \hline
        \multirow{2}[4]{*}{Case Study} & \multirow{2}[4]{*}{5} & \multicolumn{3}{Sc|}{IBEA} \\%
    \cline{3-5}        &     & FD & P & U \\%
        \hline
        \multirowcell{3}[-4pt]{First \\[6pt] Second} & Run (c.) & 6090 & 6605 & 7976 \\%
    \cline{2-5}        & Run (nc.) & 6665 & 6187 & 6609 \\%\
    \cline{2-5}        & \#Missed & 39332 & 46001 & 46765 \\%
        \hline
        \multirowcell{3}[-4pt]{First \\[6pt] Second} & Run (c.) & 4418 & 4459 & 4513 \\%
    \cline{2-5}        & Run (nc.) & 4480 & 4384 & 443 \\%
    \cline{2-5}        & \#Missed & 21081 & 21897 & 21613 \\%
        \hline
        \multirowcell{3}[-4pt]{First \\[6pt] Second} & Run (c.) & 4163 & 4251 & 4282 \\%
    \cline{2-5}        & Run (nc.) & 4241 & 4186 & 4302 \\%
    \cline{2-5}        & \#Missed & 1217 & 1456 & 2524 \\%
        \hline
        \end{tabular}%
        \label{tab:addlabel}%
        \end{table*}%

        \end{document} 

在此处输入图片描述

相关内容