Graphics, Figures & Tablesarranging a lot of pictures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
avoyance
Posts: 13
Joined: Sun Feb 13, 2011 1:53 am

arranging a lot of pictures

Post by avoyance »

The principal of TeX is box arrangement, and there are glue/sping between boxes...etc.

Now I have a lot of pictures. Specifically, they looks like:

Code: Select all

\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-1}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-2}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-3}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-4}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-5}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-6}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-7}
\noindent\includegraphics[width=\textwidth, angle=0]{K11-6-8}
each picture is of different width/height but they ar all resized to the same width in the above instructions. Actually I don't mind if they are width=1.05\textwidth or width=0.95\textwidth and there can also have a little (vertical) space between figures
as long as they can automatically fit into one page or if there are many of them perhaps automatically breaks into suitable pages. I think this function is the same as TeX is doing for text font. But I don't know how to write it. Can anyone help me? Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

arranging a lot of pictures

Post by ignasi »

tcolorbox package provides a tcbraster environment which solves this problem. Author just need to include a list of images with \tcbincludegraphics command and tcolorbox will adjust their size and organize them into a rectangular array. It uses as many pages are needed to include all desired images.

Code: Select all

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

\begin{document}
\vspace*{\fill}
\noindent
\begin{tcbraster}[raster columns=2, 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}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image-a}
\end{tcbraster}
\vspace*{\fill}
\newpage

\vspace*{\fill}
\noindent
\begin{tcbraster}[raster columns=2, 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}
\tcbincludegraphics{example-image-c}
\tcbincludegraphics{example-image-a}
\tcbincludegraphics{example-image-a}
\end{tcbraster}
\vspace*{\fill}
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

arranging a lot of pictures

Post by Stefan Kottwitz »

Very good suggestion by ignasi! tcolorbox is avery capable package. I also use it. The raster library is a pretty new addition, so perhaps you may have to update your installed tcolorbox package version.

I also used tabular for arranging images. In such cases I used collcell for saving typing work and easier writing and reading of the code.

It looked like:

Code: Select all

\usepackage{collcell}
\newcommand{\includepic}[2]{\includegraphics[width=4cm,height=3cm,keepaspectratio]{#1}}
\newcolumntype{I}{@{\hspace{1ex}}>{\collectcell\includepic}c<{\endcollectcell}}
...
\begin{tabular}{III}
  flower  & bird    & man       \\
  stone   & water   & mountain  \\
  beach   & sheep   & butterfly
\end{tabular}
Stefan
LaTeX.org admin
avoyance
Posts: 13
Joined: Sun Feb 13, 2011 1:53 am

Re: arranging a lot of pictures

Post by avoyance »

I tried the suggestion by igbasi using tcolorbox.
But did not got what I want. Completely different.
Perhaps you mis-understood what I want.
I want somehow the system can automatically make small adjustment for the size of my picture so that they can fit into one page or so.

I am arranging many pictures of different size.
What I am using is simple inclugraphics....
Sometimes a picture cannot fit into the next space but simply move into the next page because of slight difference.
I have to experiment the size of them so that they fit into one page....
ignasi
Posts: 20
Joined: Tue Jul 28, 2009 5:10 pm

arranging a lot of pictures

Post by ignasi »

I'm not sure to understand the problem. If you know how many figures you want to place on a page and you know page space, you can adjust all figures to have an specific size in \includegraphics (or \tcbincludegrpahics) options.

In any case I've made some adjustments to previous code (I've include last `tcolorbox` version in overleaf project) which you can test in https://www.overleaf.com/2403315yyqfgs

Hope it helps
Post Reply