[Tex/LaTex] Two tables do not align vertically

tablesvertical alignment

\documentclass{article}

\begin{document}

\begin{figure}
\centering
\begin{tabular}{*{3}{c}}
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{tabular}
\vspace{3mm}

\begin{tabular}{*{3}{c}}
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{tabular}
\end{figure}

\end{document}

I want to create two tables that are on top of each other. However, the bottom table is aligned slightly to the right of the top table. The difference is small, but noticeable. Why is that, and how can I fix it?

Best Answer

You have to leave a blank line before \vspace{3mm}, not after it. On the other hand, you can also use only one tabular and add the vertical space with \\[3mm].

\documentclass{article}

\begin{document}

\begin{figure}[htb]
\centering
\begin{tabular}{*{3}{c}}
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{tabular}

\vspace{3mm}
\begin{tabular}{*{3}{c}}
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{tabular}
\end{figure}

Or

\begin{figure}[htb]
\centering
\begin{tabular}{*{3}{c}}
1 & 1 & 1 \\
1 & 1 & 1 \\[3mm]
1 & 1 & 1 \\
1 & 1 & 1 \\
\end{tabular}
\end{figure}

\end{document}

enter image description here