2

I am trying to place two images next to each other and I use minipages for that. I create two minipages and when I compile it the one image overlaps with the other. Shouldn't be the one next to the other by default without any overlapping and with no need to add horizontal space in the first place and do so only if I wanted to make them even more apart? Why is that happening and how can I fix it?

The code I used is

\begin{minipage}[t]{2cm}

\includegraphics[scale=0.45]{A1.JPG}

\end{minipage}
\begin{minipage}[b]{2cm}

\includegraphics[scale=0.45]{A11.JPG}

\end{minipage}
4
  • You don't need minipages to make images come next to each other \includegraphics{a}\includegraphics{b} puts b next to a, however minipages won't stop that happening, If they are overlapping it means that either the image isn't the size latex thinks or (more likely) you have added negative space somewhere. If you don't show any example code, hard to say. – David Carlisle Mar 16 '14 at 20:13
  • I added the code but I can't really understand what you mean by saying "the size latex thinks"?How is that work? – Adam Mar 16 '14 at 20:19
  • If (for example) you are using EPS files, LatEx believes the specified bounding box comment that gives the size, but if that is wrong (which is not uncommon) the included postscript can put an image anywhere on the page without latex having any information it is there. You are using pdftex and jpg so tex reads the file so it is less likely the size is wrong, but you gave no information originally. – David Carlisle Mar 16 '14 at 20:33
  • Those minipages are not doing anything useful, you could have just \includegraphics[witd=.4\textwidth]{A1.JPG}\hfill\includegraphics[witd=.4\textwidth]{A11.JPG} – David Carlisle Mar 16 '14 at 20:35
5

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}

3
  • Thanks it works perfectly! If the images are wider shouldn't just be larger than the minipage itself and not overlap anyway but be cropped? – Adam Mar 16 '14 at 20:26
  • @Adam no as with any other overfull box you get a warning in the log (which you could have mentioned) and the overfull text sticks into the margin. There is nothing special about images you would see the same warning and same behaviour with \mbox{abcdefghikmnopq.....} – David Carlisle Mar 16 '14 at 20:31
  • I didn't notice the warning but thank you for the clear explanation. – Adam Mar 16 '14 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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