2

So I have this code:

\begin{center}
\footnotesize
\begin{tabular}{| c | c  c  c |}
      \hline
      \multirow{3}{*}{Equipment acquired at start of year} & \multicolumn{3}{c|}{Replacement cost (\$) for given years}\\
      \cline{2-4}
      & 1 & 2 & 3\\
      \hline
      1 & 4000 & \multicolumn{1}{|c|}{5400} & 9800\\
      2 & 4300 & \multicolumn{1}{|c|}{6200} & 8700\\
      3 & 4800 & \multicolumn{1}{|c|}{7100} & -\\
      4 & 4900 & \multicolumn{1}{|c|}{-} & -\\
      \hline
\end{tabular}
\end{center}

Which gives me this table:

What I want is that the column 3 is evenly width like column under 1 and 2. Also I want "Equipment acquired at start of year" to be centered between the two multirows.

Any ideas? xD

2

2 Answers 2

3

enter image description here

  • sum of widths of the 2nd, 3th and 4th columns should be larger from width of multi column cell above their column heads (this can be simple achieve by p{...} columns type)
  • \multirow can automaticaly break a text only if you prescribe the width of this cell. Otherwice is handy to use \makcell macro from the package with the same name, in which you break a text by use of \\ (see MWE -- Minimal Working Example -- below):
\documentclass{article}
\usepackage{makecell, multirow}

\begin{document}
    \begin{center}
\footnotesize
\renewcommand\arraystretch{1.2}
\begin{tabular}{| c | *{3}{>{\centering\arraybackslash}p{13mm}}|}
      \hline
\multirow{2}{*}{\makecell{Equipment acquired\\ at start of year}} 
        & \multicolumn{3}{c|}{Replacement cost (\$) for given years}\\
      \cline{2-4}
        & 1     &   2       &   3       \\
      \hline
      1 & 4000 &    5400    &   9800    \\
      2 & 4300 &    6200    &   8700    \\
      3 & 4800 &    7100    &    --     \\
      4 & 4900 &     --     &    --     \\
      \hline
\end{tabular}
    \end{center}
\end{document}

You may like the following table format:

enter image description here

\documentclass{article}
\usepackage{booktabs, makecell, multirow}

\begin{document}
    \begin{center}
\footnotesize
\begin{tabular}{ c *{3}{>{\centering\arraybackslash}p{13mm}} }
      \toprule 
\multirow{2}{*}{\makecell{Equipment acquired\\ at start of year}} 
        & \multicolumn{3}{c}{Replacement cost (\$) for given years}\\
      \cmidrule{2-4}
        & 1     &   2       &   3       \\
      \midrule
      1 & 4000 &    5400    &   9800    \\
      2 & 4300 &    6200    &   8700    \\
      3 & 4800 &    7100    &    --     \\
      4 & 4900 &     --     &    --     \\
      \bottomrule
\end{tabular}
    \end{center}
\end{document}
3

I'd suggest the following:

enter image description here

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

\begin{document}
\begin{center}
\begin{tabular}{*{4}{c}}
      \toprule
\multirow{3}{2cm}{Equipment acquired at start of year} 
        & \multicolumn{3}{c}{Replacement cost}\\
        & \multicolumn{3}{c}{(\$) for given years}\\
      \cmidrule{2-4}
        & 1     &   2       &   3       \\
      \midrule
      1 & 4000 &    5400    &   9800    \\
      2 & 4300 &    6200    &   8700    \\
      3 & 4800 &    7100    &    --     \\
      4 & 4900 &     --     &    --     \\
      \bottomrule
\end{tabular}
\end{center}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .