TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create the following layout:

 ------------                                                                  -------------
|   IMAGE 1  |                                                                |   IMAGE 2   |
|____________|                                                                |_____________|

Notice that the two images are relatively small in size, but I want them to be placed at the right/leftmost edge of the document. I tried it using minipages like this:



But then, the two images are placed like this:

|   IMAGE 1  |

|   IMAGE 2   |

I fooled around with the values of minipage and image-width, but nothing seems to help...

Edit: Also, I need the images to be centered to each other (horizontally speaking), so they are nicely aligned if one is bigger than the other.

share|improve this question
What happens if you do \includegraphics[width=4cm]{image1.eps}\hfill\includegraphics[width=4cm]{image2‌​.eps}? – Loop Space Apr 29 '11 at 12:39
(Incidentally, the flushright does nothing because it is inside the minipage, and your minipage and graphic are the same size. That the two are on separate lines is caused by the blank line between the minipage environments: that starts a new paragraph.) – Loop Space Apr 29 '11 at 12:40
The empty line between the minipages is inserting a new paragraph which make the second image be placed below the first. You need to avoid this. – Martin Scharrer Apr 29 '11 at 13:02
up vote 10 down vote accepted

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


\usepackage{lipsum}% For example text







You could also put the above code into \makebox[\textwidth]{...} to ensure they are on one line if you don't like the \pars.

share|improve this answer
nice. I'd forgotten about \height. – Ian Thompson Apr 29 '11 at 13:33
\makebox didn't do it... but \raisebox worked perfectly. Thanks a bunch – Florian Peschka Apr 29 '11 at 13:33
@ApoY2k: I meant to use \makebox with \raisebox: \makebox[\textwidth]{\raisebox{-.5\height}{\includegraphics[width=4cm]{image1}}‌​\hfill \raisebox{-.5\height}{\includegraphics[width=4cm]{image2}}}%, just to ensure both are on one line. Using paragraph breaks around it achieves the same. – Martin Scharrer Apr 29 '11 at 13:39

How about this?


\hspace{\fill} uses up all available space, pushing your images to the margins.

You can adjust the vertical alignment using minipages, so your original example would become something like this:

\framebox{ABC \rule{1pt}{1cm}}
\framebox{DEF \rule{1pt}{10cm} }

More details on this can be found in epslatex.pdf

share|improve this answer
That works nicely, but now there's a second problem; the second image is now aligned to the bottomline of the first - how can I get it to align to the center (horizontally speaking) – Florian Peschka Apr 29 '11 at 12:52
You might write a line about what \hspace and \hfill commands, that will make your answer even better. – ipavlic Apr 29 '11 at 12:57
I would just write \hfill instead. – Martin Scharrer Apr 29 '11 at 13:04
@ApoY2k: You should update your question with the vertical alignment requirement. – Martin Scharrer Apr 29 '11 at 13:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.