You can use \hfill
to add a horizontal filler between both images. This will push the second image to the right. You need to watch empty lines here because they create new paragraphs. You should add a new paragraph before and after both images, but not between them. In the example code I added explicit \par
s to highlight this, but implicit ones i.e. empty lines are fine, too.
You can vertical center both images using \raisebox
. Images included with \includegraphics
only have a height but no (=zero) depth. Every box (character, image, ...) in (La)TeX has a height, width and depth. Everything below the baseline (the invisible line the letters are placed on) is part of the depth. The \raisebox
command allows you to raise or lower its content but also to set the official width and height of it which can be larger or smaller than the original, the natural amount. The original height can be accessed by the \height
length. Use \raisebox{-.5\height}
to lower the images half under the baseline. This will effectively center them vertically.
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}% For example text
\begin{document}
\lipsum[1]
\par
\raisebox{-.5\height}{\includegraphics[width=4cm]{image1}}%
\hfill
\raisebox{-.5\height}{\includegraphics[width=4cm]{image2}}%
\par
\lipsum[2]
\end{document}
You could also put the above code into \makebox[\textwidth]{...}
to ensure they are on one line if you don't like the \par
s.
This can simplified by using the adjustbox
package. There the key valign=M
(or raise=-0.5\height
) can be used. The margin
key could also be added to improve the spacing.
\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage{lipsum}% For example text
\begin{document}
\lipsum[1]
\par
\noindent
\includegraphics[width=4cm,valign=M,margin=0ex 2ex]{example-image-a}%
\hfill
\includegraphics[width=4cm,valign=M,margin=0ex 2ex]{example-image-b}%
\par
\lipsum[2]
\end{document}
Here's one option, using the floatrow
and subfig
packages; depending on the actual size of your images, you might need to adjust some lengths:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{subfig}
\begin{document}
\begin{figure}
\ffigbox[7.8cm]{%
\begin{subfloatrow}
\hsize0.7\hsize
\vbox to 6.35cm{
\ffigbox[\FBwidth]
{\caption{small subfigure A}}
{\includegraphics[width=3cm,height=3cm]{smallfigure1}}\vss
\ffigbox[\FBwidth]
{\caption{small subfigure B}}
{\includegraphics[width=3cm,height=2cm]{smallfigure2}}
}
\end{subfloatrow}\hspace*{\columnsep}
\begin{subfloatrow}
\ffigbox[\FBwidth][]
{\caption{A large subfigure}}
{\includegraphics[width=3cm,height=6cm]{largepicture}}
\end{subfloatrow}
}{\caption{three subfigures}}
\end{figure}
\end{document}
The demo
option for graphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.
Boxing the larger image, one can automatically calculate the needed height (some small manual adjustment will still be needed for the \vbox
):
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{subfig}
\newlength\imageht
\newlength\imagedp
\begin{document}
\newsavebox\Image
\savebox\Image{\includegraphics[width=4cm]{largefigure}}
\settoheight\imageht{\usebox{\Image}}
\settodepth\imagedp{\usebox{\Image}}
\addtolength\imageht{\imagedp}
\begin{figure}
\ffigbox[7.8cm]{%
\begin{subfloatrow}
\hsize0.7\hsize
\vbox to \dimexpr\imageht+10pt\relax{
\ffigbox[\FBwidth]
{\caption{small subfigure A}}
{\includegraphics[width=3cm,height=1cm]{smallfigure1}}\vss
\ffigbox[\FBwidth]
{\caption{small subfigure B}}
{\includegraphics[width=3cm,height=1cm]{smallfigure2}}
}
\end{subfloatrow}\hspace*{\columnsep}
\begin{subfloatrow}
\ffigbox[\FBwidth][]
{\caption{A large subfigure}}
{\usebox{\Image}}
\end{subfloatrow}
}{\caption{three subfigures}}
\end{figure}
\end{document}
Best Answer
The problem is probably that your images are wider than the minipage. The images can be made exactly as wide as the minipages with
\includegraphics[width=\textwidth]{A1.JPG}