center a table that uses resizebox

I create a table that I would like centered on the page horizontally. I scale the table size using \resizebox. However, doing so, left aligns the table. How do I center it?

Here's a MWE:

\documentclass[11pt,english,titlepage]{article}
\usepackage{graphicx}

\begin{document}

\begin{table}
\caption{mytable}
\resizebox{.5\textwidth}{!}{

\begin{centering}
\begin{tabular}{rrr}
A                     & B                  & C \\
\hline
A1                   & B1             &C1\\
A2                  & B2                  & C2 \\
A3                    & B3             & C3 \\
\end{tabular}
\end{centering}
}
\end{table}

\end{document}


There is no centering environment. And issuing \centering inside \resizebox doesn't make sense anyway: it should be outside, because you want to center the resized box.

\documentclass[11pt,english,titlepage]{article}
\usepackage{graphicx}

\begin{document}

\begin{table}
\centering
\caption{mytable}
\resizebox{.5\textwidth}{!}{% <------ Don't forget this %
\begin{tabular}{rrr}
A              & B            & C \\
\hline
A1             & B1           & C1 \\
A2             & B2           & C2 \\
A3             & B3           & C3 \\
\end{tabular}% <------ Don't forget this %
}
\end{table}

\end{document}

• @egreg: why do you need the % there? – Alex Jul 28 '16 at 4:21
• @Alex Without them you'd get spaces on either side of the table – egreg Jul 28 '16 at 7:35
• @egreg, how do you do if not within a table environment? Using just {\centering .... } as discussed in tex.stackexchange.com/questions/162462/… does not seem to work? Thanks! – Matifou Feb 9 at 2:17

Here an alternative answer using adjustbox. It covers the functionality of \resizebox and is also able to center its content. It also removes the need of escaping the line breaks with % as seen in egregs answer, as the adjustbox environment removes the spaces added by them.

It is even possible to produce the table environment using adjustbox keys, or even to get the whole tabular environment replaced. This saves you a lot of typing in the long run. Note that the order of most adjustbox keys matter.

\documentclass[11pt,english,titlepage]{article}

\begin{document}

\begin{table}
\caption{mytable}% will not give you proper skip as it is configured for placement below the content
\begin{tabular}{rrr}
A              & B            & C \\
\hline
A1             & B1           & C1 \\
A2             & B2           & C2 \\
A3             & B3           & C3 \\
\end{tabular}
\end{table}

% shorter, also covering the table environment
\begin{tabular}{rrr}
A              & B            & C \\
\hline
A1             & B1           & C1 \\
A2             & B2           & C2 \\
A3             & B3           & C3 \\
\end{tabular}
% even shorter, now also covering the tabular environment