I am trying to built a 6×6 table which contains mutlirows. My code is
\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{multicol}
\usepackage{multirow}
\begin{document}
\begin{table}[H]
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|} \hline
\multicolumn{6}{|c|}{$\mathbf{n_1n_2n_3}$}\\ \hline
\multirow{6}{*}{$500$} & \multirow{3}{*}{$410$} & \multirow{2}{*}{$320$} & {} & {}& $005$\\
{} & {} & {} & $203$ & $104$ & $041$\\
{} & {} & \multirow{2}{*}{$302$} & $230$ & $140$ & $014$\\
{} & \multirow{3}{*}{$401$} & {} & $221$ & $122$ & $032$\\
{} & {} & \multirow{2}{*}{$311$} & $212$ & $131$ & $023$\\
{} & {} & {} & {} & $113$ & $050$\\
\hline
\end{tabular}
\end{center}
\caption{Table}
\label{tab:matrix}
\end{table}
\end{document}
Mu output is
As you can see the 4th and 5th column from left are not fancy. How can I make this table a bit better-loking?
Best Answer
You can nest a
tabular
environment inside\multirow
:In the following code, I defined
\innerTab
only for the first example, to clean up the actualtabular
(1st example);\mRowTab[<opt>]{<content>}
which produces a\multirow
of<opt>
rows (default: 2) with its content<content>
wrapped inside a centered-columntabular
(2nd and 3rd example);\innerTabular{<content>}
which puts<content>
into a one-columned vertically centeredtabular
(4th example).As it stands the
\mRowTab
definition could be replaced bywhich means that only one-rowed
<text>
is allowed (notabular
).The second example is a copy of the first one with the new
\mRowTab
.The third example is, in my opinion, “better-looking”.
The fourth example (not pictured) is a copy of the third one, only without
\multirow
but with\innerTabular
Note that the first row doesn’t actually need\innerTabular
.Code
Ouput