我有三个相似的表格,一个在自己的图形中,两个作为子图形在第二个图形中。尽管在 \centering 环境中,但这两个子表偏离中心。我怎样才能将所有表格居中?
(我对表格还不熟悉,我的构造可能不够优雅,但我已经删除了所有不会导致错误的多余的行。它一定是多行/多列部分中的某些东西。)
\documentclass[]{article}
\usepackage{multirow, array, hhline}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[!ht]
\centering
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.5em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0 & 0.0 & 0.0 \\
\end{tabular}
\caption{Caption 1}
\end{table}
\begin{table}[!ht]
\centering
\begin{subtable}[h]{2in}
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.75em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0\% & 00\% & 00\% \\
\end{tabular}
\caption{2a}
\end{subtable}
\begin{subtable}[h]{2in}
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.75em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0\% & 00\% & 00\% \\
\end{tabular}
\caption{2b}
\end{subtable}
\end{table}
\end{document}
答案1
您希望子表框占满整个宽度,然后居中里面他们:
\documentclass{article}
\usepackage{multirow, array, hhline}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{table}[!ht]
\centering
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.5em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0 & 0.0 & 0.0 \\
\end{tabular}
\caption{Caption 1}
\end{table}
\begin{table}[!ht]
\centering
\begin{subtable}{\textwidth}\centering
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.75em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0\% & 00\% & 00\% \\
\end{tabular}
\caption{2a}
\end{subtable}
\begin{subtable}{\textwidth}\centering
\begin{tabular}{|r|c|c|c|}
\multirow{2}{*}{\parbox[p][2.75em][b]{2.5cm}{\centering Rows}} & \multicolumn{3}{ >{\centering\arraybackslash}p{3.5cm}|}{\parbox[p][2.5em][c]{3.5cm}{\centering Columns}} \\
\multicolumn{1}{|c|}{} & 0\% & 00\% & 00\% \\
\end{tabular}
\caption{2b}
\end{subtable}
\end{table}
\end{document}