1

I have the following code:

\documentclass[10pt]{article}
\usepackage{subcaption}
\begin{document}

\begin{figure}
  \centering
  \begin{subfigure}[!t]{0.45\textwidth}
   \centering
    \begin{tabular}{|c|c|}
    \hline
    $\phi(A)$ & $A$ \\
    \hline
    $a$ & $\{ a, e, i, o, u, y \}$ \\
    $b$ & $\{ x, z, q \}$ \\ 
    $c$ & $\{ w, v, r, s, t, c \}$ \\
    $d$ & $\{ b, d, f, g, h, j \}$ \\
    $e$ & $\{ k, l, m, n, p \}$ \\
    \hline
    \end{tabular}
    \caption{Reduction to five characters}
    \label{tbl:alpha5}
  \end{subfigure}
  ~
  \begin{subfigure}[!t]{0.45\textwidth}
    \centering
    \begin{tabular}{|c|c|}
    \hline
    $\phi(A)$ & $A$ \\
    \hline
    $a$ & $\{ a, e, i, o, u, y \}$ \\
    $b$ & $\{ x, z, q \}$ \\
    $c$ & $\{ w, v, r, s \}$ \\
    $d$ & $\{ t, c, b, d, f \}$ \\
    $e$ & $\{ g, h, j \}$ \\
    $f$ & $\{ k, l, m, n, p \}$ \\
    \hline
    \end{tabular}
    \caption{Reduction to six characters}
    \label{tbl:alpha6}
  \end{subfigure}
  \caption{Alphabet reduction maps}
\end{figure}
\end{document}

which produces

enter image description here

What I would like to achieve is to put them such that the headers of the two tables are on the same level, and both the subcaptions are on the same level too.

1 Answer 1

1

I suggest you insert the instruction \multicolumn{2}{c}{\null} immediately after the final \hline of the first tabular environment. That way, the two tabular environments have the same number of rows and hence will align correctly automatically -- no need to add placement specifiers after \begin{subfigure}{<width>}.

...
\begin{tabular}{|c|c|}
\hline
$\phi(A)$ & $A$ \\
\hline
$a$ & $\{ a, e, i, o, u, y \}$ \\
$b$ & $\{ x, z, q \}$ \\
$c$ & $\{ w, v, r, s, t, c \}$ \\
$d$ & $\{ b, d, f, g, h, j \}$ \\
$e$ & $\{ k, l, m, n, p \}$ \\
\hline
\multicolumn{2}{c}{\null} % <-- new
\end{tabular}
...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .