开始新章节时首页上有图片,但页面空白的问题

开始新章节时首页上有图片,但页面空白的问题

这是一个难题。我有很多次开始新章节的情况,新章节的第一页是 pdf 页面,使用 pdf 页面加载\includegraphics (我有很多文档,我扫描,然后像这样加载到 Latex 中)。

如果我没有正确调整 pdf/图像页面的宽度,那么在章节开头就会出现空白页。因此,我花了很多时间手动调整图像宽度,使其足够小,以消除章节开头的空白页。

不仅如此,如果我从信纸尺寸改为法律尺寸,则不需要进行所有这些更改。

我想问是否有一种自动化的方法来找出 pdf 页面或要加载的图像的宽度,以便不会生成空白页。

案件总是出现在新章节的第一页。以下是我所指的 MWE。

\documentclass[11pt]{report}%   
\usepackage[demo]{graphicx}
\usepackage[letterpaper]{geometry}
%\usepackage[legalpaper]{geometry}
\begin{document}
Some text here
Some text here

Some text here
Some text here

\chapter{one}
\includegraphics[width=0.9\textwidth,height=.9\textwidth]{whatever}

\includegraphics[width=0.9\textwidth,height=.9\textwidth]{whatever}
\end{document}

结果如下。第二页是空的

Mathematica 图形

更改 height=.9height=.85修复它

....
\chapter{one}
\includegraphics[width=0.9\textwidth,height=.85\textwidth]{whatever}

\includegraphics[width=0.9\textwidth,height=.9\textwidth]{whatever}
 ....

结果如下

Mathematica 图形

我理解这个问题。以及 Latex 这样做的原因。图像有点太大,所以它尝试在新页面上显示,但最终放弃了,页面被浪费了。

注意:在上面的 MWE 中,我添加了height=只是为了显示问题。在我的实际代码中,只width=使用了 。但我不知道如何在不使用 的情况下在这里显示问题height=

所以我的问题是:有没有办法告诉 Latex 自动调整正在加载的图像的宽度以使其正确,从而不会生成空白页?或者有一种更智能的方法来做到这一点,而无需进行所有这些手动调整。

我现在做的是运行 Latex,花很多时间调整图像的宽度值以删除它们前面的空白页。有时我也会更改geometry,然后不得不重新做一遍。如果能自动完成这项工作就好了。

使用 TL 2015。

答案1

\getremaining计算页面上剩余的垂直空间,并将答案放入长度中\vremaining

记得运行两次。

\documentclass[11pt]{report}%   
\usepackage[demo]{graphicx}
\usepackage[letterpaper]{geometry}
%\usepackage[legalpaper]{geometry}
\usepackage{tikzpagenodes}

\newlength{\vremaining}

\newcommand{\getremaining}%
{\begin{tikzpicture}[remember picture,overlay]
  \pgfextracty{\vremaining}{\pgfpointanchor{current page text area}{south}}%
  \global\vremaining=-\vremaining
\end{tikzpicture}%
\advance\vremaining by 0.6\baselineskip
\vspace*{-\baselineskip}\newline}% place above image

\begin{document}
Some text here
Some text here

Some text here
Some text here

\chapter{one}
\getremaining
\includegraphics[width=0.9\textwidth,height=\vremaining]{whatever}

\includegraphics[width=0.9\textwidth,height=.9\textwidth]{whatever}
\end{document}

相关内容