[Tex/LaTex] tabular side-by-side, same rows height

tables

Quick advise:

I want to have a tabular side-by-side.

How would you guys suggest me to go about making sure they have the same height?

Consider the case:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}

\begin{table}[H]
\centering
\begin{tabular}{p{14.5em}}
\toprule
\textbf{Medidas Absolutas} \\
\midrule
Média dos erros quadrados \newline MSE$=\frac{1}{n} \sum_{i=1}^n (\hat{x_i}-x_i)^2 $ \\
\midrule
Média dos desvios absolutos \newline MAD$=\frac{1}{n} \sum_{i=1}^n |\hat{x_i}-x_i|$ \\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}{p{14.5em}}
\toprule
\textbf{Medidas Relativas} \\
\midrule
Coeficiente de Theil \newline U$=\frac{\sqrt{\sum_{i=1}^n(\hat{x_i}-x_i)^2}}{\sqrt{\sum_{i=1}^n(x_i-x_{i-1})^2}}$ \\
\midrule
Mean Absolute Percentage Error\newline MAPE$=\frac{1}{n}\sum_{i=1}^n \Big|\frac{(\hat{x_i}-x_i)}{x_i} \Big|$ \\
\bottomrule
\end{tabular}
\caption{Algumas medidas para avaliação do desempenho dos modelos preditivos.}
\end{table}

\end{document}

screenshot

The problem is that the equations on the right are a little too big. I would like the corresponding row of the left table to have the same height.

I have tried \renewcommand{\arraystretch}{1.6} is that it increases size to all rows, not just the bigger ones.

I have tried using \phantom, but it does not quite look for some reason …

Maybe some \mbox with same height?

ps: these are some examples of absolute and relative error functions. If someone has some other idea to present this information that would be welcome as well!

Best Answer

\vphantom can be used to adjust the row/line spacings of the two tables. This aligns the equation lines. Also some text lines nees \vphantom because of the descenders in the other table.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}

\begin{table}
  \centering
  \begin{tabular}{p{14.5em}}
    \toprule
    \textbf{Medidas Absolutas} \\
    \midrule
    Média dos erros quadrados \newline MSE$=\frac{1}{n} \sum_{i=1}^n
    (\hat{x_i}-x_i)^2 $%
    \vphantom{$\frac{\sqrt{\sum_{i=1}^n}}{\sqrt{\sum_{i=1}^n}}$}
    \\
    \midrule
    Média dos desvios absolutos\vphantom{g}
    \newline MAD$=\frac{1}{n} \sum_{i=1}^n
    |\hat{x_i}-x_i|$%
    \vphantom{$\Big|$}
    \\
    \bottomrule
  \end{tabular}
  \hfill
  \begin{tabular}{p{14.5em}}
    \toprule
    \textbf{Medidas Relativas} \\
    \midrule
    Coeficiente de Theil\vphantom{q} \newline
    U$=\frac{\sqrt{\sum_{i=1}^n(\hat{x_i}-x_i)^2}}
      {\sqrt{\sum_{i=1}^n(x_i-x_{i-1})^2}}$
    \\
    \midrule
    Mean Absolute Percentage Error\newline MAPE$=\frac{1}{n}\sum_{i=1}^n
    \Big|\frac{(\hat{x_i}-x_i)}{x_i} \Big|$ \\
    \bottomrule
  \end{tabular}
  \caption{Algumas medidas para avaliação do desempenho dos modelos
    preditivos.}
\end{table}

\end{document}

Result