Blank lines tell LaTeX
to start a new paragraph, which is one of the reasons that your code puts the figures on their own lines; the other reason is that the sum of the width of your two minipage
s is 2\textwidth
, which is wider than \textwidth
.
There are a few things that we can do to fix this:
- remove the blank line between the first
\end{minipage}
and the second \begin{minipage}...
- change the
width
argument of each minipage
so that the combined width is less than or equal to \textwidth
; of course, if you'd prefer to overflow the page margins, then you can crank it up higher
- add a
%
after the first \end{minipage}
which removes the little bit of horizontal space that is automatically inserted by the minipage
environment.
Referring to this line of your code:
\includegraphics[width=0.3\linewidth, height=0.15\textheight]{prob1_6_2}
This will refer to the current linewidth
, i.e, the width of the current minipage
in which it resides. If we make each minipage
have a width of .5\textwidth
, then the width of this graphic will actually be .15\textwidth
wide. Adjust as you see fit- typically, I specify the width of the minipage
, and then prefer to use \includegraphics[width=\textwidth...
Finally, there are some concerns about using \begin{figure}[h]
. Float placement has been discussed in great detail at the following links (in order of recommended reading- the last one is epic):
Here is a complete (modified) version of your code that implements the changes described above.
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}[!htb]
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=0.3\linewidth, height=0.15\textheight]{prob1_6_2}
\caption{$dt=0.1$}
\label{fig:prob1_6_2}
\end{minipage}%
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=0.3\linewidth, height=0.15\textheight]{prob1_6_1}
\caption{$dt =$}
\label{fig:prob1_6_1}
\end{minipage}
\end{figure}
\end{document}
For further options about putting figures side by side, have a look at LaTeX figures side by side and the links within- there are a lot of options available.
My final comment is to consider using descriptive labels- using \label{fig:prob1_6_1}
is ok, but it doesn't tell you much about what the figure
actually shows you. This may not matter when you're writing the document and you are intimately familiar with it, but if you come back to it at a later time, you might wish for more details; for example, if the figure shows solution to a Bernoulli
equation , you might label it fig:bernoulli
.
minipage
environments. Remove the empty line and place%
after the first\end{minipage}
. Also, you cannot place twominipage
s side-by-side if each one is the width of the typeblock. No extra package is required forminipage
; it is a standard environment.minipage
s to span the width of the text area, the sum of their widths should be1.0\textwidth
. The specific values depend on the size of the figures and how you'd like them arranged. Check the link in @cmhughes comment for more details.[h]
on its own it makes it highly likely the float goes to the end of the document latex will usually warn and change it to[ht]
to give itself a chance , but best to include p as well:[thp]
minipage
environments.