Hello I have really big problems with positioning my sub figures. I have long caption text and I think that is the reason why they don't fit side by side. What can I do for solving this problem. [t] didn't work.
\begin{figure}[t]
\centering
\begin{subfigure}[t]{.5\textwidth}
\centering
\includegraphics[width=12cm]{FIGURE1}
\caption{Really long text over 2 lines}
\label{fig:bestC1Sitting}
\end{subfigure}%
\begin{subfigure}[t]{.5\textwidth}
\centering
\includegraphics[width=12cm]{FIGURE2}
\caption{Really long text over 2 lines}
\label{fig:bestC1Standing}
\end{subfigure}
\end{figure}
I also don't get what's the point of \textwidth or linewidth? Are this relative positions? I would be really glad if somebody can help me.
Best Answer
You are using
\includegraphics[width=12cm]{FIGURE2}
where as your0.5 text width
may not be 12cm. You should be usingwidth=\linewidth
You can usewidth=\textwidth
also assubfigure
is actually aminipage
and\textwidth
refers to the width of text insideminipage
. And don't leave a blank line in between subfigures as it would indicate a paragraph break. With this, we haveLooking UGLY isn't it?. We need some space in between. So change
\begin{subfigure}[t]{.5\textwidth}
to\begin{subfigure}[t]{.45\textwidth}
with a\hfill
in between the subfigures.\textwidth
is generally the global width of the text area. The parameter\linewidth
contains the line length inside a list (or derived) environment and it may change in a nested list (while\hsize
,\textwidth
and\columnwidth
don't change).See egreg's answer from which I borrowed above lines. Hope it will be clear.