4

I want to do vertical alignment of subtables. The following is a minimal example of the tables I have.

\documentclass{article}
\usepackage{multirow}
\usepackage{subcaption}

\begin{document}
\begin{table}[]
    \centering
    \caption{Test1}
    \begin{subtable}{.3\linewidth}
        \centering
        \caption{Subtable 1}
        \begin{tabular}{|l|l|c|}
            \hline
            \multicolumn{2}{|c|}{Col 1} & Col 2 \\ \hline
            \multicolumn{2}{|l|}{Cell 1} & 1 \\ \hline
        \end{tabular}
    \end{subtable}%
    \begin{subtable}{.3\linewidth}
        \caption{Subtable 2}
        \centering
        \begin{tabular}{|l|l|c|}
            \hline
            \multicolumn{2}{|c|}{Col 1} & Col 2 \\ \hline
            \multicolumn{2}{|l|}{Cell 1} & 1 \\ \hline
            \multicolumn{2}{|l|}{Cell 2} & 2 \\ \hline
        \end{tabular}
    \end{subtable}% 
\end{table}
\end{document}

This generates the following type of table

Not Aligned tables

What to do if I want to get a table like this (edited in paint):

Aligned tables

1
  • Can I use subfloat instead of subtable?
    – hola
    Jun 5 at 20:20

2 Answers 2

6

Use the optional argument of the subtable environment:

\begin{subtable}[t]{.3\linewidth}
3

To complement @Bernard answer I had to also set [t] in the tabular element.

\begin{subtable}[t]{.48\linewidth}

and

\begin{tabular}[t]{lrl}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.