22

I have hundreds of figures that I have arranged into 2x2 matrices using the \minipage environment like so:

\begin{figure}[ht] \label{ fig7} 
  \begin{minipage}[b]{0.5\linewidth}
    \includegraphics[width=.5\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_profile_0} 
    \caption{Initial condition} 
  \end{minipage} 
  \begin{minipage}[b]{0.5\linewidth}
    \includegraphics[width=.5\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_profile_Rup} 
    \caption{Rupture} 
  \end{minipage} 
  \begin{minipage}[b]{0.5\linewidth}
    \includegraphics[width=.5\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_dft_0_corner} 
    \caption{DFT, Initial condition} 
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.5\linewidth}
    \includegraphics[width=.5\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_dft_corner_Rup} 
    \caption{DFT, rupture} 
  \end{minipage} 
\end{figure}

I find that with this kind of an arrangement I have lots of white space after the figures. How should I ensure that I use all the "page real-estate" for my figures without too much white space?

I am really sorry that I can't seem to explain my problem any better.

enter image description here

How to avoid spilling of images into following page?

As per the comments, when I use \includegraphics[width=x\linewidth] with x>0.5, my images spill into the following page. I would like my table and image to be in the same page and have the images leave little white space:

Images moving to following page:

enter image description here

I would like this with lesser white space: enter image description here

Minimum working example:

\documentclass[draft,10pt]{article}

% \usepackage[ascii]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{caption}
% \usepackage{babel}
\usepackage{fontenc}
\usepackage{graphicx}
% \usepackage{tabular}

\begin{document}
 MWE:
\centering
\scriptsize
\begin{table}[h]
    \begin{tabular}{|p{5cm}|p{5cm}|}
\hline
        a & 1 \\ 
    a & 1 \\ 
b & 1 \\ 
c & 1 \\ 
d & 1 \\ 
e & 1 \\ 
f & 1 \\ 
g & 1 \\ 
h & 1 \\ 
i & 1 \\ 
    \hline
    \end{tabular}
\end{table}


\begin{figure}[h] \label{ fig7} \begin{minipage}[b]{0.50\linewidth}\centering\includegraphics[width=0.70\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_profile_0} \caption{Initial condition} \end{minipage} \begin{minipage}[b]{0.50\linewidth}\centering\includegraphics[width=0.70\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_profile_Rup} \caption{Rupture} \end{minipage} \begin{minipage}[b]{0.50\linewidth}\centering\includegraphics[width=0.70\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_dft_0_corner} \caption{DFT, Initial condition} \end{minipage}\hfill \begin{minipage}[b]{0.50\linewidth}\centering\includegraphics[width=0.70\linewidth]{/home/dnaneet/Research/Dissertation/wigner/Effect_of_domainSize_wavelength/G=0.333/dftdata/L_lambda_max_1wl_dft_corner_Rup} \caption{DFT, rupture} \end{minipage} \end{figure}

\end{document}
dearN
  • 2,760

2 Answers2

29

You could try putting \centering in the minipage. Adding some \vspace after the caption might be helpful too.

\documentclass{article}
\usepackage{graphicx}
\pagestyle{empty}
\begin{document}
\begin{figure}[ht] 
  \label{ fig7} 
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=.5\linewidth]{example-image-a} 
    \caption{Initial condition} 
    \vspace{4ex}
  \end{minipage}%%
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=.5\linewidth]{example-image-b} 
    \caption{Rupture} 
    \vspace{4ex}
  \end{minipage} 
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=.5\linewidth]{example-image-c} 
    \caption{DFT, Initial condition} 
    \vspace{4ex}
  \end{minipage}%% 
  \begin{minipage}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=.5\linewidth]{example-image} 
    \caption{DFT, rupture} 
    \vspace{4ex}
  \end{minipage} 
\end{figure}
\end{document}

enter image description here

Here is an example of using subcaptions packages to get subfigures within a larger figure environment:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\pagestyle{empty}
\begin{document}
\begin{figure}[ht] 
  \begin{subfigure}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=0.75\linewidth]{example-image-a} 
    \caption{Initial condition} 
    \label{fig7:a} 
    \vspace{4ex}
  \end{subfigure}%% 
  \begin{subfigure}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=0.75\linewidth]{example-image-b} 
    \caption{Rupture} 
    \label{fig7:b} 
    \vspace{4ex}
  \end{subfigure} 
  \begin{subfigure}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=0.75\linewidth]{example-image-c} 
    \caption{DFT, Initial condition} 
    \label{fig7:c} 
  \end{subfigure}%%
  \begin{subfigure}[b]{0.5\linewidth}
    \centering
    \includegraphics[width=0.75\linewidth]{example-image} 
    \caption{DFT, rupture} 
    \label{fig7:d} 
  \end{subfigure} 
  \caption{Illustration of various images}
  \label{fig7} 
