Take the 2-minute tour ×
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.

I am trying to align my images in a grid like format within LaTeX and have done so like this:

\documentclass[a4paper,11pt,fleqn,titlepage]{article}
\usepackage[margin=2.5cm]{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{ulem}
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{epstopdf}
\usepackage{longtable}
\usepackage{color}
\usepackage{showframe}
\usepackage{subfigure}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}

\begin{document}

\newpage

\begin{figure}[!ht]
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-4.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-5.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-6.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-7.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-8.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-9.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-10.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-11.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-12.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-13.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-14.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-15.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-16.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-17.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-18.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-19.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-20.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-21.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-22.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-23.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-24.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-25.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-26.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-27.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-28.eps}}}
\vspace{1cm}
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-29.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-30.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-31.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-32.eps}}}
\hspace{0cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\includegraphics[trim=5cm 8cm 6cm 8cm, clip=true, scale=0.25]{Polyhedra/Polyhedron-33.eps}}}
\end{figure}

\newpage
\end{document}

This works fine for me for the first two lines of images (I have five on each line) however when it gets to the third line of images the vertical space between the images increases and I don't know why.

Is there a way to make my images align so that:

  1. The entire figure is top aligned vertically and centrally aligned horizontally to a new page.

  2. The subfigures have five on each line.

  3. The subfigures are aligned centrally horizontally within the figure.

  4. The subfigures are aligned by the top vertically on each line.

  5. The spacing between all subfigures is equal both between them on the same line and from one line to the next.

If you imaging a piece of paper with a grid draw in the centre and an image in the centre of each square in the grid, that's what I want. I get the feeling I am either really close or just doing something horrendously wrong! Any help would be greatly appreciated.

Note: I have only put the boxes in to see where the images begin and end, these shall be removed.

share|improve this question
    
Welcome to TeX.SX. Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Claudio Fiandrino Jan 11 '13 at 16:15

1 Answer 1

up vote 4 down vote accepted

You want a blank line before each \vspace so that the space comes at that point, currently they are all set as a single paragraph \vspace within a paragraph has a defined (but usually unwanted) behaviour

Also unless you are having individual captions you don't need subfigure you could just use \includegraphics directly.


Please when making an example, try to make it minimal by removing unused packages and not relying on unavailable images, something like:

\documentclass[a4paper,11pt,fleqn,titlepage]{article}
\usepackage[margin=2.5cm]{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   % ... or a4paper or a5paper or ... 
%\geometry{landscape}                % Activate for for rotated page geometry
\usepackage[parfill]{parskip}    % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{subfigure}


\begin{document}

\newpage

\begin{figure}[!ht]
\centering
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}

\vspace{1cm}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\subfigure{\setlength\fboxsep{0pt}\setlength\fboxrule{0.5pt}
\fbox{\rule{2.5cm}{2cm}}}
\end{figure}

\newpage
\end{document}

enter image description here

share|improve this answer
    
Ok, will make sure I do that in future. –  adrem7 Jan 11 '13 at 16:36

Your Answer

 
discard

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.