6

I am trying to establish one geometry for my first page (not a title page), and use another for the rest of the document. However, because I am trying to make a template, and thus do not want to rely on a user to put in \newgeometry or \restoregeometry in the text of the document, I would like to establish these geometries in the preamble. Is there any way to do this?

A minimum working example

\documentclass{article}
\usepackage{lecturenotes}

\usepackage{afterpage}

\thispagestyle{plain}


\begin{lecture}{01}{Sample Lecture Notes}{John Sam}{01/01/2000}{Mark John}{PHYSICS 124: Physics of Energy}

\afterpage{\newgeometry{top=2cm, bottom=2.5cm, outer=5.5cm, inner=2cm, heightrounded, marginparwidth=3.5cm, marginparsep=0.4cm, includeheadfoot}}


\end{lecture}
\theend

The style 'lecturenotes'

    \def\fileversion{1.0}
\def\filedate{2014/02/05}
\NeedsTeXFormat{LaTeX2e}


\usepackage{graphicx}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage[top=0.5cm, bottom=2.5cm, outer=5.5cm, inner=2cm, heightrounded, marginparwidth=3.5cm, marginparsep=0.4cm, includeheadfoot]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}

\newcommand{\handout}{
   \noindent
   \begin{center}
   \framebox{ \vbox{ \hbox to 13.5cm { {\bf {\course}} \hfill {Lecture \lecturenum\ -- \lecturedate} }
       \vspace{4mm}
       \hbox to 13.5cm { {\Large \hfill {\lecturetitle}  \hfill} }
       \vspace{2mm}
       \hbox to 13.5cm { {\it {Lecturer: \lecturer} \hfill {Notes by: \lecturescribe}} }
     }
   }
   \end{center}
   \vspace*{4mm}
}

\newenvironment{lecture}[6]{
    \begin{document}
    \global \def \lecturenum {#1}
    \global \def \lecturetitle {#2}
    \global \def \lecturescribe {#3}
    \global \def \lecturedate {#4}
    \global \def \lecturer {#5}
    \global \def \course {#6}
    \handout
}


\lhead{\lecturedate}
\chead{\lecturetitle}
\rhead{Lecture \lecturenum}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\newcommand{\theend}{\end{document}}
  • 2
    If only the first page is to have the altered layout and you don't want to require the user to do anything special, maybe a solution with the afterpage package is a possibility. Please add a minimal working example (MWE) that illustrates your layout with the manual geometry commands. It will be much easier for us to reproduce your situation and find a solution beginning from compilable code, starting with \documentclass{...} and ending with \end{document}. BTW: Welcome to TeX.SX! – Paul Gessler Feb 6 '14 at 5:21
  • 1
    If you are trying to keep everything under the hood, why not simply issue \newgeometry and \restoregeometry under the hood as well? There's also the package changepage (updated version of chngpage), which might work for your needs. But the same basic 'problem' of keeping things hidden seems to be the same. FYI: etoolbox offers lots of environment hooks, which might help keep things hidden. An MWE would help clarify what might work for you. – jon Feb 6 '14 at 5:46
  • Thanks for the welcome @PaulGessler! Ill get onto a MWE, however in the case of afterpage - I have already tried using it, but issuing the command \afterpage{\newgeometry{}} after \begin{document} doesn't seem to do anything? – Heisenbugs Feb 6 '14 at 5:54
  • You can't do like this: \restoregeometry has to issue a \clearpage command. A paragraph can't use two page geometries, because it's typeset before page breaks are considered. – egreg Feb 6 '14 at 7:51
1

If all you want to do is change the top margin on the first page, you're doing it the hard way. Just use a negative \vspace to move the text up to wherever you want it. The use of handout and lecture makes me wonder if this is not part of an even more elaborate set-up, but, in principle, you could do something like this:

\newlength\toplen  
\newlength\fplen   
\newlength\fpgap    
\setlength{\fplen}{0.5cm}  
\setlength{\toplen}{\dimexpr2cm + \fplen\relax}   
\setlength{\fpgap}{\dimexpr\fplen - \toplen - \headheight - \headsep - \topsep  
- \partopsep\relax}

Then plug \toplen into geometry and \vspace*{\fpgap} into your \handout command. Note: this is really designed to give you only 0.5 cm between the top of the physical page and the top of the framebox. Your original geometry command would leave significantly more space.

Here's a complete example, slightly changed from yours above. (Mainly with respect to the not-advised hiding of \begin{document} and \end{document}; but I also made \lecture [a command] from the environment lecture.)

\documentclass{article}
\usepackage{filecontents}
% --------------------------------------------------------------------
\begin{filecontents*}{lecturenotes.sty}
\def\fileversion{1.0}
\def\filedate{2014/02/05}
\NeedsTeXFormat{LaTeX2e}

\RequirePackage{graphicx}
\RequirePackage{amsmath,amssymb,amsthm,amsfonts}

% Some lengths
\newlength\toplen
\newlength\fplen
\newlength\fpgap
\setlength{\fplen}{0.5cm}
\setlength{\toplen}{\dimexpr2cm + \fplen\relax}
\setlength{\fpgap}{\dimexpr\fplen - \toplen - \headheight - \headsep - \topsep - \partopsep\relax}

\RequirePackage[showframe, top=\toplen, %
bottom=2.5cm, outer=5.5cm, inner=2cm, heightrounded,
marginparwidth=3.5cm, marginparsep=0.4cm, includeheadfoot]{geometry}

\RequirePackage{fancyhdr}
\pagestyle{fancy}
\lhead{\lecturedate}
\chead{\lecturetitle}
\rhead{Lecture \lecturenum}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\newcommand{\handout}{%
  \noindent
  \vspace*{\fpgap}%
  \begingroup
  \par
  \centering
  \framebox{ \vbox{ \hbox to 13.5cm { {\bf {\course}}
        \hfill {Lecture \lecturenum\ -- \lecturedate} }
      \vspace{4mm}
      \hbox to 13.5cm { {\Large \hfill {\lecturetitle}  \hfill} }
      \vspace{2mm}
      \hbox to 13.5cm { {\it {Lecturer: \lecturer} \hfill
          {Notes by: \lecturescribe}} }
    }
  }
  \par
  \endgroup
  \vspace*{4mm}%
  \par\ignorespacesafterend
}

\newcommand{\lecture}[6]{%
%   \begin{document}  <-- why ?
  \thispagestyle{plain}
  \global \def \lecturenum {#1}
  \global \def \lecturetitle {#2}
  \global \def \lecturescribe {#3}
  \global \def \lecturedate {#4}
  \global \def \lecturer {#5}
  \global \def \course {#6}
  \handout
}


\newcommand{\theend}{\end{document}}% <-- why?
\end{filecontents*}
% --------------------------------------------------------------------

\usepackage{lecturenotes}
\usepackage{lipsum}

\begin{document}

\lecture{01}{Sample Lecture Notes}{John Sam}{01/01/2000}{Mark
    John}{PHYSICS 124: Physics of Energy}

\lipsum[1]
\newpage
\lipsum[1-10]

\theend % <-- why?
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.