# How can I remove all space between two images with a global option?

I want to include several images just below each other without vertical space. How can I do this by adding some code to the preamble (i.e. I want this setting globally). Consider the following example:

\documentclass{article}

\usepackage[demo]{graphicx}
\begin{document}

\includegraphics{image1}

\includegraphics{image2}

\includegraphics{image3}

%% and a lot more images

\end{document}


Output:

You see there is a little bit vertical space bewtween the pictures. But I want to have no vertical space at all.

• Without vertical image? You mean vertical space? – user31729 Sep 7 '15 at 17:03

Between lines is an additional \interlineskip. You have to kill this with \offinterlineskip, within a group.

\documentclass{article}

\usepackage[demo]{graphicx}
\begin{document}

\begingroup
\offinterlineskip
\includegraphics{image1}

\includegraphics{image2}

\includegraphics{image3}

\endgroup

\includegraphics{image4}

\includegraphics{image5}

\end{document}


Please note: The PDF viewer might show glued lower images too, but this is an PDF viewer issue!. The lower ones are separated!

Here, I just use a \Shortstack with 0pt stacking gap. Default alignment of the stack is centered, but that can be set with \def\stackalignment{<l,c, or r>}.

Being a stack, each set of stacked images must fit on a single page.

\documentclass{article}
\usepackage{stackengine}
\setstackgap{S}{0pt}
\usepackage[demo]{graphicx}
\begin{document}
\Shortstack{
\includegraphics[width=1in]{image1}
\includegraphics{image2}
\includegraphics[width=2cm]{image3}
}
%% and a lot more images

\end{document}