将两个图形一个放在另一个上面,并让它们及其标题放在同一页上。理想情况下,图形将适合整个页面

将两个图形一个放在另一个上面,并让它们及其标题放在同一页上。理想情况下,图形将适合整个页面

有没有办法让我文档中包含的两个图放在同一页上

到目前为止我看到以下内容:

在此处输入图片描述

到目前为止我写的代码是这样的:

\begin{figure}
    \centering
    \includegraphics[width = \textwidth]{W.png}
    \caption{ ksd fxk sdkjf nksdzkulvskjzvlkzxsdlvsdlj. sdflkjznscfv dlk jnvl dfzlvxjkcnlk vndflkj. jnskjlnsdljkfn klkjsndflkjnsddlfk fsklj fklsjdnz flkjzskl sdlkj fnzsdkjlfnlksjznf lkjsdznfjkndflzxkj nlky}
    \label{fig:W}
\end{figure}


\begin{figure}
    \centering
    \includegraphics[width = \textwidth]{U.png}
    \caption{ksd fxk sdkjf nksdzkulvskjzvlkzxsdlvsdlj. sdflkjznscfv dlk jnvl dfzlvxjkcnlk vndflkj. jnskjlnsdljkfn klkjsndflkjnsddlfk fsklj fklsjdnz flkjzskl sdlkj fnzsdkjlfnlksjznf lkjsdznfjkndflzxkj nlky \cite{halle1981ionization}. }
    \label{fig:U}
\end{figure}

我在标题中写了一些无意义的内容,因为我稍后会对其进行编辑。

理想情况下,我希望强制 overleaf 将两个图放在一页上,并且两个图及其标题的组合应填满整个页面。有办法吗?

答案1

这会将两个图像缩放到相同的宽度,以便使其适合可用空间。

\documentclass{article}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{pgfmath}

\begin{document}
\begin{figure}[p]
    \setbox0=\vbox{\caption{ ksd fxk sdkjf nksdzkulvskjzvlkzxsdlvsdlj. sdflkjznscfv dlk jnvl dfzlvxjkcnlk vndflkj. jnskjlnsdljkfn klkjsndflkjnsddlfk fsklj fklsjdnz flkjzskl sdlkj fnzsdkjlfnlksjznf lkjsdznfjkndflzxkj nlky}\label{fig:W}}% labels should go inside saveboxes (local \@currentlabel)
    \setbox1=\vbox{\caption{ksd fxk sdkjf nksdzkulvskjzvlkzxsdlvsdlj. sdflkjznscfv dlk jnvl dfzlvxjkcnlk vndflkj. jnskjlnsdljkfn klkjsndflkjnsddlfk fsklj fklsjdnz flkjzskl sdlkj fnzsdkjlfnlksjznf lkjsdznfjkndflzxkj nlky \cite{halle1981ionization}. }\label{fig:U}}%
    \setbox2=\vbox{\includegraphics[width = \textwidth]{example-image-a}
      \includegraphics[width = \textwidth]{example-image-b}}%
    \edef\temp{\the\dimexpr \textheight-\floatsep-\ht0-\dp0-\ht1-\dp1}% available height
    \ifdim \ht2<\temp 
      \def\scale{1.0}%
    \else
      \pgfmathsetmacro{\scale}{\temp/\ht2}% cannot use \dimen0
    \fi
    \centering
    \includegraphics[width = \scale\textwidth]{example-image-a}
    \unvbox0
    \vskip\floatsep
    \includegraphics[width = \scale\textwidth]{example-image-b}
    \unvbox1
\end{figure}
\end{document}

演示

相关内容