# Make subfigures as big as possible

I have 6 figures putting them together in two lines (3 subfigure in each line). There are horizontal white spaces between subfigures (in each line). I am going to use those spaces to make the subfigures as large as possible (while keeping their aspect ration). My code is as follows,

\documentclass[conference]{IEEEtran}
\usepackage{algorithm, algpseudocode, dsfont, color, soul, tikz, amsmath, amssymb, amsfonts, amsthm, bbm, bbold, fixmath, mathtools, multirow, boldline, xcolor, colortbl, url, footnote, cite}
\begin{document}
\begin{figure*}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x2_RWD.pdf}
\end{subfigure}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x4_RWD.pdf}
\end{subfigure}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x7_RWD.pdf}
\end{subfigure}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x2_NRD.pdf}
\end{subfigure}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x4_NRD.pdf}
\end{subfigure}
\begin{subfigure}[t]{0.33\linewidth}
\includegraphics[width=\linewidth, height=\textheight, keepaspectratio]{x7_NRD.pdf}
\end{subfigure}
\end{figure*}
\end{document}

• please, provide complete but small document beginning with \documentclass{...} and ending with \end{document}. six images (three in line) with heights equal to text height you can't put on one page! welcome to tex.se! – Zarko Apr 26 '18 at 17:56

Since you're not exploiting any of the special features of subfigure environments -- such as the ability to set captions and to insert labels for cross-referencing purposes, you might as well use plain minipage environments.

(In the code below, if you do need to provide \caption and \label statements, simply change all instances of \begin{minipage} and \end{minipage} back to \begin{subfigure} and \end{subfigure}, resp. Of course, be sure to load the subcaption package as well.)

To maximize the possible horizontal separation between adjacent graphs, insert \hfill (or \hspace{\fill}) directives between the minipage/subcaption environments.

\documentclass[twocolumn]{article}
\usepackage[demo]{graphicx} % omit 'demo' option in real doc.
\begin{document}
\begin{figure*}
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x2_RWD.pdf}
\end{minipage}\hfill
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x4_RWD.pdf}
\end{minipage}\hfill
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x7_RWD.pdf}
\end{minipage}

%% leaving a blank line is deliberate, to tell TeX that a line break needs to occur
\medskip
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x2_NRD.pdf}
\end{minipage}\hfill
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x4_NRD.pdf}
\end{minipage}\hfill
\begin{minipage}[t]{0.325\linewidth}
\includegraphics[width=\linewidth]{x7_NRD.pdf}
\end{minipage}
\end{figure*}
\end{document}


Addendum, posted after the OP provided additional information, in a comment, about the document class and packages he/she employs. About those packages: (a) fixmath should only be loaded if Computer Modern fonts are in use -- which is not the case here. (b) xcolor and colortbl should not be loaded independently. (c) Some packages you load automatically load some other packages; hence, there's no need to load the color, amsmath, and amsfonts packages explicitly. (d) Since all graphs have the same height, the [t] position specifiers may be omitted from the subcaption setups.

\documentclass[conference,demo]{IEEEtran} % omit 'demo' option in real doc.
\usepackage[table]{xcolor} % don't load 'colortbl' and 'xcolor' independently from each other
\usepackage[hyphens]{url} % no need to load 'url' without 'hyphens' option
\usepackage{algorithm, algpseudocode, soul,
tikz, mathtools, amssymb, amsthm,
multirow, footnote, cite, subcaption,
dsfont, bbm, bbold, boldline}

%% 'fixmath' should only be used if Computer Modern
%% fonts are in use -- which is not the case here

\begin{document}

\begin{figure*}
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x2_RWD.pdf}
\caption{\dots} \label{fig:a}
\end{subfigure}\hfill
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x4_RWD.pdf}
\caption{\dots} \label{fig:b}
\end{subfigure}\hfill
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x7_RWD.pdf}
\caption{\dots} \label{fig:c}
\end{subfigure}

%% Leaving a blank line is deliberate, to tell
%% LaTeX that a line break needs to occur

\medskip
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x2_NRD.pdf}
\caption{\dots} \label{fig:d}
\end{subfigure}\hfill
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x4_NRD.pdf}
\caption{\dots} \label{fig:e}
\end{subfigure}\hfill
\begin{subfigure}{0.325\linewidth}
\includegraphics[width=\linewidth]{x7_NRD.pdf}
\caption{\dots} \label{fig:f}
\end{subfigure}
\caption{Overall figure caption}
\label{fig:overall}
\end{figure*}
\end{document}

