3

I have three similar tables, one within its own figure and two as two subfigures within a second figure. The two subtables are off-center, despite being within the \centering environment. How can I center all the tables?

(I'm new to tables, and my construction is probably less than elegant, but I've taken out all the extraneous lines that don't cause the error. It must be something in the multirow/multicolumn part.)

\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}
  • Whoops, forgot the first line. Should be complete now. – Katie R Apr 28 '14 at 20:26
2

You want the subtable boxes to be full width, and then centre inside them:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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