%
% \GetFileInfo{gmeometric.sty}
% \title{The \pk{gmeometric} Package\thfileinfo}
% \author{Grzegorz Murzynowski}
% \maketitle
%
%
% \begin{copyrnote}
%
%%   Written by Grzegorz Murzynowski,
%%   natror at o2 dot pl
%%
%% \copyright\,2006, 2007 by Grzegorz Murzynowski.
%%
%% This program is subject to the \LaTeX\ Project Public License.
%% See
%% \url{http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html}
%% for the details of that license.
%%
%% LPPL status: "author-maintained".\par
%
%\end{copyrnote}
%
% \CheckSum{61}
% \chschange{v0.69}{2007/4/26}{40}
% 
%% \FileInfo

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gmeometric}
     [2007/04/26 v0.69 to allow the `geometry' macro in the document (GM)]

%%
%
%% \division{Introduction, usage}
%%
%% This package allows you to use the |\geometry| macro, provided by
%% the \pk{geometry} v3.2 by Hideo Umeki, anywhere in a~document:
%% originally it's claused |\@onlypreamble| and the main work of
%% \pk{gmeometric} is to change that.
%%
%% Note it's rather queer to change the page layout \emph{inside}
%% a~document and it should be considered as drugs or alcohol: it's
%% O.K.\ only if you \emph{really} know what you're doing.
%%
%% In order to work properly, the macro should launch the |\clearpage|
%% or the |\cleardoublepage| to `commit' the changes. So, the
%% unstarred version trigges the first while the starred the
%% latter. If that doesn't work quite as expected, try to precede or
%% succede it with |\onecolumn| or |\twocolumn|.
%%
%% It's important that |\clear(double)page| launched by |\geometry|
%% not to be a~no-op, i.e., |\clear(double)page| immediately
%% preceding |\geometry| (nothing is printed in between) discards the
%% `commitment'.
%%
%% \stanza
%% You may use \pk{gmeometric} just like \pk{geometry} i.e., to specify
%% the layout as the package options: they shall be passed to
%% \pk{geometry}.
%
%
% \begin{gmlonely}
%   \subdivision{Installation}
%
%   Just put the \pk{gmeometric.sty} somewhere in the \file{texmf/\:tex/\:latex}
%   branch. Creating a~\file{texmf/\:tex/\:latex/\:gm} directory may be advisable
%   if you consider using other packages written by me.
%
%   Then you should refresh your \TeX\ distribution's files' database
%   most probably. 
% \end{gmlonely}
%
%
% \subdivision{Contents of the \pk{gmeometric.zip} archive}
%
% The distribution of the \pk{gmeometric} package consists of the
% following four files.
% \begin{verse}
%   \pk{gmeometric.sty}\\
%   \pk{README}\\
%   \pk{gmeometricDoc.tex}\\
%   \pk{gmeometricDoc.pdf}
% \end{verse}
%
%
% \begin{gmlonely}
%   \subdivision{Compiling of the Documentation}
%
%   The last of the above files (the \pk{.pdf}, i.e., \emph{this
%     file}) is a~documentation compiled from the \pk{.sty} file by
%   running \LaTeX\ (twice) on the \pk{gmeometricDoc.tex} file.
%   Compiling of the documentation requires the packages: \pk{gmdoc}
%   (\pk{gmdoc.sty} and \pk{gmdocc.cls}), \pk{gmverb.sty},
%   \pk{gmutils.sty}, \pk{gmiflink.sty} and also some standard
%   packages: \pk{hyperref.sty}, \pk{color.sty}, \pk{geometry.sty},
%   \pk{multicol.sty}, \pk{lmodern.sty}, \pk{fontenc.sty} that should
%   be installed on your computer by default.
%
%   If you have not installed the \pk{mwart.cls} class (available on
%   CTAN in \pk{mwcls} package), the result of your compilation may
%   differ a bit from the \pk{.pdf} provided in this \pk{.zip} archive
%   in formattings: If you have not installed \pk{mwart.cls}, the
%   standard \pk{article.cls} class will be used.
% \end{gmlonely}
%
%
% \division{Usage}
% The only use of this package is to allow the |\geometry| command
% also inside the \env{document} (originally it's
% |\@onlypreamble|). To make |\geometry| work properly it may be
% advisable to `commit' the layout changes with (|\clearpage|,
% |\cleardoublepage| or |\newpage|) and maybe |\one/twocolumn|.
%
% Some layout commands should be put before |\one/twocolumn| and other
% after it. An example:
%
%\begin{verbatim}
% \thispagestyle{empty}
%
% \advance\textheight 3.4cm\relax
% \onecolumn
% \newpage
%
% \advance\footskip-1.7cm
% \geometry{hmargin=1.2cm,vmargin=1cm}
%\end{verbatim}
%
% And another:
%\begin{verbatim}
% \geometry{bottom=3.6cm}
%\end{verbatim}
%
% 
% \division{The Code}

\RequirePackage{gmutils}[2007/04/23]% this package defines the storing
% and restoring commands.


\RequirePackageWithOptions{geometry}

% Let's remove some macros from the list to erase at begin document:
\let\do\not@onlypreamble

\do\Gm@cnth 
\do\Gm@cntv
\do\c@Gm@tempcnt 
\do\Gm@bindingoffset
\do\Gm@wd@mp 
\do\Gm@odd@mp 
\do\Gm@even@mp 
\do\Gm@orgw 
\do\Gm@orgh
\do\Gm@dimlist


% Redefine |\geometry| to give it the starred version that clears
% a~double page when used in the document. The unstarred versions will
% do just |\clearpage|. Note that |\clear(double)page| makes no harm
% when used in the preamble. \CodeDefine\geometry
\def\geometry{%
  \@ifstar{\gm@geometry{double}}{\gm@geometry{}}}

% \CodeDefine\gm@geometry
\def\gm@geometry#1#2{%
  \Gm@clean
  \setkeys{Gm}{#2}%
  \Gm@process
  \csname clear#1page\endcsname}%


% \changes{v0.69}{2007/04/26}{The package main action rewritten to use
% \cs{not@onlypreamble} and not \cs{(Re)StoreMacros}}


\endinput
% \NoEOF

% (For my GNU Emacs:)
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: "../../../../LaTeX/TeXGuru/gmeometric/gmeometricDoc.tex"
%%% End: 
