有没有一种简单的方法可以在页面末尾添加一些类似的内容\AtEndDocument
(例如类似于\AtThisPageEnd
)?
我查看了everyhook
和everypage
,但看起来不可能用这些包来实现。
有人有想法吗?
编辑:更准确地说,我尝试使用 geometry 包更改某些页面的布局。当文本宽度恒定时,我设法使其工作。当文本宽度不恒定时,问题就出现了,请参见此示例
\documentclass [a4paper]{article}
\usepackage [showframe]{geometry}
\usepackage {atbegshi}
\usepackage {lipsum}
\title{The Title}
\author{Me}
\date{\today}
\geometry{
paperwidth=18cm,
paperheight=18cm,
textwidth=9cm,
}
\makeatletter
\gdef\setGeometryPage
{
\ifnum\thepage=2
\global\let\setGeometryPage =\relax
\expandafter \@gobble % gobble clearpage
\newgeometry
{
textwidth=12cm,
}%
\fi
\aftergroup\setGeometryPage
}
\AtBeginShipout{
\AtBeginShipoutUpperLeft{
\setGeometryPage
}
}
\makeatother
\begin{document}
\maketitle
\section{First section}
\lipsum[1]
This part is the transition with the next page.
This part is the transition with the next page.
This part is the
%\clearpage\noindent
transition
\lipsum[1-2]
\end{document}
一种解决方法(不是很好)是\clearpage\noindent
在第一页的末尾添加(参见示例注释)。(注意:我只想geometry
在这里使用包来设置布局)
答案1
你正在寻找的是开放问题,因此您必须采取一些手动干预措施。以下是两个选项:
自从你知道在换行符所在的位置,您可以插入强制段落换行符,并确保最后一行填满行宽。这里的长度是
\parfillskip
。之后,您可以插入\clearpage\noindent
类似以下的内容:\lipsum[1] {\setlength{\parfillskip}{0pt}% Make last line in paragraph fill the line This part is the transition with the next page. This part is the transition with the next page. This part is the\par% } \clearpage\noindent transition \lipsum[1-2]
如果你不想关心精确的位置,但知道分页符之前有一定数量的行,您可以使用它
\parshape
来调整段落流:\lipsum[1] \parshape 3 % Shape of 3+ lines in the paragraph have to be adjusted 0pt \linewidth % Line 1 = A regular line (no additional indent, and full \linewidth) 0pt \linewidth % Line 2 = A regular line (no additional indent, and full \linewidth) 0pt \dimexpr\linewidth+3cm % Line 3+ = Adjusted (no additional indent, width of \linewidth+3cm) This part is the transition with the next page. This part is the transition with the next page. This part is the transition \lipsum[1-2]
在上述两个实例中,均实现了以下输出: