1

I am trying to align two tables to the top of the page. The problem is that if one table is not the same length as the other, it will align its center with the other tables rather than moving to the top. As you can see from the image below, the third table is not aligned to the top of the page. Does anybody have an idea on how to make both tables align to the top of the page?

enter image description here

\documentclass{article}

\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{tabularx}
\colorlet{tablegray}{gray!50!white}
\newcommand{\faketable}[1]{{\color{tablegray}\rule{\linewidth}{.#1\textheight}}}
\begin{document}

    \begin{table*}
        \begin{minipage}{0.45\textwidth}
            \caption{I am das duck}
            \faketable{3}
            \bigbreak
            \caption{I am the penguin}
            \faketable{5}
        \end{minipage}
        \hfill
        \begin{minipage}{.45\linewidth}
            \caption{I bin das Walross}
            \faketable{8}
        \end{minipage}
    \end{table*}

\end{document}
  • 1
    Tour code doesn't compile for me... Try \begin{minipage}[t]{0.45\textwidth} --->(not tested!) – koleygr Jun 21 '17 at 7:58
  • The code does not compile. One have to change [2] to [1] in \newcommand to compile. Adding optional parameter to minipage environments (as suggested by koleygr) solves the issue. – Wojtek Myszka Jun 21 '17 at 8:07
1

There's a problem with the \faketable command which is declared as accepting two arguments, but uses only one. So I declared only one. That said, use the [t] option for your minipages. Unrelated: the caption yields a correct spacing between caption above table and table.

\documentclass{article}

\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{tabularx, caption}
\colorlet{tablegray}{gray!50!white}
\newcommand{\faketable}[1]{{\color{tablegray}\rule{\linewidth}{.#1\textheight}}}

\begin{document}

\begin{table*}
  \begin{minipage}[t]{0.45\textwidth}
    \caption{I am das duck}
    \faketable{3}
    \bigbreak
    \caption{I am the penguin}
    \faketable{5}
  \end{minipage}
  \hfill
  \begin{minipage}[t]{.45\linewidth}
    \caption{Ich bin das Walross}
    \faketable{8}
  \end{minipage}
\end{table*}

\end{document} 

enter image description here

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.