\end{figure}

The illustrations in figure~\ref{fig7}\ldots but in figure~\ref{fig7:d} you see\ldots

\end{document}

enter image description here

A.Ellett
  • 50,533
  • Thank you! Is there some way I could make the figures larger but ensuring that they don't overflow into the next page? Some sort of "float" related trick? – dearN Aug 05 '13 at 16:02
  • @drN You can adjust the width in the argument to \includegraphics. Currently you have it set to 0.5\linewidth which is actually 0.25\textwidth since \linewidth is relative to currently effective \linewidth set by the minipage. – A.Ellett Aug 05 '13 at 16:08
  • Your code has a spurious blank space; also, there's a \label without \caption. – Gonzalo Medina Aug 05 '13 at 16:08
  • @A.Ellett Yes. But when I change 0.5 \linewidth to a larger multiple, my figures flow into the next page. – dearN Aug 05 '13 at 16:16
  • @GonzaloMedina Thank you, I hadn't noticed the \label. – A.Ellett Aug 05 '13 at 16:17
  • @drN To more fully understand how large you can make this images, it would be helpful to have a full working example that illustrates how the figure gets moved with larger figures. – A.Ellett Aug 05 '13 at 16:19
  • @drN Also, as GonzaloMedina points out, the \label as you placed it will not be effective. You'll either want to place a \label with each caption. Or if you just want to reference the group, you might want to consider using subfigures and subcaption. – A.Ellett Aug 05 '13 at 16:23
  • @GonzaloMedina I never realized that! Thank you! – dearN Aug 05 '13 at 16:26
  • @A.Ellett Just included an example of what I mean by "spilling of images into the following page" – dearN Aug 05 '13 at 17:02
  • What is the purpose of the %% ? – shadowhorst Apr 24 '15 at 12:13
  • @shadowhorst A % at the end of the line prevents unintended whitespace from creeping in. A single % would have sufficed. I've somehow gotten into the habit of doubling these because of how they appear in my editor and it also makes them a bit more easy to spot (particularly when it looks like whitespace has crept in where I don't want it and I'm trying to debug things). – A.Ellett Apr 24 '15 at 13:39
  • @A.Ellett is there a way to change the labels from (a), (b),... to (i), (ii),...? Thanks! – user217285 Apr 19 '16 at 18:11
  • @A.Ellett thoughts on the previous comment? – user217285 Apr 27 '16 at 23:48
  • @A.Ellett how about now? – user217285 May 05 '16 at 08:38
  • @Nitin I really haven't had time in my schedule to re-examine this. Perhaps you should post it as a question if you feel you need an answer to this soon. – A.Ellett May 05 '16 at 13:35
  • How to ensure that all four images are in the centre? it's working but all four images are towards the right side compare than left – Aaditya Ura Oct 03 '20 at 02:14
0
\frame{\frametitle{Methodology [Contd.]}
\begin{figure}[ht!]
     \begin{center}
%
        \subfigure{%
            \label{fig:first}
            \includegraphics[width=0.4\textwidth]{img3-fig1.png}
        }%
        \subfigure{%
           \label{fig:second}
           \includegraphics[width=0.4\textwidth]{img3-fig2.png}
        }\\ %  ------- End of the first row ----------------------%
        \subfigure{%
            \label{fig:third}
            \includegraphics[width=0.4\textwidth]{img3-fig3.png}
        }%
        \subfigure{%
            \label{fig:fourth}
            \includegraphics[width=0.4\textwidth]{img3-fig4.png}
        }%
%
    \end{center}
    \caption{%
        The distribution of IQ Score obtained for various students in context of different test given by an individual student.
     }%
   \label{fig:subfigures}
\end{figure}
}

enter image description here

  • Unfortunately your code snippet is not very useful, because it does not neither compile not show or explain, which packages are needed. Moreover it seems, you are using a completely different class. Note also, that the already existing answer already shows a suggestion in using sub-figures (with an environment provided by package subcaption instead of a command, provided by an unknown package or class). So can please explain the code you are showing and extend the code to a working example? – cabohah Nov 13 '23 at 08:49