change title page margins ONLY without packages

I am trying to prepare a package for students that offers a uniform standard title page for their work (homework, reports, theses, and probably more).

I have the title page laid out as it should be. However, I am having problems setting the margins. I wish to centre ONLY the title page, without side effects to possible margin settings that the students might have already set up for the rest of their document.

I have seen other solutions such as this one, but they invariably make use of some package like geometry etc. I am seeking a solution that works with plain LaTeX only. The reason is that I do not know what class the title page package ends up in (book, report, memoir, classicthesis, ...), and I need something that provides maximum compatibility.

• Are they using pdfLaTeX? If so, just create a separate class to produce just the title page and have them use the pdfpages package to include it. Nothing you do is going to be compatible inline with absolutely anything they might be using. – cfr Sep 7 '15 at 21:26
• I don't know what they are using. And I have thought about the pdfpages solution, as this is what I do for my own thesis title page. But for someone maybe new to TeX, and more importantly maybe already struggling to get the required work done, a two-step process is far worse than accepting small incompatibilities with e.g. the geometry package. And since geometry does it, it should be doable, right? – user53911 Sep 7 '15 at 21:34
• It is going to break somebody's document. Bound to. What do you mean by plain LaTeX exactly? Note that classes and packages do not just add things, they change things. So, by \begin{document}, \macroA may not do the same thing in student 1's document as it does in student 2's. I'm no guru but everything I know suggests that you simply can't do this in a way which will be compatible with every student's work: not if they could be using literally any combination of class and packages. Not using a package doesn't mean compatible with everything. Packages are just code. Code changes stuff. – cfr Sep 7 '15 at 21:51
• Of course people might load packages and break stuff. I merely wish to minimise the way in which my code does likewise. The question is simply how to achieve in a standalone way what the \newgeometry, \restoregeometry, ... commands from geometry do. – user53911 Sep 7 '15 at 22:08

One option would be to borrow the definitions for the \changepage command from the changepage package:

\documentclass{article}
\usepackage{lipsum}

\makeatletter
% Definitions taken from changepage.sty
\begingroup
\catcode\Q=3
\long\gdef\@ifmtarg#1{\@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
\long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4}
\endgroup

% Set the page output parameters
\DeclareRobustCommand{\ch@ngetext}{%
\setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}%
\setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}%
\if@twocolumn%
\@firstcolumntrue%
\fi%
\setlength{\hsize}{\columnwidth}%
\setlength{\linewidth}{\hsize}}

\DeclareRobustCommand{\changepage}[9]{%
\ch@ngetext%
\makeatother
%

\begin{document}

\changepage{7cm}{6cm}{-3cm}{-3cm}{}{-3cm}{}{}{}
\lipsum[1-10]
\clearpage
\changepage{-7cm}{-6cm}{3cm}{3cm}{}{3cm}{}{}{}
\lipsum[1-5]
\end{document}


The result:

• This works very well, thank you. I have renamed the command to something unique for the package, in case someone uses changepage. – user53911 Sep 7 '15 at 22:48
• @nes I thought you wanted a standard title page? This gives a different result for memoir than it does for report, and a different result again for book. – cfr Sep 8 '15 at 1:29
• @nes Try \documentclass{book}, \documentclass{book}\usepackage{geometry}, \documentclass{memoir}. (Restricting to classes which default to double-sided.) Or \documentclass{report}`. (For one which doesn't.) – cfr Sep 8 '15 at 1:36
• @cfr Thanks for your concern, I take one/twoside and one/twocolumn into account when laying out the title. I really only needed a means to change the geometry for a single page. – user53911 Sep 8 '15 at 8:26