# Flush stacked rotated images

I have a series of images that I would like to line up horizontialy, all scaled to a given height, rotated 90 degrees and exactly flush with respect to each other. For example:

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

\setlength\parindent{0pt}      % Remove all indents
\pagestyle{empty}              % Empty pagestyle

\newcommand{\tallbox}[1]{%
\resizebox{!}{6cm}{ %
\includegraphics[angle=90]{#1}  %
} %
}

\begin{document}%
\tallbox{gen/2354942681964301350.pdf}%
\tallbox{gen/3719368526636490760.pdf}%
\tallbox{gen/4072051681301936821.pdf}%
\end{document}


This gives:

I cannot figure out how to automatically remove the spacing between the graphics. Any combination of negative \hspace seems to fail when the height is changed. I've tried changing the lengths:

\setlength{\textfloatsep}{0pt}
\setlength{\intextsep}{0pt}
\setlength{\floatsep}{0pt}
\setlength{\itemsep}{0pt}


But none of these seem to change the particular spacing I'm looking for.

-
don't use spaces between } % in your definition. –  Herbert Jul 5 '12 at 14:22
Note that such transformations can also be easily done with the adjustbox package. –  Martin Scharrer Jul 5 '12 at 14:23
@MartinScharrer Tobi/Herbert just solved it (and I'll accept once I can) but could you show an example with adjustbox? I think having that knowledge might be useful for more fine-grained questions. –  Hooked Jul 5 '12 at 14:24

There are three superfluous spaces in the definition of \tallbox. Note that the % is the right way to omit additional spaces but if Tex reads …{6cm} % it sees the argument {6cm} followed by a space followed by a comment % since TeX reads strictly form left to right the % in this case only eats the line break (i.e. a space in the output) but not the preceding space. To omit this space to you must type % directly after the last character in a line, as you can see in the example below.

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

\setlength\parindent{0pt}      % Remove all indents
\pagestyle{empty}              % Empty pagestyle

\newcommand{\tallbox}[1]{%
\resizebox{!}{6cm}{% <----------
\includegraphics[angle=90]{#1}% <----------
}% <----------
}

\begin{document}%
\tallbox{gen/2354942681964301350.pdf}%
\tallbox{gen/3719368526636490760.pdf}%
\tallbox{gen/4072051681301936821.pdf}%
\end{document}


An other way to omit these spaces is to write the definition in a single line

\newcommand{\tallbox}[1]{\resizebox{!}{6cm}{\includegraphics[angle=90]{#1}}


I prefer and recommend the first way since it’s much more readable and it’s easier to find matching braces. I nearly always use the “more lines solution” except for simple text replacement, like

\newcommand{\TikZ}{Ti\textit{k}Z\xspace}

-
Thanks Tobi, I didn't even think that those spaces would count, I thought the % would eat them up. Is it better practice to put a small function like this on one line or use many %? –  Hooked Jul 5 '12 at 14:26
@Hooked: See my edit ;-) –  Tobi Jul 5 '12 at 15:12
@Hooked: The % "eats" all characters after it, but your spaces were before. In the given solution the % "eats" the end-of-line, which would be otherwise be considered as a space by tex. Note that after a commented-out end-of-line, all spaces are ignored until the first non-space. This allows for indentation of the next line. I think that multiple-line, properly indented code improves readability. You only have to be cautious with those pesky end-of-lines. –  JLDiaz Jul 5 '12 at 15:14