0

I have a problem putting two figures side by side, I don't want the caption text to affect the beside figure.

Here is my code:

\begin{figure}[H] 
\centering 
\begin{minipage}{0.45\textwidth}
    \centering
    \includegraphics[width=0.9\textwidth]{gull} % first figure itself
    \caption{HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD  }
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
    \centering
    \includegraphics[width=0.9\textwidth]{gull} % second figure itself
    \caption{second figure}
\end{minipage}
\end{figure}

So the problem is if I write many things in one \caption I don't want LaTeX to carry the second figure down.

enter image description here

I want for the figures a steady position regardless of what I have written below of them.

1

You might use the position-switches for minipages:

\documentclass[]{article}

\usepackage{graphicx}

\begin{document}
\begin{figure}[h] 
\centering 
\begin{minipage}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=0.9\textwidth]{example-image-a} % first figure itself
    \caption{HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD HELLO WORLD  }
\end{minipage}\hfill
\begin{minipage}[t]{0.45\textwidth}
    \centering
    \includegraphics[width=0.9\textwidth]{example-image-b} % second figure itself
    \caption{second figure}
\end{minipage}
\end{figure}
\end{document}

results

1

This is the default if you use floatrow. In addition you can make the caption width equal to the width of the figure with the optional argument of \ffigbox:

\documentclass[]{article}

\usepackage{graphicx}
\usepackage{caption, floatrow}

\begin{document}

\begin{figure}[!htb]
\centering
\begin{floatrow}[2]
\floatsetup{floatrowsep=qquad}
\captionsetup{labelfont=sc, justification=centerlast}
%
\ffigbox[\FBwidth]{\includegraphics[width=0.45\textwidth]{TheLarch}} % first figure itself
    {\caption{HELLO LARCH\\ HELLO LARCH HELLO LARCH HELLO LARCH HELLO LARCH HELLO LARCH HELLO LARCH HELLO LARCH }}%
   \ffigbox{\includegraphics[width=0.45\textwidth]{TheLarch}} % second figure itself
{\caption{A second larch}}
\end{floatrow}
\end{figure}

\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.