3

is there a simple way to add some content at the end of pages similarly to \AtEndDocument (for example something like \AtThisPageEnd) ?

I looked at everyhook and everypage, but it doesn't look that it's possible to do it with these packages.

Does someone have an idea ?

Edit: To be more precise, I try to change the layout for some page using the geometry package. I manage to make it work when the textwidth is constant. The problem comes when it is not, see this example

\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}

Geometry change on page 2, but margin kept to be the one of the first page till end of block [1]

A workaround (not very nice) is to add the \clearpage\noindent at the end of the first page (see example comment). (NB: I'd like to set the layout only with the geometry package here)

9
  • 2
    the normal way would be to use \thispagestyle{zzz} and then specify your text in the page foot of the zzz style. Feb 16, 2016 at 16:53
  • 1
    Do you want the content to form part of the text block, be in the footer, or be added to the shipped-out page at some random position? Could you make it more clear what you're after exactly?
    – Werner
    Feb 16, 2016 at 17:33
  • I agree with @Werner. If you want it to be still inside the writing area, you could just issue a \vfill command and write whatever you want after it. Feb 16, 2016 at 17:51
  • @Werner Yes I want it to be part of the text and executed in a macro. For my case I'd like to add a \clearpage at the end of one specific page to begin the next page with a new group.
    – gdolle
    Feb 16, 2016 at 20:01
  • Can you provide the community with a minimal working example (MWE) showing what you have and what you want? The latter should show how to achieve your goal through hard coding, perhaps, even though you want it to be more automated. It would make this more clear in my opinion.
    – Werner
    Feb 16, 2016 at 20:06

1 Answer 1

0

What you're looking for is an open problem, so you'll have to resort to some manual intervention. Here are two options:

  1. Since you know where the break is located, you can insert a forced paragraph break and ensure that the last line fills the line width. The length at play here is \parfillskip. After that, you can insert your \clearpage\noindent like before:

    \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]
    
  2. If you don't want to care about the exact position, but know that you have a certain number of lines before the page break, you can use \parshape to adjust the flow of the paragraph:

    \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]
    

In both instance above, the following output is achieved:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .