2

The table is too wide, and I want to make it narrower by wrapping the Second under the First, how should I achieve this?

The latex code looks like this currently:

\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*}%

enter image description here

| improve this question | | | | |
  • 1
    This is no different than your other question... – Werner Mar 14 '14 at 3:37
2

For example, this can be achieved by a nested table:

\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}

Result

| improve this answer | | | | |
  • thanks, can "First Second" be in the centre of the cell? – sweetyBaby Mar 14 '14 at 2:11
  • @sweetyBaby Change \newcommand*{\tab}[1]{\begin{tabular}{@{}l@{}}#1\end{tabular}} to \newcommand*{\tab}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}. – Gonzalo Medina Mar 14 '14 at 2:27
2

I just put the column entries that needed stacking into stacks. The stack alignment is controlled with an optional argument to the stack: [l], [c], or [r]. Also, I set the vertical stacking gap in the preamble with \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}

enter image description here

| improve this answer | | | | |
2

A solution using the makecell package: its aim is specifically to allow multine cells and it has a \multirowcellcommand with a syntax slightly different from that of \multirow. I also suggest to replace the bigstrut package with ``cellspace; this package allows to define a minimal distance between the top of a row and the bottom of the row above (\cellspacetoplimit) and symmetrically a\cellspacebottomlimit. 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 themath` option.

        \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} 

enter image description here

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.