0

Is there a way to make the two figures that I have included in my document to be placed on the same page

So far I see the following:

enter image description here

The code I have written so far is this:

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

I put nonsense in the captions because I will edit it later.

Ideally I would like to force overleaf to place the two figures on one page and the two figures combined with their captions should fill the entire page. Is there a way to do this?

Bernard
  • 271,350
DJA
  • 167

1 Answers1

1

This scales both images to the same width so as to fit them into the available space.

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

demo

John Kormylo
  • 79,712
  • 3
  • 50
  • 120