[Tex/LaTex] Text placed under figure instead of above

positioning

I have a figure that contains two subfigures side by side:

Foobar

\begin{figure*}[h!]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=5.0in]{ressourcen/market_category}
        \caption{Market category cocktails}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=5.0in]{ressourcen/market_category_2}
        \caption{Market category lemonade}
    \end{subfigure}
    \caption{Market dashboard}
\end{figure*}

However the text foobar is placed under the figure instead of above it. I want to control the placement with h! but it has no effect. Any ideas how to have the text above the figure?

Best Answer


\documentclass[10pt,a4paper]{article}
\usepackage{subcaption}
\usepackage{float}
\usepackage{graphicx}

\begin{document}


Text before.

\begin{figure}[H]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=2.0in]{example-image}
        \caption{Market category cocktails}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=2.0in]{example-image}
        \caption{Market category lemonade}
    \end{subfigure}
    \caption{Market dashboard}
\end{figure}

Text after.

\end{document}

enter image description here

Related Question