I'm writing one document with a letterhead which applies only to the first page, so I needs the margins changed, in particular I need to change the \textheight length only for one page of the document: the first.
I have success doing this the "bad" way but I'm trying to do it better (Knuth-compliant way).
This works but requires manual intervention to put \changepage at the correct place, or force a new page with \pagebreak before the \changepage command used to restore the margins.
What I want? I want something like making a page style definition and calling it with \thispagestyle after document's begins, i.e.:
This solution does not works, this changes the \topmargin adding -1.5cm but ignores the addition of 1.5cm to \textheight. Using \pagestyle{titlepage} does changes both lengths! but this is not what I want, so there is a difference in the implementation of \pagestyle and \thispagestyle.
I did search inside latex.ltx format file and I have found that \thispagestyle command defines \@specialstyle to the arg. of \thispagestyle{} and sets \@specialpagetrue which will be checked inside \@outputpage to define the page style only for the current page, I guess this happens after something that doesn't allows changing \textheight variable.
(this is without using 'changepage' package), but has the same results, i.e. \textheight not changed using \thispagestyle, and both lengths changed using \pagestyle.
Also, something like \AtBeginNextPage (which doesn't exists) should work the following way:
You could use the geometry package. geometry 5.1 and later supports changing page dimensions even in the middle of a document or just for the title page. It offers commands \newgeometry{…} and \restoregeometry for that purpose.
\newgeometry option has one disadvantage for me: it can't change only one value at its invocation remembering the current page layout, i.e. \newgeometry{vmargin={0.5cm}} sets the top margin to 0.5cm but also sets all other values to to their default, so using \newgeometry requires pasting the \geometry line at preamble with the changed margin. Yes, I'm using geometry package. I forgot to mention it in the first message! But there is no difference without geometry.
Also using \newgeometry that way I have the same behavior. I'll try to paste a minimal code which reproduces that:
In the code we have two "page styles", one which changes the margins with geometry and one which do the same with changepage. In both of them, when the page style is set with \thispagestyle, the margins are not set correctly (indeed, \textheight), and if we use \pagestyle, everything works fine.
Why I don't want to use \pagestyle? Because I need to put the next \pagestyle at hand when the first page ends and before the first ink drop is written to the second page.