1

I have my template here

\begin{document}

\begin{table}[!h]
\begin{center}
\makebox[\textwidth][c] %[l]
{
\begin{tabular}{c|c|c}
\hline
Topic 1 & Topic 2 & Topic 2  \\
\hline
33333 & 44444 & 55555\\
\hline
aaaaa & bbbbb & 55555\\
\hline
 \end{tabular}
 }
  \hspace*{0mm}
\end{center}
\caption{}
  \label{table:example-app}
\end{table} 


\end{document}

enter image description here

How do I make:

a. the "Topic 2" in the 1st row (2nd and 3rd columns) combined to be a single block, and has the vertical line in between removed?

b. As well as combine "55555" occur in the 2nd and 3rd row (of 3rd column) to be a single block, and has the horizontal line in between removed?

c. In the desired new Table, I hope that "Topic 2" and "55555" only occur once in the new form. Namely, repeated items are combined.

I tried to use the multirow but I failed (cannot compile in TexShop). Maybe there is a neat way to do that.

wonderich
  • 2,387

1 Answers1

3

Here it is. You shouldn't use the center environment for tables or figures, as it adds spurious vertical spacing. Use \centering instead. As I didn't see what the \makebox command was for, I took the liberty to remove it. Finally, I added some vertical padding to the rows, setting \arraystretch to 1.2.

\documentclass{article}

\usepackage{multirow}
\begin{document}

\begin{table}[!h]
\centering\renewcommand\arraystretch{1.2}
\begin{tabular}{c|c|c}
\hline
Topic 1 & \multicolumn{2}{c}{Topic 2}\\
\hline
33333 & 44444 & \multirow{2}{*}{55555}\\
\cline{1-2}
aaaaa & bbbbb
\\
\hline
 \end{tabular}
\caption{}
  \label{table:example-app}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Oh! by the way, if you have tables without caption text, you should change the caption style so that there's no colon for such captions (this can be done with the captionpackage). – Bernard May 01 '17 at 20:58
  • Can you explain what does the alternative of "\cline"? Like is there a "\lline" or "\rline"? the C, L, R version for it? What is the meaning? – wonderich May 02 '17 at 01:46
  • Can you explain what is the meaning: \multirow{2}{*}{} ? – wonderich May 02 '17 at 02:10
  • My remaining puzzle: https://tex.stackexchange.com/questions/367726 – wonderich May 02 '17 at 04:00