我有一个非常大的(高度方面)图形,想把它和标题一起放在一个页面上,标题放在下面(我想保留文档宽度样式,而且图形无论如何都会填满线条,所以把标题放在侧面不是一个解决方案)。有没有办法缩放图形以适合带有标题的页面?(我知道 scalebox,但我想避免缩放标题文本)。
\documentclass{report}
\usepackage{floatrow}
\usepackage[demo]{graphicx}
\floatsetup{style=ruled, footposition=caption, capposition=bottom, heightadjust=object}
\begin{document}
\begin{figure}
\includegraphics[height=1.2\textheight]{dummy}
\caption{this should be in text}
\end{figure}
\end{document}
答案1
您可以计算出浮动样式占用了多少空间并进行相应的调整,或者您也可以让乳胶为您完成这项工作。
如果你使用
\includegraphics[height=\dimexpr\textheight\relax]{dummy}
LaTeX 报告
LaTeX Warning: Float too large for page by 22.2pt on input line 9.
所以如果你使用
\includegraphics[height=\dimexpr\textheight-22.2pt\relax]{dummy}
很开心。
答案2
使用 LaTeX 自动计算高度,并适当缩放图像:
\documentclass{report}
\usepackage{floatrow}
\usepackage[demo]{graphicx}
\usepackage{calc}
\usepackage{fp}
\floatsetup{style=ruled, footposition=caption, capposition=bottom, heightadjust=object}
\begin{document}
\begin{figure}
\newlength{\spacearoundfigures} % It should be possible to calculate this value
\setlength{\spacearoundfigures}{124pt} % Include \abovecaptionskip and \belowcaptionskip\
\newsavebox{\figurebox}
\savebox{\figurebox}{\includegraphics[height=1.2\textheight]{dummy}}
\newsavebox{\captionbox}
\savebox{\captionbox}{this should be in text}% N.B. only works for one-line captions add code to allow line breaking and limit width to \textwidth less figure horizontal space
\newlength{\cbh}
\settototalheight{\cbh}{\usebox{\captionbox}}
\newlength{\fbh}
\setlength{\fbh}{\textheight}
\addtolength{\fbh}{-\cbh}
\makeatletter\FPdiv\result{\strip@pt\fbh}{\strip@pt\textheight}\makeatother
\scalebox{\result}{\usebox{\figurebox}}
\caption{\usebox{\captionbox}}
\end{figure}
\end{document}