5

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?

2 Answers2

5

\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

1

Try with [ht!] parameter.

(Also you may want to use 'keepaspectratio' in 'includegraphics' because you may loose the format of the figure if not)

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

\begin{document}


Foobar

\begin{figure*}[ht!]
    \centering
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=2.0in]{Sc1.png}
        \caption{Market category cocktails}
    \end{subfigure}%
    ~ 
    \begin{subfigure}[t]{0.5\textwidth}
        \centering
        \includegraphics[height=2.0in]{Sc2.png}
        \caption{Market category lemonade}
    \end{subfigure}
    \caption{Market dashboard}
\end{figure*}
%\ref{test}

\end{document}

This is my code and this is the result:

enter image description here

koleygr
  • 20,105