I have this for my first page:

% Custom margins - FIRST PAGE

And I have a bunch of text. Somewhere in there, Latex creates a second page of text for me. If I then go exactly where that is, and paste the following:


I get the expected behavior. Now, if I change the margins of the first page again, that would necessarily change what text would appear on the second page and that messes up my changing the geometry of the second page. Instead what I get is two pages with the "FIRST PAGE" settings, and the second page has a huge amount of blank space and a third page with the correct settings.

I know that to use a different geometry on another page, you use the \newgeometry command. My question is - where do I place that in my latex code so that it always effects the second (and third etc.) pages without letting the first call to geometry affect that?

  • 2
    \newgeometry always starts a new page at the point where it is issued: are you aware of this?
    – GuM
    Mar 13, 2017 at 19:01
  • Implicitly yes, which is why i have to make sure to place it in the right place, as described above - my question is then how can I set the geometry of the second/third pages without triggering a new page?
    – user79950
    Mar 13, 2017 at 19:55
  • 1
    basically you can not do this. tex does all the line breaking before page breaking is considered so you can not change the size of the text block at an automatic page break. Mar 13, 2017 at 20:41
  • 1
    @GustavoMezzetti as you say it definitely would not work mid paragraph and quite often it won't work at all. Once floats are considered there may be several pages worth of text already with line breaks fixed to the previous text width. Mar 13, 2017 at 20:43
  • 3
    just set up the geometry for your second page but start the document \begin{document} \vspace*{-0.5in} so the first page starts higher, which seems to be the intention. Mar 13, 2017 at 21:21

1 Answer 1


Caveat: Use at Your Own Risk!

As D.C. says (and as it is well known), it is basically impossible to have the text width change at a page boundary in an “automatic” fashion, that is, whatever the text that spans the two pages is. This is because TeX chooses the line breaks within each paragraph before it knows where it is going to cut off each page, and doesn’t change them any more afterwords. In principle, it is possible to prohibit page breaks within paragraphs by setting the \interlinepenalty parameter to a value ≥ 10000, but in practice this is only feasible if you have very short paragraphs that never exceed two or three lines in length. Note, however, that this could be the case inside a table of contents or similar index; another situation in which this might be true is inside at itemize or enumerate environment.

However, if you do not need to change the line width, but only the margins, the following code shows a crude hack by means of which this could be achieved. Because of the \globaldefs=1 it contains, I explicitly decline any warranty that this methods will not break anything: use it solely at your own risk!

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.





This is a test.

\afterpage{\globaldefs=1 \restoregeometry}

Now \( \verb|\globaldefs|=\texttt{\number\globaldefs} \).



You must log in to answer this question.

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