59

I'd like my figures to be one on top of the other, rather than next to each other, so that they are larger and spread along the page width. How do I do this? Here is my code:

\begin{figure}[H]
\centering
   \begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=0.8\textwidth]{Nvariousg1}
   \caption{}
   \label{fig:Ng1} 
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=0.8\textwidth]{Nvariousg2}
   \caption{}
   \label{fig:Ng2}
\end{subfigure}
\caption{(a) Numerical solutions for the small-time system with a constant-curvature body shape showing the scaled leading-order veritcal reaction force $N_0$ versus the scaled body mass $M$ for various values of $g$. Again, $I=M$ for definiteness and $A=0.7$. (b) As for (a) but over a wider range of values of $M,I$.}
\end{figure}

4 Answers4

74

Since you're looking to make the two graphs larger, you could (a) increase the widths of the two subfigure environments to, say, 0.75\textwidth and (b) set the widths of the graphs to 1\linewidth, i.e., to the full width of the enclosing subfigure environments. LaTeX will automatically insert a line break between the two subfigures.

Example of two figures stacked on top of each other

\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}  % remove 'demo' option for your real document

\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.55\textwidth}
   \includegraphics[width=1\linewidth]{Nvariousg1}
   \caption{}
   \label{fig:Ng1} 
\end{subfigure}

\begin{subfigure}[b]{0.55\textwidth}
   \includegraphics[width=1\linewidth]{Nvariousg2}
   \caption{}
   \label{fig:Ng2}
\end{subfigure}

\caption[Two numerical solutions]{(a) Numerical solutions for the small-time system 
with a constant-curvature body shape showing the scaled leading-order veritcal 
reaction force $N_0$ versus the scaled body mass $M$ for various values of $g$. 
Again, $I=M$ for definiteness and $A=0.7$. (b) As for (a) but over a wider range of 
values of $M,I$.}
\end{figure}
\end{document}
suriv
  • 103
Mico
  • 506,678
  • Seems like parts here are deprecated. 0.55 appears above/below the entire figure, so does a and b. – jibo Mar 19 '18 at 15:53
  • @jibo - I'm afraid I have no idea what you're talking about. For sure, I see no "0.55" appearing anywhere, and "(a)" and "(b)" show up right where they're supposed to show up, viz., below the respective graphs. Please clarify what you're experiencing – Mico Mar 19 '18 at 15:57
  • It's hard to explain without pictures. Running the demo code as you provided yielded no problems. However as soon as adding own picture files what I explained above appeared. There might be some compatibility issue with another package that I am using, don't know which though. I managed to solve the issue by using \subfloat instead of \begin{subfigure} – jibo Mar 19 '18 at 16:49
  • Are you maybe loading both subcaption and subfig (or subfigure)? If that’s the case, all bets are off. Load either subfig or subcaption, but not both. – Mico Mar 19 '18 at 17:01
  • 1
    Yes subfigure was loaded in addition to subcaption. That was what caused the troubles, so now it is working fine (just by disabling one of them). – jibo Mar 27 '18 at 11:59
  • 1
    @jibo - I'm glad you figured out the cause of the problem. By the way, the subfigure package is deprecated and shouldn't be used anymore. – Mico Mar 27 '18 at 21:30
6

An other option is provided here.

\documentclass[smallextended]{svjour3}
\usepackage{lipsum}% Just for this example
\usepackage{graphicx}
\begin{document}

See Figure~\ref{fig:myfig}(a) or~(b). \lipsum[1]

\begin{figure}
  \centering
  \begin{tabular}{@{}c@{}}
    \includegraphics[width=.7\linewidth,height=75pt]{example-image-a} \\[\abovecaptionskip]
    \small (a) An image
  \end{tabular}

  \vspace{\floatsep}

  \begin{tabular}{@{}c@{}}
    \includegraphics[width=.6\linewidth,height=100pt]{example-image-b} \\[\abovecaptionskip]
    \small (b) Another image
  \end{tabular}

  \caption{This is a figure caption}\label{fig:myfig}
\end{figure}

\lipsum[2]

\end{document}
Jo-
  • 221
5

Just add '\\' between the subfigures.

\begin{figure}[H]
\centering
   \begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=0.8\textwidth]{Nvariousg1}
   \caption{}
   \label{fig:Ng1} 
\end{subfigure}

\\

\begin{subfigure}[b]{0.3\textwidth}
   \includegraphics[width=0.8\textwidth]{Nvariousg2}
   \caption{}
   \label{fig:Ng2}
\end{subfigure}
\caption{(a) Numerical solutions for the small-time system with a constant-curvature body shape showing the scaled leading-order veritcal reaction force $N_0$ versus the scaled body mass $M$ for various values of $g$. Again, $I=M$ for definiteness and $A=0.7$. (b) As for (a) but over a wider range of values of $M,I$.}
\end{figure}
  • 4
    If you're introducing blank lines, that surely would introduce a break, meaning there's no need for \\. – Werner Nov 06 '18 at 00:52
5

The subfigure package is now deprecated. subfig can be used instead. Here is how to use it:

\documentclass{article}
\usepackage{subfig}
\usepackage[demo]{graphicx}  % remove 'demo' option for your real document

\begin{document} \begin{figure} \centering \subfloat[a][a]{\includegraphics{a.png} \label{fig:a}} \ \subfloat[b][b]{\includegraphics{b.png} \label{fig:b}} \caption{a + b} \label{fig:AB} \end{figure} \end{document}

Hagbard
  • 483