This works for me:
\documentclass{article}
\usepackage{amsmath}
\newcounter{eqn}
\renewcommand*{\theeqn}{\alph{eqn})}
\newcommand{\num}{\refstepcounter{eqn}\text{\theeqn}\;}
\makeatletter
\newcommand{\putindeepbox}[2][0.7\baselineskip]{{%
\setbox0=\hbox{#2}%
\setbox0=\vbox{\noindent\hsize=\wd0\unhbox0}
\@tempdima=\dp0
\advance\@tempdima by \ht0
\advance\@tempdima by -#1\relax
\dp0=\@tempdima
\ht0=#1\relax
\box0
}}
\makeatother
\usepackage[demo]{graphicx}
% \setlength{\tabcolsep}{0pt}
\begin{document}
\begin{tabular}{cc}
\num\putindeepbox[7pt]{\includegraphics{whatever.jpg}}
& \num\putindeepbox[7pt]{\includegraphics{whatever.jpg}} \\
\num\putindeepbox[7pt]{\includegraphics{whatever.jpg}}
& \num\putindeepbox[7pt]{\includegraphics{whatever.jpg}} \\
\end{tabular}
\end{document}
(Edited to include pseudo-captions; the macro \putindeepbox
takes something and puts it into a box of height equal to 0.7\baselineskip
by default (i.e., the height of a \strut
) and deep enough to accomodate for the given material. Somehow in tabular
\baselineskip
gets reset to zero, so I've hardcoded the height manually. Not very elegant, but works - feel free to improve it;). Notice also some dirty tricks with boxes - hopefully someone will find a cleaner way to do it. I hope that this is what you wanted, and that it is not too late... See also comments below to make spacing better.)
The spacing is not perfect; you can manipulate the horizontal spacing with tabcolsep
, AFAIK there is no such parameter for vertical spacing in tabular.
Ok, there is my answer.
The idea is to make a loop which uses \includegraphics
to output each page of the pdf, at 45% of the line width (assuming that you want two pages per row, which seems sensible). The tricky part is to consider the case of an odd number of pages. In this case, the last row contains a single page, so it would be nicer if that page is centered.
The following code does that.
\documentclass[12pt]{book}
\usepackage[a4paper,margin=25mm,showframe=false]{geometry}
\usepackage{graphicx}
\usepackage{listings}
\input{repeat}
\lstset{ %
frame=single,
language=tex, % the language of the code
numbers=left, % where to put the line-numbers
numberstyle=\scriptsize, % the size of the fonts that are used for the line-numbers
basicstyle=\ttfamily\scriptsize, % font and size of the code
showspaces=false, % show spaces adding particular underscores
showstringspaces=false, % underline spaces within strings
showtabs=false, % show tabs within strings adding particular underscores
tabsize=4, % sets default tabsize to 4 spaces
breaklines=false, % sets automatic line breaking
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
}
\def\IncludeOutput#1{
\parskip=2mm
\def\examplename{#1}
\pdfximage{\Directory/\examplename.pdf}%
\edef\lastpdfpage{\the\pdflastximagepages}
\repeat\for{pag}\by{0} % We advance manually the counter in the loop body
\until{\ifnum\pag>\lastpdfpage}
\do{
\noindent\hfill\fbox{%
\includegraphics[width=0.45\textwidth,page=\number\pag]{\Directory/\examplename.pdf}}%
\hfill%
\advance\pag by 1
\ifnum\pag>\lastpdfpage\hfill\par% If odd number of pages
\else% If even number of pages, output the last one
\fbox{%
\includegraphics[width=.45\textwidth,page=\number\pag]{\Directory/\examplename.pdf}}%
\hfill\hbox{}\par % Next pair of images
\fi%
\advance\pag by 1
}
}
\begin{document}
\def\Directory{Examples}
\lstinputlisting{\Directory/Lipsum.tex}
\IncludeOutput{Lipsum}
And more text follows\dots
\end{document}
An this is the result:
In case the text is unreadable, the content of Lipsum.tex
is:
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\title{Lorem Ipsum}
\maketitle
% This inserts paragraphs 1 to 35 of ``Lorem Ipsum'' which produces 7 pages
\lipsum[1-35]
\end{document}
And you can download the resulting pdf here
Best Answer
your question is not very clear and seems to be duplicate to many similar question here. You need to put some small effort in search this site ... anyway, you can start with the following approach:
addendum: in the case, that name of images' files are 1, 2, ... 396 and you like to present them in 33 groups of 12 images (33 x 12 = 396) per figure organised in array 3 x 4 images you can make above example shorter with use two loops: