4

I have a lot of different graphics in three versions each. All those versions have a fixed width and I want those three versions to be displayed next to each other. So far, I've used a tabbing environment to achieve this. Since I have a lot of graphics, I wrote a command:

\newcommand{\compimg}[1]{
    \includegraphics[width=28.8mm]{img#1v1} \> \includegraphics[width=57.6mm]{img#1v2} \> \includegraphics[width=57.6mm]{img#1v3} \\[3mm]
}

\begin{tabbing}
    \hspace{31.8mm} \= \hspace{60.6mm} \= \kill
    \compimg{1}
    \compimg{2}
    \compimg{3}
    % ...
\end{tabbing}

This works pretty well and the sizes and spacing (3mm between all the images) is perfect.

Now, I'd like the images to be vertically centered on each page. I guess I'll have to use a float, but I couldn't get it to work without at least messing up my vertical spacing.

How can I center the images on each page without losing the consistent spacing? Any help is appreciated.


Update

Since all my graphics have a fixed width, I can get along with \hspace{3mm} instead of the tabbing environment. That doesn't solve my problem, but maybe makes it easier.

3
  • If you force your figures to be on the exact same place on every page you are cancelling the "floating" feature. This might bring you underfull vertical space. Aug 9, 2013 at 6:35
  • What exactly do you mean by vertically centered on each page? With respect to one another, or with the entire page? Do you have nothing else but these figures on a page?
    – Werner
    Aug 13, 2013 at 6:46
  • I want to have as many figures as possible on each page, with an even vertical spacing of 3mm between them, vertically center on the page (not evenly spaced out on the page). There is nothing else but the figures. Sorry if my question was a bit unclear, a sketch might have helped..
    – Daerst
    Aug 15, 2013 at 6:16

3 Answers 3

5

It isn't quite clear what spacing you want (in particular do you want all the image rows to be clumped together in the centre, or do you want them spaced out).

I would use something like

\newcommand{\compimg}[1]{%
 \par
 \includegraphics[width=28.8mm]{img#1v1}%
 \hspace{3mm}%
 \includegraphics[width=57.6mm]{img#1v2}%
 \hspace{3mm}%
 \includegraphics[width=57.6mm]{img#1v3}%
 \par
}

Then

\vspace*{\fill}
\compimg{1}
\vspace*{\fill}
\compimg{2}
\vspace*{\fill}
\compimg{3}
\vspace*{\fill}

or

\vspace*{\fill}
\compimg{1}
\compimg{2}
\compimg{3}
\vspace*{\fill}

depending...

}


based on comments below, I think actually you want this:

\documentclass{article}
\addtolength\textwidth{100pt}
\addtolength\oddsidemargin{-50pt}

\usepackage[demo]{graphicx}

\newcommand{\compimg}[1]{%
 \par
 \includegraphics[width=28.8mm]{img#1v1}%
 \hspace{3mm}%
 \includegraphics[width=57.6mm]{img#1v2}%
 \hspace{3mm}%
 \includegraphics[width=57.6mm]{img#1v3}%
 \par
}

\begin{document}

\setlength\parskip{3mm}
\makeatletter
\newcommand\@texttop{\vfill}
\renewcommand\@textbottom{\vfill}
\makeatother


\compimg{1}
\compimg{2}
\compimg{3}
\compimg{4}
\compimg{5}
\compimg{6}
\compimg{7}
\end{document}

enter image description here

3
  • I was looking for images "clumped" together with a vertical distance of 3mm. On each page, vertically centered, as much pictures as possible. Your second solution does this, but not dynamically. This works for me, but in the sense of the questions, a solution that dynamically distributes the images to pages would be great.
    – Daerst
    Aug 14, 2013 at 12:45
  • @Daerst it would not have been possible to guess that requirement from the question as written:-) I'll update answer to fit. Aug 14, 2013 at 12:55
  • David, thanks for the answer. Sorry if my question was unclear. Glad you figured it out anyway! Thanks!
    – Daerst
    Aug 15, 2013 at 6:20
2

If your are sure that each series of 3 pictures fits on line, you could try something like this:

\newcommand{\compimg}[1]{%
  \hbox to\hsize{%
    \hfill
    \hbox to 28.8mm{v1\hfil#1\hfil v1}%
    \hskip 3mm
    \hbox to 57.6mm{v2\hfil#1\hfil v2}%
    \hskip 3mm
    \hbox to 28.8mm{v3\hfil#1\hfil v3}%
    \hfill
  }%
}%

Here is a sample use:

\begin{figure}
\compimg{a}
\compimg{b2b}
\compimg{c}
\end{figure}

Of course, you need to replace the various hboxes with your includegraphics command.

I do not know the tabbing environment, so I am not sure if you want your figures in a floating environment or not. If you do, then the example is fine, if you do not, you will have to remove the figure and put your compimg calls in a separate paragraph.

I also probably should warn you that my solution is very low-level, I am more a TeX user as a LaTeX one! Maybe someone will come up with a more LaTeX-idiomatic answer, in the meanwhile, maybe mine will help you!

3
  • This doesn't address the vertical spacing requested. Aug 13, 2013 at 18:16
  • I understood the question as if the horizontal spacing between pictures were mangled up when the OP tried to vertically center its pictures. Now it is does not seem so obvious to me, what his problem actually is. Aug 14, 2013 at 8:54
  • I'm not sure what the problem is either but I'm sure the solution will involve a command with a v in its name:-) Aug 14, 2013 at 9:06
2

Another option based in raster library and \tcbincludegraphics command from tcolorbox. Within a tcbraster environment you can select how many columns has it, the distance between rows and columns and the style applied to all tcolorboxes included in it. Next code shows two example, one with the default style for tcolorbox which add some space and frame to each included figure and a second one with blank style which only includes the figure without frame and space around it.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{mwe}

\begin{document}
\vspace*{\fill}
\noindent
\begin{tcbraster}[raster columns=3, raster equal height, raster column skip=3mm, raster row skip=3mm]
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image-b}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image-b}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image}
\end{tcbraster}
\vspace*{\fill}
\newpage

\vspace*{\fill}
\noindent
\begin{tcbraster}[raster columns=3, raster equal height, raster column skip=3mm, raster row skip=3mm, raster every box/.style={blank}]
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image-b}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image-b}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image}
\end{tcbraster}
\vspace*{\fill}
\end{document}

enter image description here

You must log in to answer this question.

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