14

I have this table (a table environment containing two tabular environments). I need the two tabulars to be placed side by side. But I need the second tabular to be align horizontally (same height that first tabular). How can I do it?

\begin{table}[H]
    \caption{Neque porro quisquam est qui dolorem ipsum quia dolor sit amet.}
    \label{table:lorem_ipsum}
    \parbox{.35\linewidth}{
        \begin{tabular}[t]{ c | c }
            Lorem & Ipsum \\ 
            \hline
            A   & B \\
            C & D \\
            E & F \\
            G & H \\
            I & J \\
        \end{tabular}
    }
    \hfill
    \parbox{.50\linewidth}{
        \begin{tabular}[t]{ c | c }
            Lorem & Ipsum \\ 
            \hline
            K & L \\
            M & N \\
            O & P \\
        \end{tabular}
    }
\end{table}

Current code: enter image description here

2 Answers 2

13

I suggest you get rid of the \parbox wrappers. If you want to roughly center the two tabular environments within the width of the text block, consider using a few (more) \hfill instructions.

enter image description here

\documentclass{article}
\usepackage{float,caption}
\begin{document}
\begin{table}[H]
    \caption{Neque porro quisquam est qui dolorem ipsum quia dolor sit amet.}
    \label{table:lorem_ipsum}
    \hfill
        \begin{tabular}[t]{ c | c }
            Lorem & Ipsum \\ 
            \hline
            A   & B \\
            C & D \\
            E & F \\
            G & H \\
            I & J \\
        \end{tabular}
    \hfill
        \begin{tabular}[t]{ c | c }
            Lorem & Ipsum \\ 
            \hline
            K & L \\
            M & N \\
            O & P \\
        \end{tabular}
    \hfill\null
\end{table}
\end{document}

Addendum: If you must keep the \parbox wrappers, I would suggest you add the [t] positioning specifier in both instances: \parbox[t]{.35\linewidth}{...} and \parbox[t]{.50\linewidth}{...}.

2

At least for this example, a simple solution (less code) is constructing only one tabular environment with an empty column.

mwe

\documentclass{article}
\usepackage{booktabs,caption}
\begin{document}
\begin{table}
\caption{Neque porro quisquam est qui 
         dolorem ipsum quia dolor sit amet.}
\centering
 \begin{tabular}[t]{c|cp{1cm}c|c}
   Lorem & Ipsum && Lorem & Ipsum\\[2pt]           
   \cmidrule{1-2}\cmidrule{4-5}
   A & B && K & L \\
   C & D && M & N \\
   E & F && O & P\\
   G & H && \multicolumn{1}{c}{}\\
   I & J && \multicolumn{1}{c}{}\\
 \end{tabular}
\end{table}
\end{document}

You must log in to answer this question.

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