如何将两个图形堆叠在一起,而不是并排堆叠?

如何将两个图形堆叠在一起,而不是并排堆叠?

我希望我的图形一个接一个地排列,而不是一个挨着一个,这样它们就会更大,并沿着页面宽度分布。我该怎么做呢?这是我的代码:

\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}

答案1

由于您希望使两个图形更大,您可以 (a) 增加两个subfigure环境的宽度,例如,0.75\textwidth以及 (b) 将图形的宽度设置为1\linewidth,即设置为封闭subfigure环境的整个宽度。 LaTeX 会自动在两个子图之间插入换行符。

两个图形堆叠在一起的示例

\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}

答案2

提供了其他选项这里

\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}

答案3

只需在子图之间添加‘\\’。

\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

subfigure 包现在已弃用子图可以代替使用。使用方法如下:

\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}

相关内容