(Vertical) Alignment of caption when placing two tables beside each other

alignmentcaptionsminipagesubcaption

I followed the approach outlined in this answer to place two tables (and also figures and tables) beside each other.
Unfortunately if the height of one of the two floats is greater than the other one the captions are no longer aligned.

Image and MWE of this problem below:
enter image description here
MWE

\documentclass[ngerman]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{tabularx}
\usepackage{booktabs}
\begin{document}

\begin{table}[!htb]
    \begin{minipage}{.49\textwidth}
        \centering
        \label{tab:state0_eval_sarsa}
        \caption{Bewertung State 0 \\ bester Sarsa Agent}
        \begin{tabular}{lr}
        \toprule
        Aktion  & Bewertung \\ \midrule
        0   & -0,0283 \\
        1   & -0,0258 \\
        2   & -0,0223 \\
        3   & -0,0272 \\
        4   & 0,0019  \\
        5   & -0,0218 \\
        6   & -0,0337 \\
        7   & -0,0394 \\
        8   & -0,0274 \\ \bottomrule
    \end{tabular}
    \end{minipage}%
    \begin{minipage}{.49\textwidth}
        \centering
        \caption{Bewertung Aktionsklassen State 0 bester Sarsa Agent}
        \label{tab:state0_eval_sarsa_aggregated}
        \begin{tabular}{lr}
        \toprule
        Aktion  & Bewertung \\ \midrule
        Ecke    & -0,0279 \\
        Kante   & -0,0286 \\
        Mitte   &  0,0019 \\ \bottomrule
        
        \end{tabular}
    \end{minipage}
\end{table}

\end{document}

Best Answer

Use \begin{minipage}[t]{<width>} The optional argument t puts the contents at the top of the box.

d

The \hfill between the minipages pushes the tables to the left and right edge of the text area.

\documentclass[ngerman]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\usepackage{tabularx}
\usepackage{booktabs}

\usepackage{kantlipsum}% to add dummy text

\begin{document}
    
    \kant[1]
    
    \noindent\begin{table}[!htb]
        \begin{minipage}[t]{.45\textwidth}
            \centering
            \label{tab:state0_eval_sarsa}
            \caption{Bewertung State 0 \\ bester Sarsa Agent}
            \begin{tabular}{lc}
                \toprule
                Aktion  & Bewertung \\ \midrule
                0   & -0,0283 \\
                1   & -0,0258 \\
                2   & -0,0223 \\
                3   & -0,0272 \\
                4   & 0,0019  \\
                5   & -0,0218 \\
                6   & -0,0337 \\
                7   & -0,0394 \\
                8   & -0,0274 \\ \bottomrule
            \end{tabular}
        \end{minipage}\hfill%
        \begin{minipage}[t]{.45\textwidth}
            \centering
            \caption{Bewertung Aktionsklassen State 0 bester Sarsa Agent}
            \label{tab:state0_eval_sarsa_aggregated}
            \begin{tabular}{lc}
                \toprule
                Aktion  & Bewertung \\ \midrule
                Ecke    & -0,0279 \\
                Kante   & -0,0286 \\
                Mitte   &  0,0019 \\ \bottomrule                
            \end{tabular}
        \end{minipage}
    \end{table}

\kant[1]
    
\end{document}