• but op declare images height equal to text height, what is not possible to fit in one page ... so i wait on his response on my comment :-( – Zarko Apr 26 '18 at 18:28
• @Zarko - OP also is setting keepaspectratio. Unless the pics are unusually tall (like height >> width), the natural width of the images is going to be the constraining factor for three side-by-side image. Thus, specifying height=textheight, keepaspectratio is redundant. Let's see if the OP speaks up and answers your question. – Mico Apr 26 '18 at 18:41
• And what do the minipages do? – egreg Apr 26 '18 at 21:34
• @egreg - The [t] position specifiers (carried over from the OP’s own code) will be useful if the graphs don’t all have the same heights. If, however, the three graphs in a given row all have the same heights, the minipage “wrappers” could (should!) be removed. – Mico Apr 26 '18 at 21:54
• @Mohammad - Please note that I've provided an addendum to incorporate the pieces of information you provided in a number of comments. – Mico Apr 27 '18 at 0:11

You need no subfigure environment, unless you want subcaptions.

Here the images are horizontally and vertically separated by the same white space, \lineskip.

\documentclass[twocolumn]{article}

\usepackage[demo]{graphicx} % demo because I don't have your files
\usepackage{lipsum} % for mock text

\newlength{\maxfigurewidth}

\begin{document}

\lipsum[1-3]

\begin{figure*}

\setlength{\maxfigurewidth}{\dimexpr(\textwidth-2\lineskip)/3}

\includegraphics[width=\maxfigurewidth]{x2_RWD.pdf}\hfil
\includegraphics[width=\maxfigurewidth]{x4_RWD.pdf}\hfil
\includegraphics[width=\maxfigurewidth]{x7_RWD.pdf}

\includegraphics[width=\maxfigurewidth]{x2_NRD.pdf}\hfil
\includegraphics[width=\maxfigurewidth]{x4_NRD.pdf}\hfil
\includegraphics[width=\maxfigurewidth]{x7_NRD.pdf}

\caption{Some global caption}\label{whatever}

\end{figure*}

\lipsum[1-12]

\end{document}


The \lineskip is inserted automatically between the two rows, we insert it manually (with \hfil) between the columns.

If you want no spacing, either between columns or between rows:

\begin{figure*}

\setlength{\maxfigurewidth}{\dimexpr\textwidth/3}

\includegraphics[width=\maxfigurewidth]{x2_RWD.pdf}%
\includegraphics[width=\maxfigurewidth]{x4_RWD.pdf}%
\includegraphics[width=\maxfigurewidth]{x7_RWD.pdf}

\nointerlineskip

\includegraphics[width=\maxfigurewidth]{x2_NRD.pdf}%
\includegraphics[width=\maxfigurewidth]{x4_NRD.pdf}%
\includegraphics[width=\maxfigurewidth]{x7_NRD.pdf}

\caption{Some global caption}\label{whatever}

\end{figure*}


With subcaptions:

\documentclass[twocolumn]{article}

\usepackage{subcaption}
\usepackage[demo]{graphicx} % demo because I don't have your files
\usepackage{lipsum} % for mock text

\newlength{\maxfigurewidth}

\begin{document}

\lipsum[1-3]

\begin{figure*}

\setlength{\maxfigurewidth}{\dimexpr(\textwidth-2em)/3}

\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x2_RWD.pdf}
\caption{one}
\end{subfigure}\hfil
\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x4_RWD.pdf}%
\caption{two}
\end{subfigure}\hfil
\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x7_RWD.pdf}
\caption{three}
\end{subfigure}

\medskip

\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x2_NRD.pdf}%
\caption{four}
\end{subfigure}\hfil
\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x4_NRD.pdf}%
\caption{five}
\end{subfigure}\hfil
\begin{subfigure}{\maxfigurewidth}
\includegraphics[width=\textwidth]{x7_NRD.pdf}
\caption{six}
\end{subfigure}

\caption{Some global caption}
\end{figure*}

\lipsum[1-12]

\end{document}


• Actually I need subcaptions, however; I haven't included that in my code. sorry! – Mohammad Apr 26 '18 at 22:05
• Excatly I need something like those blackboxes. But how can I use subfigure? – Mohammad Apr 26 '18 at 22:06
• @Mohammad I added the solution with subfigure – egreg Apr 26 '18 at 22:12