I am trying to create an environment for plotting two figures side-by-side:
\begin{figure}[t]
\begin{minipage}[b]{0.49\textwidth}
\flushleft
\psfragfig[frame,mode=nonstop]{Plot_random_Breite_05_1}
\caption{Figur Nr. 8a}
\label{fig:8a}
\end{minipage}
\hspace*{14pt}% separation between the subfigures
\begin{minipage}[b]{0.49\textwidth}
\flushleft
\psfragfig[frame,mode=nonstop]{Plot_random_Breite_05_2}
\caption{Figur Nr. 8b}
\label{fig:8b}
\end{minipage}
\end{figure}
Unfortunately I get an "Overfull hbox" warning.
I tried several things to remove this warning:
- remove
\hspace
- smaller width (
0.4\textwidth
) \linewidth
instead of\textwidth
subfigure
instead ofminipage
Nothing helped. The plot is not scaled, the textwidth is about 9cm and the size of the plot is about 3cm.
Has someone an idea? Can't figure out where the bug is -.-
If I use \hfill
as recommended below, my code and the output look like this:
\begin{figure}[t]
\begin{minipage}[b]{0.49\textwidth}
\raggedright
\psfragfig[frame,mode=nonstop]{Plot_random_Breite_05_1}
\caption{Figur Nr. 8a}
\label{fig:8a}
\end{minipage}\hfill
\begin{minipage}[b]{0.49\textwidth}
\raggedleft
\psfragfig[frame,mode=nonstop]{Plot_random_Breite_05_2}
\caption{Figur Nr. 8b}
\label{fig:8b}
\end{minipage}
\end{figure}
As you can see I would prefer, if both picture align
with the margins.
Is there a way to align
the second caption with the frame of the plot?
Best Answer
The construction on the line that contains your two sub-figures consist of elements that have the following widths:
A
minipage
of width0.49\textwidth
;An inter-word space between the first
minipage
and the\hspace*
;A hard space of
14pt
;A
minipage
of width0.49\textwidth
.The above combination is wider than
\textwidth
, obviously, as is indicated by the first construction below (I'm using\rule
instead ofminipage
, but the effect is the same):If you're stuck on having the fixed
14pt
gap between the two sub-figures, then you need to make sure that each component is exactly split between the remainder. That is, each image (orminipage
) takes up0.5\textwidth-7pt
. That's what the second construction achieves.Note the use of
%
sign after the first sub-figure in order to avoid the inter-word space that is naturally inserted after a macro with an argument.Alternatively, if you're interested in fixing the width of the sub-figures (rather than the
14pt
gap mentioned above), then you can insert a flexible fill using\hfill
.