2

I have created a 3x3 matrix of figures as follow:

\begin{figure} 
\begin{tabular}{ccc}
\includegraphics[scale=0.2]{my_figure}    & 
\includegraphics[scale=0.2]{my_figure}   & 
\includegraphics[scale=0.2]{my_figure}  \\ 
\includegraphics[scale=0.2]{my_figure}   & 
\includegraphics[scale=0.2]{my_figure}  & 
\includegraphics[scale=0.2]{my_figure} \\ 
\includegraphics[scale=0.2]{my_figure}    &  
\includegraphics[scale=0.2]{my_figure}    &  
\includegraphics[scale=0.2]{my_figure}   \\ 
\end{tabular}
\caption{Many figures}
\end{figure}

How can I reduce or leave no space among them?

9
  • \begin{figure}\tabcolsep=0pt\renewcommand*{\arraystretch}{0}
    – LaRiFaRi
    Jul 28, 2015 at 9:03
  • @LaRiFaRi Thanks but didn't work.
    – DimKoim
    Jul 28, 2015 at 9:07
  • 1
    Then please make your code compilable. Show us a minimal example of what you have. My approach works perfectly for me in article.
    – LaRiFaRi
    Jul 28, 2015 at 9:07
  • "Didn't work" is nothing we can work with. What does not work, the rows, the columns, both, getting an error...?
    – LaRiFaRi
    Jul 28, 2015 at 9:08
  • It is part of my thesis and the template is from the university so I cannot specify the document class . It didn't reduce the space, both between the rows and columns, no errors though.
    – DimKoim
    Jul 28, 2015 at 9:12

1 Answer 1

3

As LaRiFaRi suggested \newcommand*{\arraystretch}{0} supresses space between rows and @{} between columns.

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\begin{figure} 
\centering
\renewcommand*{\arraystretch}{0}
\begin{tabular}{*{3}{@{}c}@{}}
\includegraphics[scale=0.2]{example-image}    & 
\includegraphics[scale=0.2]{example-image}   & 
\includegraphics[scale=0.2]{example-image}  \\
\includegraphics[scale=0.2]{example-image}   & 
\includegraphics[scale=0.2]{example-image}  & 
\includegraphics[scale=0.2]{example-image} \\
\includegraphics[scale=0.2]{example-image}    &  
\includegraphics[scale=0.2]{example-image}    &  
\includegraphics[scale=0.2]{example-image}   
\end{tabular}
\caption{Many figures}
\end{figure}
\end{document}

enter image description here

2nd option: with raster library from tcolorbox

raster library allows you to arrange several boxes in a regular way. By default, every row occupies the whole line width and tcolorbox calculates inner tcolorboxes size.

Instead of \includegraphics you must use \tcbincludegraphics because raster environment expects tcolorboxes. tcolorbox options can be used: title, colors, etc. and also special options to \includegrahics command can be indicated with graphics={...}. You can also decide distance between rows and columns.

The code for this particular case could be:

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

\begin{document}
\begin{figure}
\centering
\begin{tcbraster}[raster columns=3, raster equal height, 
raster column skip=0pt, raster row skip=0pt, raster every box/.style={blank}]
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\tcbincludegraphics{example-image}
\end{tcbraster}
\caption{Many figures}
\end{figure}
\end{document}

enter image description here

4
  • 2
    I'd use \begin{tabular}*{3}{@{}c}@{}} for suppressing also the trailing padding; otherwise the centering is not correct.
    – egreg
    Jul 28, 2015 at 9:57
  • Your approach is working great in the document classes of latex. However, because I am writing my thesis in a template of my university (I share the link in a comment), I have incompatibility problems. It runs but doesn't give any result.
    – DimKoim
    Jul 28, 2015 at 11:58
  • @DimKoim I've opened your zip file, included all *.sty, *.cls files inside /kulemnt/doc/template folder, inserted my example from \begin{figure} to \end{figure} between two \include{...} lines in thesis.tex and everything worked as expected. Unless you provide some more information we cannot help you.
    – Ignasi
    Jul 28, 2015 at 12:08
  • I dunno what's the problem with my template but your answer is more than correct. No, I don't have any more info to provide. Thanks a lot.
    – DimKoim
    Jul 28, 2015 at 12:17

You must log in to answer this question.

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