在此 MWE 中,我手动微调了图形的宽度(0.711082\linewidth
),以便在将整个文档放在一页上的同时最大化其尺寸。
\documentclass{article}
\usepackage{mwe}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[h]
\centering
\includegraphics[width=0.711082\linewidth]{example-image}
\end{figure}
\lipsum[2-3]
\end{document}
是否存在什么通用机制可以实现这样的目标?
答案1
说到缩放图像以适合剩余页面......(需要运行两次。)
\documentclass{article}
\usepackage{mwe}
\usepackage{lipsum}
\usepackage{tikzpagenodes}
\usepackage{showframe}
\newlength{\maxheight}
\newcommand{\maxgraphics}[1]% #1 = filename
{\settoheight{\maxheight}{\includegraphics[width=\columnwidth]{#1}}%
\tikz[remember picture]{% measuer distance to bottom of page
\dimendef\y=0% local definition
\pgfextracty{\y}{\pgfpointanchor{current page text area}{south}}%
\ifdim\y>-1pt \y=-1pt\fi
\ifdim\maxheight>-\y
\global\maxheight=-\y
\fi}\par\vspace{-\parskip}\vspace{-\baselineskip}\vfill% not on same baseline
\includegraphics[height=\maxheight]{#1}}
\begin{document}
\lipsum[1-3]
\begin{center}
\maxgraphics{example-image}
\end{center}
\lipsum[4]
\end{document}