我希望将图形放在文档底部,使标题与底部边距对齐(即文本和边距之间没有空格)。这是 MWE:
\documentclass[12pt]{report}
\usepackage[top=1.0in,hmargin=1.25in,height=9.0in,letterpaper,showframe]{geometry}
\usepackage[document]{ragged2e}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage[labelfont=bf,justification=RaggedRight,singlelinecheck=off,%
labelsep=period]{caption}
\usepackage{duckuments}
\usepackage{blindtext}
\begin{document}
\RaggedRight
\doublespace
\chapter{Title of chapter}
\blindtext
\begin{figure}[b]
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is a caption that is very long for the figure and it should be aligned with the bottom margin}
\end{figure}
\blindtext
\blindtext
\begin{figure}[t]
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is the caption.}
\end{figure}
\end{document}
第一个图形设置在底部,但标题与边距不对齐(文本和边距之间有空格)。但是,顶部对齐的图形与边距对齐,因此我不想弄乱环境的填充figure
。
编辑:
这是屏幕截图,我画了红线(在编辑器上)来表示我所说的间距。
答案1
您可以使用\flushbottom
它来使页面的最后一行始终与打字区域的底部对齐。
请看代码:
\documentclass[12pt]{report}
\usepackage[top=1.0in,hmargin=1.25in,height=9.0in,letterpaper,showframe]{geometry}
\usepackage[document]{ragged2e}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage[%
labelfont=bf,
justification=RaggedRight,
singlelinecheck=off,%
labelsep=period
]{caption}
\usepackage{duckuments}
\usepackage{blindtext}
\begin{document}
\flushbottom % <========================================================
\RaggedRight
\doublespace
\chapter{Title of chapter}
\blindtext
\begin{figure}[b]
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is a caption that is very long for the figure and it should be aligned with the bottom margin}
\end{figure}
\blindtext
\blindtext
\begin{figure}[t]
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is the caption.}
\end{figure}
\end{document}
结果:
答案2
似乎当文本被拉伸以适合页面时,底部浮动会被拉起。因此,通过改为使用\textfloatsep
expand,可以防止这种情况发生。剩下的就是删除标题基线下方的空间。
\documentclass[12pt]{report}
\usepackage[top=1.0in,hmargin=1.25in,height=9.0in,letterpaper,showframe]{geometry}
\usepackage[document]{ragged2e}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage[labelfont=bf,justification=RaggedRight,singlelinecheck=off,%
labelsep=period]{caption}
\usepackage{duckuments}
\usepackage{blindtext}
\addtolength{\textfloatsep}{0pt plus 0.01fil}
\begin{document}
\RaggedRight
\doublespace
\chapter{Title of chapter}
\blindtext
\begin{figure}[b]
\hrule
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is a caption that is very long for the figure and it should be aligned with the bottom margin}
\vskip-\dp\strutbox%\hrule
\end{figure}
\blindtext
\blindtext
\begin{figure}[t]
\centering
\includegraphics[height=3cm]{example-image-duck}
\caption{This is the caption.}
\end{figure}
\end{document}