# Two tables cannot both align to center

I have two tables with different column number. Now I have the following code (I'm new to LaTeX, if there is a better way to have two tables in a group plz let me know).

\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
& $W_f, W_u, W_c, W_o$ & $W_y$        & $b_f, b_u, b_c, b_o$ & $b_y$      \\ \hline
Dim. & $(n_a, n_a + n_x)$   & $(n_y, n_a)$ & $(n_a, 1)$           & $(n_y, 1)$ \\ \hline
\end{tabular}
\newline
\vspace*{0.1cm}
\newline
\centering
\begin{tabular}{|c|c|c|c|}
\hline
& $a^{<t>}, a^{<t-1>}, c^{<t>}, c^{<t-1>}$ & $\Gamma_f, \Gamma_u, \Gamma_o$ & $\tilde{c}^{<t>}$ \\ \hline
Dim. & $(n_a, m)$                               & $(n_a, m)$                     & $(n_a, m)$      \\ \hline
\end{tabular}
\caption{The dimension of used parameters in an LSTM forward pass. We have a dimension size of $m$ because we are doing vectorization calculation for $m$ inputs simultaneously.}
\label{table:lstm-fp}
\end{table}


What I want is just let this two table vertically aligned to center. But I've failed for a while.

EDIT:

I've tried \bigskip but it doesn't work :(

\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|c|}
\hline
& $W_f, W_u, W_c, W_o$ & $W_y$        & $b_f, b_u, b_c, b_o$ & $b_y$      \\ \hline
Dim. & $(n_a, n_a + n_x)$   & $(n_y, n_a)$ & $(n_a, 1)$           & $(n_y, 1)$ \\ \hline
\end{tabular}
\bigskip
\begin{tabular}{|c|c|c|c|}
\hline
& $a^{\langle t \rangle}, a^{\langle t-1 \rangle}, c^{\langle t \rangle}, c^{\langle t-1 \rangle}$ & $\Gamma_f, \Gamma_u, \Gamma_o$ & $\tilde{c}^{\langle t \rangle}$ \\ \hline
Dim. & $(n_a, m)$                               & $(n_a, m)$                     & $(n_a, m)$      \\ \hline
\end{tabular}
\caption{The dimension of used parameters in an LSTM forward pass. We have a dimension size of $m$ because we are doing vectorization calculation for $m$ inputs simultaneously.}
\label{table:lstm-fp}
\end{table}

• Off-topic: instead of a^{<t>}, you may wish to write a^{\langle t\rangle}, etc. – Mico Feb 3 '18 at 7:03
• Off-topic: You defined 6 columns but use only 5 ... – user31729 Feb 3 '18 at 7:04
• @Mico Thanks for telling. I actually have used a^{\langle t\rangle}. But I prefer to have <> when writing and then do replacement :DD – Kulbear Feb 3 '18 at 7:12
• @ChristianHupfer woops – Kulbear Feb 3 '18 at 7:13

I suggest to use a common tabular environment for both tables and apply \multicolumn for the 2nd and 3rd columns in the 2nd table.

I stretched the array spacings a little bit.

Also vertical rules in tables are not recommended.

\documentclass{article}

\begin{document}

\begin{table}
\centering
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{|*{5}{c|}}
\hline
& $W_f, W_u, W_c, W_o$ & $W_y$        & $b_f, b_u, b_c, b_o$ & $b_y$      \\ \hline
Dim. & $(n_a, n_a + n_x)$   & $(n_y, n_a)$ & $(n_a, 1)$           & $(n_y, 1)$ \\ \hline
\multicolumn{5}{c}{} \\
\hline
& \multicolumn{2}{c|}{$a^{<t>}, a^{<t-1>}, c^{<t>}, c^{<t-1>}$} & $\Gamma_f, \Gamma_u, \Gamma_o$ & $\tilde{c}^{<t>}$ \\ \hline
Dim. & \multicolumn{2}{c|}{$(n_a, m)$ }                              & $(n_a, m)$                     & $(n_a, m)$      \\ \hline
\end{tabular}
\caption{The dimension of used parameters in an LSTM forward pass. We have a dimension size of $m$ because we are doing vectorization calculation for $m$ inputs simultaneously.} \label{table:lstm-fp}
\end{table}

\end{document}


• Appreciate the solution! – Kulbear Feb 3 '18 at 7:28

Just remove

\newline
\vspace*{0.1cm}
\newline
\centering


and insert \bigskip (or \medskip), sandwiched between blank lines,between the two tabular environments.

Addendum: I take it you chose to create two separate tabular environments so that the width of the material wouldn't exceed \textwidth. I think it's better to create a single, vertically-oriented table, and not scatter the information across two separate tabular environments. A separate issue: since almost all of the material is in math-mode, using an array environment cuts down drastically on the number of $ symbols one has to type. I would also like to suggest that you give the table a much more "open" look by omitting all vertical lines and using just one horizontal line. Your readers will appreciate it, and they will likely reward your effort by actually studying the tabular material... \documentclass{article} \usepackage{booktabs,mathtools} \DeclarePairedDelimiter{\zz}{\langle}{\rangle} \begin{document} \begin{table} \centering \renewcommand\arraystretch{1.2}$\begin{array}{@{}ll@{}}
\textnormal{Parameters} & \textnormal{Dimension} \\
\midrule % from 'booktabs' package
W_f, W_u, W_c, W_o & (n_a, n_a + n_x)\\
W_y & (n_y, n_a)\\
b_f, b_u, b_c, b_o & (n_a, 1)\\
b_y & (n_y, 1) \\
a^{\zz{t}}, a^{\zz{t-1}}, c^{\zz{t}}, c^{\zz{t-1}} & (n_a, m) \\
\Gamma_f, \Gamma_u, \Gamma_o & (n_a, m)\\
\tilde{c}^{\zz{t}} & (n_a, m) \\
\end{array}$\caption{Dimensions of parameters used in an LSTM forward pass. We have a dimension size of$m$because we are doing vectorization calculation for~$m\$ inputs simultaneously.}
\label{table:lstm-fp}
\end{table}
\end{document}

• @Kulbear: You need \bigskip and an empty line after that, then the 2nd tabular – user31729 Feb 3 '18 at 7:22
• Appreciate the solution! – Kulbear Feb 3 '18 at 7:28
• @ChristianHupfer - No problem at all! In the meantime, I've added a completely different solution, which uses a single, vertically-oriented array environment to replace the OP's two horizontally-oriented tabular environments. – Mico Feb 3 '18 at 7:35
• @Mico: Yes, I saw that already. Can't upvote again, however ;-) And your 2nd solution needs more vertical space? You're a tree - killer in case the table is printed on paper :-P – user31729 Feb 3 '18 at 7:36
• @ChristianHupfer - Jabba the Hutt has been called much worse than a tree-killer. :-) – Mico Feb 3 '18 at 7:38