1

I'm trying to display a bunch of images side by side. Originally I wanted them on the same line, but I got them to fit by putting 2 on the next line. I'd like to make the pictures bigger but the white space beside the images seems to grow proportionally and push the second image off the page.

enter image description here

\documentclass[]{article}
\usepackage[demo]{graphicx}

\begin{document}
\begin{figure}[h]
\centering
\begin{minipage}{.5\textwidth}
    \centering
    \includegraphics[width=0.4\linewidth]{p1}
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \includegraphics[width=0.4\linewidth]{p2}   
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \includegraphics[width=0.4\linewidth]{p3}
\end{minipage}%
\begin{minipage}{.5\textwidth}
    \centering
    \includegraphics[width=0.4\linewidth]{p4}
\end{minipage}
\end{figure}
\end{document}
7
  • you could remove all the minipage which are not doing anything useful, and delete the blank lines which are paragraph breaks so forcing things to stack vertically. Commented Mar 11, 2015 at 14:06
  • The rules for white space around an image are exactly the same as the rules for a letter such as X \includegraphics itself adds no space, you just get whatever white space you have added in the source file. Ends of lines introduce word spaces and blank lines introduce vertical paragraph skips. Commented Mar 11, 2015 at 14:08
  • Ideally I'd like the images to line up horizontally. by adding a % at the end of the second minipage I do get that, but the third image is only half on the page and the 4th is completely off
    – Arland
    Commented Mar 11, 2015 at 14:09
  • Your example doesn't allow anyone to see anything as it isn't a complete document and it references figures we haven't got. If you make a complete document and add \usepackage[demo]{graphics} then the example will be more useful and you can check that it shows the problem. You have 4 images stacked vertically so they will run off the page if they are too large, but we have no indication of their size. Commented Mar 11, 2015 at 14:13
  • Doesn't the width=0.4 set the image width? Document is updated as suggested
    – Arland
    Commented Mar 11, 2015 at 14:23

1 Answer 1

2

It isn't really clear what you want, but perhaps:

enter image description here

\documentclass[]{article}
\usepackage[demo]{graphicx}

\begin{document}
\begin{figure}[htp]% never use h on its own
\centering
    \includegraphics[width=0.2\linewidth]{p1}
    \includegraphics[width=0.2\linewidth]{p2}   
    \includegraphics[width=0.2\linewidth]{p3}
    \includegraphics[width=0.2\linewidth]{p4}
\end{figure}
\end{document}
3
  • That looks good. I tried adding captions with \caption{} and it lined the images up vertically. Is there a way to keep it horizontal?
    – Arland
    Commented Mar 11, 2015 at 14:39
  • @Arland Yes if you want \caption then you can put each image in a minipage with its caption, or use a package like subfigure or subcaption that has more extensive support. (depends if you want to number 1,2,3,f or 1a 1b 1c 1d, mainly) Commented Mar 11, 2015 at 14:41
  • Ok thanks, I'll look into that. Thanks for your input
    – Arland
    Commented Mar 11, 2015 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .