Graphics, Figures & Tablesproblem with space between figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
deea
Posts: 4
Joined: Fri Jun 02, 2017 6:15 am

problem with space between figures

Post by deea »

I want to insert 4 figures in the same line, but the space between the figures becomes too big. How can I reduce it? Please, could somebody offer some solutions?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

problem with space between figures

Post by Stefan Kottwitz »

Welcome to the forum!

It depends on how you are doing it. If you end the line or the paragraph normally, LaTeX doesn't insert additional space. If you let LaTeX justify left and right margin, LaTeX can insert space to fully fill the page width. Or do you use a package such as subfigure, subfig, or subcaption, or use minipage or \parbox for positioning?

Please post your code, otherwise we cannot say what produces that space.

Stefan
LaTeX.org admin
deea
Posts: 4
Joined: Fri Jun 02, 2017 6:15 am

problem with space between figures

Post by deea »

Hy Stefan, thanks for the welcome message,
my code was the following:

Code: Select all

\documentclass[nopreprint,times,3p,final]{elsarticle}

\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
\usepackage{graphicx,subcaption}
\usepackage{epsf}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{float}
\usepackage{subfig}
\usepackage{booktabs}
\usepackage{subcaption}


\begin{document}

\begin{figure}[htbp]
\centering
\begin{subfigure}{.3\textwidth}
  \centering
  \includegraphics[width=.5\linewidth]{1sz500AvgBySizeUj.eps}
  \caption{}
  \label{fig:q000001}
  \quad
  \quad
  \end{subfigure} %
\begin{subfigure}{.3\textwidth}
  \centering
  \includegraphics[width=.5\linewidth]{2sz500AvgBySizeUj.eps}
  \caption{}
  \label{fig:q11}
  \quad
  \quad
  \end{subfigure}%
\begin{subfigure}{.3\textwidth}
  \centering
  \includegraphics[width=.5\linewidth, angle=270]{3sz500AvgBySizeUj.eps}
  \caption{}
  \label{fig:q21}
  \quad
  \quad
  \end{subfigure}%
\begin{subfigure}{.3\textwidth}
  \centering
  \includegraphics[width=.4\linewidth, angle=270]{4sz500AvgBySizeUj.eps}
  \caption{}
  \label{fig:q31}
  \quad
  \quad
  \end{subfigure}
\begin{subfigure}{.3\textwidth}
  \centering
    \includegraphics[width=.5\linewidth]{41sz500Avg5.eps}
    \caption{}
    \label{fig:q411}
    \quad
    \quad
  \end{subfigure}%
\begin{subfigure}{.3\textwidth}
  \centering
    \includegraphics[width=.5\linewidth]{42sz500Avg5.eps}
    \caption{}
    \label{fig:q4211}
    \quad
    \quad
  \end{subfigure}%
\begin{subfigure}{.3\textwidth}
  \centering
    \includegraphics[width=.5\linewidth]{43sz500Avg5.eps}
    \caption{}
    \label{fig:q4311}
    \quad
    \quad
  \end{subfigure}%
\begin{subfigure}{.3\textwidth}
  \centering
    \includegraphics[width=.5\linewidth]{44sz500Avg5.eps}
    \caption{}
    \label{fig:q4411}
    \quad
    \quad
  \end{subfigure}
\caption{Distribution from $q=0.000001$ to $q=0.44$}
\label{fig:q000001q44}
\end{figure} 

\end{document}
I tried with subcaption as well, with the code:

Code: Select all

\begin{figure}
\centering
\subcaptionbox{q=0.1}{\includegraphics[width=0.20\textwidth]{1sz500AvgBySizeUj.eps}}%
\label{fig:q1}
\hfill
\subcaptionbox{q=0.2}{\includegraphics[width=0.20\textwidth]{2sz500AvgBySizeUj.eps}}%
\label{fig:q2}
\hfill
\subcaptionbox{q=0.3}{\includegraphics[width=0.20\textwidth, angle=270]{3sz500AvgBySizeUj.eps}}%
\label{fig:q3}
\hfill
\subcaptionbox{q=0.4}{\includegraphics[width=0.20\textwidth, angle=270]{4sz500AvgBySizeUj.eps}}%
\label{fig:q4}
\caption{Distribution from $q=0.1$ to $q=0.4$}
\end{figure}
With subcaption it was better, there wasn't so much space between figures, but I couldn't put 8 figures there in two lines, only 4 in one line.

I want to put litle figures, 4 in a line and more lines, in some places I have to insert 8, 12 or 16 figures, so 2,3 or for lines are needed.

Thanks a lot,
Virag
Last edited by Stefan Kottwitz on Fri Jun 02, 2017 6:37 pm, edited 1 time in total.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

problem with space between figures

Post by Johannes_B »

Welcome, using subcaption, use \par when you want to jump to the next line. It introduces a new paragraph.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
deea
Posts: 4
Joined: Fri Jun 02, 2017 6:15 am

problem with space between figures

Post by deea »

Thanks, with \par I have got figures in more lines, but I got in package also two other problems, the labels can't be seen totally, even if I inserted 4 \quad rows and the other problem that appeared, that even if the figures are the same size, the first row is longer than the others.
Virag
Post Reply