% \iffalse meta-comment
%
% Copyright (C) 1998-2002 by Rolf Niepraschk <niepraschk@ptb.de>
% --------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% Please send error reports and suggestions for improvements to
%   Rolf Niepraschk <niepraschk@ptb.de>.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{eso-pic}
%<package>   [2002/11/16 v1.1b eso-pic (RN)] 
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{eso-pic,array}
\EnableCrossrefs\CodelineIndex\RecordChanges
\begin{document}
  \DocInput{eso-pic.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{637}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \iffalse meta-comment
% ===================================================================
%  @LaTeX-package-file{
%    author         = {Rolf Niepraschk},
%    version        = "v1.1b",
%    date           = "16 November 2002",
%    filename       = "eso-pic.sty",
%    address        = "",
%    telephone      = "",
%    email          = "niepraschk@ptb.de",
%    codetable      = "ISO/ASCII",
%    keywords            = "LaTeX2e, \shipout, picture",
%    dependences    = "everyshi",
%    supported      = "yes",
%    docstring      = "LaTeX package which makes it easy to add some  
%                       picture commands to every page." 
%  }
% ===================================================================
% \fi
%
% \providecommand\env[1]{\textsf{#1}}
% \providecommand\clsname[1]{\textsf{#1}}
% \providecommand\pkgname[1]{\textsf{#1}}
% \providecommand\optname[1]{\textsf{#1}}
% \providecommand\progname[1]{\textsf{#1}}
%
% \setlength\emergencystretch{3em}
%
%  \changes{v0.4}{1998/06/02}{Initial version}
%  \changes{v0.5}{1998/07/11}{Some bug corrections}
%  \changes{v0.6}{2000/05/13}{Some corrections for compatibility with
%     the \pkgname{html} package suggested by Ross Moore and a licence note}
%  \changes{v0.7}{2001/07/20}{New command \cmd{\AddToShipoutPicture*}}
%  \changes{v1.0}{2002/07/03}{New commands \cmd{\LenToUnit},%
%    \cmd{\AtPageUpperLeft}, \cmd{\AtPageCenter}, \cmd{\AtTextUpperLeft}, 
%    and \cmd{\AtTextCenter}.}
% \changes{v1.0c}{2002/10/30}{New command \cmd{\AtTextLowerLeft} and 
%    corrections to \cmd{\AtTextUpperLeft}.}
%  \changes{v1.1}{2002/11/07}{New commands and package options for 
%    background grids.}
%  \changes{v1.1b}{2002/11/16}{New package options "texcoord" and "pscoord"}
%  \changes{v1.1b}{2002/11/16}{New command \cmd{\AtPageLowerLeft}}
%
% \GetFileInfo{eso-pic.sty}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \title{The \pkgname{eso-pic} package\thanks{This document
%   corresponds to \pkgname{eso-pic}~\fileversion, dated \filedate.}}
% \author{Rolf Niepraschk \\ \texttt{niepraschk@ptb.de}}
%
% \date{}
%
% \maketitle
%
% \begin{abstract}
%    This package makes it easy to add some picture commands to every page.
% \end{abstract}
%
% \section{Introduction}
%
%  This package is an extension to Martin Schr\"oder's \pkgname{everyshi} 
%  package. Using \pkgname{every\-shi}'s \cs{EveryShipout} command 
%  \pkgname{eso-pic} adds one or more userdefined \texttt{picture} commands to 
%  \LaTeX's shipout routine. 
%
% \section{Usage}
%
%  \subsection{Basic commands for adding \LaTeX{} stuff to the page background}
%  \DescribeMacro{\AddToShipoutPicture} All the picture commands which are
%  parameters of an \cs{AddToShipoutPicture} command will be added to the 
%  internal macro \cs{ESO@HookI}. This macro is part of a 
%  zero-length \texttt{picture} environment with basepoint at the lower left 
%  corner of the page (default) or at the upper left corner 
%  (package option "texcoord"). The \texttt{picture} environment will be 
%  shipped out at every new page.
%
%  \DescribeMacro{\ClearShipoutPicture} A call of \cs{ClearShipoutPicture} 
%  clears the contents of \cs{ESO@HookI}. 
%  
%  \DescribeMacro{\AddToShipoutPicture*} \cs{AddToShipoutPicture*} works like 
%  \cs{AddToShipoutPicture} but only for the current page. It used the internal
%  macro \cs{ESO@HookII} which contents will be removed automatically.
%
%  \DescribeMacro{\LenToUnit} Allows a length as parameter to a picture
%    command.
%
%  \DescribeMacro{\gridSetup} 
%    |\gridSetup[|\meta{gridunitname}|]||{|\meta{gridunit}|}|^^A
%      |{|\meta{labelfactor}|}||{|\meta{griddelta}|}| |{|\meta{gridDelta}|}|^^A
%      |{|\meta{gap}|}|. For details see the implementation section.\par
%  \DescribeMacro{\AtPageUpperLeft}
%  \DescribeMacro{\AtPageLowerLeft}
%  \DescribeMacro{\AtPageCenter} 
%  \DescribeMacro{\AtTextUpperLeft}
%  \DescribeMacro{\AtTextLowerLeft}
%  \DescribeMacro{\AtTextCenter} 
%    Helper macros for easier positioning on the page.  \vfill\mbox{}
%
%  \subsection{Package options}
%  \begin{center}
%  \begin{tabular}{@{}>{\ttfamily}llp{.5\textwidth}@{}}
%    \textnormal{Option} & Value & Comments \\ \hline
%    pscoord & empty or \textit{true}, \textit{false} & The zero point of
%      the coordinate system is the lower left corner of the page
%      (the default). \\
%    texcoord & empty or \textit{true}, \textit{false} & The zero point of
%      the coordinate system is the upper left corner of the page. \\
%    grid & empty or \textit{true}, \textit{false} & A grid is drawing; 
%      default: false. \\
%    gridunit & \textit{mm}, \textit{in}, \textit{bp}, \textit{pt} & Distance 
%      between gridlines are multiples of \texttt{gridunit}. default: mm.\\
%    gridcolor & a valid color name & Color of the main gridlines; 
%                                     default: black \\
%    subgridcolor & a valid color name & Color of the subgridlines; 
%                                     default: black. \\
%    subgridstyle & \textit{solid} or \textit{dotted} & `dotted' is very slow! 
%      default: solid. \\
%    colorgrid & empty or \textit{true}, \textit{false} & Shortcut for 
%          `grid=true', `gridcolor=red' and `subgridcolor=green'; 
%          default: false.\\
%    dvips        & empty or \textit{true}, \textit{false} & Is also true 
%      if the package option \texttt{dvips} is 
%      used by \pkgname{color} or \pkgname{graphics}. If true package 
%      \pkgname{eepic} is loaded for better performance of dotted lines.   
%    
%  \end{tabular}
%  \end{center}
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
%
% \subsection{The main functionality}
%
%    \begin{macrocode}
\RequirePackage{everyshi}
%    \end{macrocode}
% \begin{macro}{\LenToUnit}
%    \begin{macrocode}
\newcommand\LenToUnit[1]{#1\@gobble}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtPageUpperLeft}

%    \begin{macrocode}
\newcommand\AtPageUpperLeft[1]{%
  \begingroup
    \@tempdima=0pt\relax\@tempdimb=\ESO@yoffsetI\relax
    \put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb}){#1}%
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtPageLowerLeft}
%    \begin{macrocode}
\newcommand\AtPageLowerLeft[1]{\AtPageUpperLeft{%
  \put(0,\LenToUnit{-\paperheight}){#1}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtPageCenter}
%    \begin{macrocode}
\newcommand\AtPageCenter[1]{\AtPageUpperLeft{%
  \put(\LenToUnit{.5\paperwidth},\LenToUnit{-.5\paperheight}){#1}}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtTextUpperLeft}
%    \begin{macrocode}
\newcommand\AtTextUpperLeft[1]{%
  \begingroup
    \setlength\@tempdima{1in}%
    \ifodd\c@page%
      \advance\@tempdima\oddsidemargin%
    \else%
      \advance\@tempdima\evensidemargin%
    \fi%
    \@tempdimb=\ESO@yoffsetI\relax\advance\@tempdimb-1in\relax%
    \advance\@tempdimb-\topmargin%
    \advance\@tempdimb-\headheight\advance\@tempdimb-\headsep%
    \put(\LenToUnit{\@tempdima},\LenToUnit{\@tempdimb}){#1}%
  \endgroup
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtTextLowerLeft}
%    \begin{macrocode}
\newcommand\AtTextLowerLeft[1]{\AtTextUpperLeft{%
  \put(0,\LenToUnit{-\textheight}){#1}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\AtTextCenter}
%    \begin{macrocode}
\newcommand\AtTextCenter[1]{\AtTextUpperLeft{%
  \put(\LenToUnit{.5\textwidth},\LenToUnit{-.5\textheight}){#1}}}
%    \end{macrocode}
% \end{macro}
% \DescribeMacro{\ESO@HookI}\DescribeMacro{\ESO@HookII}
% \DescribeMacro{\ESO@HookIII}
%    \begin{macrocode}
\newcommand{\ESO@HookI}{} \newcommand{\ESO@HookII}{}
\newcommand{\ESO@HookIII}{}
%    \end{macrocode}
% \begin{macro}{\AddToShipoutPicture}
%    \begin{macrocode}
\newcommand{\AddToShipoutPicture}{%
  \@ifstar{\g@addto@macro\ESO@HookII}{\g@addto@macro\ESO@HookI}}
%    \end{macrocode}  
% \end{macro}  
% \begin{macro}{\ClearShipoutPicture}
% \changes{v1.0a}{2002/10/07}{Changed \cmd{\let} to 
%   \cmd{\global}\cmd{\let} (suggested by Alberto Lusiani).}
%    \begin{macrocode}
\newcommand{\ClearShipoutPicture}{\global\let\ESO@HookI\@empty}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ESO@isMEMOIR}
%    Support for the \clsname{memoir} class.
%    \begin{macrocode}
\newcommand\ESO@isMEMOIR[1]{}
\@ifclassloaded{memoir}{\renewcommand\ESO@isMEMOIR[1]{#1}}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@ShipoutPicture}
% \changes{v0.8}{2002/01/21}{Compatibility with the \clsname{memoir} class 
%    (suggested by Andreas Matthias).}
% \changes{v0.9}{2002/07/27}{Compatibility with the \pkgname{crop} package 
%   (better test of \clsname{memoir}).}
% \changes{v0.9}{2002/07/27}{\cmd{\nointerlineskip} prevents a small vertical 
%  misplacement (suggested by Stephan Lehmke)}
% \changes{v1.0b}{2002/10/23}{A new hook \cmd\ESO@HookIII for special 
%    purpose (suggested by D. P. Story).}
%    \begin{macrocode}
\newcommand{\@ShipoutPicture}{%
  \bgroup
    \@tempswafalse%
    \ifx\ESO@HookI\@empty\else\@tempswatrue\fi%
    \ifx\ESO@HookII\@empty\else\@tempswatrue\fi%
    \ifx\ESO@HookIII\@empty\else\@tempswatrue\fi%
    \if@tempswa%
      \@tempdima=1in\@tempdimb=-\@tempdima%
      \advance\@tempdimb\ESO@yoffsetI%     
      \ESO@isMEMOIR{%
        \advance\@tempdima\trimedge%
        \advance\@tempdima\paperwidth%
        \advance\@tempdima-\stockwidth%
        \if@twoside\ifodd\c@page\else%
          \advance\@tempdima-2\trimedge%
          \advance\@tempdima-\paperwidth%
          \advance\@tempdima\stockwidth%
        \fi\fi%
        \advance\@tempdimb\trimtop}%
      \unitlength=1pt%
      \global\setbox\@cclv\vbox{%
        \vbox{\let\protect\relax
          \pictur@(0,0)(\strip@pt\@tempdima,\strip@pt\@tempdimb)%  
            \ESO@HookIII\ESO@HookI\ESO@HookII%
            \global\let\ESO@HookII\@empty%
          \endpicture}%         
          \nointerlineskip%
        \box\@cclv}%
    \fi
  \egroup
}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\EveryShipout{\@ShipoutPicture}
%    \end{macrocode}
% \subsection{The background grid}
%    \begin{macrocode}
\RequirePackage{keyval}
%    \end{macrocode}
%  Initialising some macros
%    \begin{macrocode}
\newif\ifESO@dvips\ESO@dvipsfalse \newif\ifESO@grid\ESO@gridfalse
\newif\ifESO@texcoord\ESO@texcoordfalse
\newcommand*\ESO@gridunitname{}
\newcommand*\ESO@gridunit{}
\newcommand*\ESO@labelfactor{}
\newcommand*\ESO@griddelta{}\newcommand*\ESO@griddeltaY{}
\newcommand*\ESO@gridDelta{}\newcommand*\ESO@gridDeltaY{}
\newcommand*\ESO@gridcolor{}
\newcommand*\ESO@subgridcolor{}
\newcommand*\ESO@subgridstyle{dotted}% ???
\newcommand*\ESO@gap{}
\newcommand*\ESO@yoffsetI{}\newcommand*\ESO@yoffsetII{}
\newcommand*\ESO@gridlines{\thinlines}
\newcommand*\ESO@subgridlines{\thinlines}
\newcommand*\ESO@hline[1]{\ESO@subgridlines\line(1,0){#1}}
\newcommand*\ESO@vline[1]{\ESO@subgridlines\line(0,1){#1}}
\newcommand*\ESO@Hline[1]{\ESO@gridlines\line(1,0){#1}}
\newcommand*\ESO@Vline[1]{\ESO@gridlines\line(0,1){#1}}    
\newcommand\ESO@fcolorbox[4][]{\fbox{#4}}
\newcommand\ESO@color[1]{}
\newcommand\ESO@colorbox[3][]{%
  \begingroup
    \fboxrule=0pt\fbox{#3}%
  \endgroup
}
%    \end{macrocode}
% \begin{macro}{\gridSetup}
%    \begin{macrocode}
\newcommand\gridSetup[6][]{%
  \edef\ESO@gridunitname{#1}\edef\ESO@gridunit{#2}
  \edef\ESO@labelfactor{#3}\edef\ESO@griddelta{#4}
  \edef\ESO@gridDelta{#5}\edef\ESO@gap{#6}}
%    \end{macrocode}
% \end{macro}
%  All the key-value options 
%    \begin{macrocode}
\define@key{ESO}{texcoord}[true]{\csname ESO@texcoord#1\endcsname}
\define@key{ESO}{pscoord}[true]{\csname @tempswa#1\endcsname
  \if@tempswa\ESO@texcoordfalse\else\ESO@texcoordtrue\fi}
\define@key{ESO}{dvips}[true]{\csname ESO@dvips#1\endcsname}
\define@key{ESO}{grid}[true]{\csname ESO@grid#1\endcsname
  \setkeys{ESO}{gridcolor=black,subgridcolor=black}}
\define@key{ESO}{colorgrid}[true]{\csname ESO@grid#1\endcsname
  \setkeys{ESO}{gridcolor=red,subgridcolor=green}}
\define@key{ESO}{gridcolor}{\def\ESO@gridcolor{#1}}
\define@key{ESO}{subgridcolor}{\def\ESO@subgridcolor{#1}}
\define@key{ESO}{subgridstyle}{\def\ESO@subgridstyle{#1}}%
\define@key{ESO}{gridunit}{%
  \def\@tempa{#1}
  \def\@tempb{bp}
  \ifx\@tempa\@tempb
    \gridSetup[\@tempa]{1bp}{1}{10}{50}{2}
  \else
    \def\@tempb{pt}
    \ifx\@tempa\@tempb
      \gridSetup[\@tempa]{1pt}{1}{10}{50}{2}
    \else     
      \def\@tempb{in}
      \ifx\@tempa\@tempb
        \gridSetup[\@tempa]{.1in}{.1}{2}{10}{.5}
      \else 
        \gridSetup[mm]{1mm}{1}{5}{20}{1}
      \fi
    \fi
  \fi      
}
\setkeys{ESO}{subgridstyle=solid,pscoord=true,gridunit=mm}
%    \end{macrocode}
%    \begin{macro}{\ProcessOptionsWithKV}
%    This macro can process package options using `key=value' syntax. 
%    \begin{macrocode}
\def\ProcessOptionsWithKV#1{%
  \let\@tempc\@empty
  \@for\CurrentOption:=\@classoptionslist\do{%
    \@ifundefined{KV@#1@\CurrentOption}%
    {}{\edef\@tempc{\@tempc,\CurrentOption,}}}%
  \edef\@tempc{%
    \noexpand\setkeys{#1}{\@tempc\@ptionlist{\@currname.\@currext}}}%
  \@tempc
  \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}  
\ProcessOptionsWithKV{ESO}%
%    \end{macrocode} 
%    \begin{macro}{\ESO@div}
%  Divides length |#1| by |#2| \(\times\) \cmd{\ESO@gridunit} and adds one. 
%  Result is in \cmd{\@tempcnta}.
%    \begin{macrocode}
\newcommand\ESO@div[2]{%
  \@tempdima=#1\relax\@tempdimb=\ESO@gridunit\relax
  \@tempdimb=#2\@tempdimb\divide\@tempdima by \@tempdimb%
  \@tempcnta\@tempdima\advance\@tempcnta\@ne}  
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode} 
\AtBeginDocument{%
  \IfFileExists{color.sty}
  {%
    \RequirePackage{color}
    \let\ESO@color=\color\let\ESO@colorbox=\colorbox
    \let\ESO@fcolorbox=\fcolorbox       
  }{}
  \@ifundefined{Gin@driver}{}%
  {%
    \ifx\Gin@driver\@empty\else%
      \filename@parse{\Gin@driver}\def\reserved@a{dvips}%
      \ifx\filename@base\reserved@a\ESO@dvipstrue\fi%
    \fi
  }%
  \ifx\pdfoutput\undefined\else
    \ifx\pdfoutput\relax\else
      \ifcase\pdfoutput\else
        \ESO@dvipsfalse%
      \fi
    \fi
  \fi   
  \ifESO@dvips\def\@tempb{eepic}\else\def\@tempb{epic}\fi
  \def\@tempa{dotted}%\def\ESO@gap{\LenToUnit{6\@wholewidth}}%
  \ifx\@tempa\ESO@subgridstyle
    \IfFileExists{\@tempb.sty}%
    {%
      \RequirePackage{\@tempb}
      \renewcommand*\ESO@hline[1]{\ESO@subgridlines\dottedline{\ESO@gap}%
        (0,0)(##1,0)}
      \renewcommand*\ESO@vline[1]{\ESO@subgridlines\dottedline{\ESO@gap}%
        (0,0)(0,##1)} 
    }{}
  \else
    \ifx\ESO@gridcolor\ESO@subgridcolor%
      \renewcommand*\ESO@gridlines{\thicklines}
    \fi       
  \fi
} 
\ifESO@texcoord
  \def\ESO@yoffsetI{0pt}\def\ESO@yoffsetII{-\paperheight}
  \edef\ESO@griddeltaY{-\ESO@griddelta}\edef\ESO@gridDeltaY{-\ESO@gridDelta}  
\else  
  \def\ESO@yoffsetI{\paperheight}\def\ESO@yoffsetII{0pt}
  \edef\ESO@griddeltaY{\ESO@griddelta}\edef\ESO@gridDeltaY{\ESO@gridDelta}
\fi  
%    \end{macrocode}  
%    \begin{macro}{\ESO@gridpicture}
%    \begin{macrocode} 
\newcommand\ESO@gridpicture{%
  \begingroup
    \setlength\unitlength{\ESO@gridunit}%
    \ESO@color{\ESO@subgridcolor}%
%    \end{macrocode}     
%    --- horizontal subgrid lines ---
%    \begin{macrocode}    
    \ESO@div{\paperheight}{\ESO@griddelta}%
    \multiput(0,0)(0,\ESO@griddeltaY){\@tempcnta}%
      {\ESO@hline{\LenToUnit{\paperwidth}}}%
%    \end{macrocode}     
%    --- vertical subgrid lines ---
%    \begin{macrocode}  
    \ESO@div{\paperwidth}{\ESO@griddelta}%
    \multiput(0,\LenToUnit{\ESO@yoffsetII})(\ESO@griddelta,0){\@tempcnta}%
      {\ESO@vline{\LenToUnit{\paperheight}}}%
    \ESO@color{\ESO@gridcolor}%
%    \end{macrocode}     
%    --- horizontal grid lines ---
%    \begin{macrocode}     
    \ESO@div{\paperheight}{\ESO@gridDelta}%
    \multiput(0,0)(0,\ESO@gridDeltaY){\@tempcnta}%
      {\ESO@Hline{\LenToUnit{\paperwidth}}}%
%    \end{macrocode}     
%    --- vertical grid lines ---
%    \begin{macrocode}        
    \ESO@div{\paperwidth}{\ESO@gridDelta}%
    \multiput(0,\LenToUnit{\ESO@yoffsetII})(\ESO@gridDelta,0){\@tempcnta}%
      {\ESO@Vline{\LenToUnit{\paperheight}}}%
%    \end{macrocode}         
%    --- horizontal numbers ---
%  \changes{v1.1a}{2002/11/09}{Font setting added.}
%    \begin{macrocode}   
    \fontsize{10}{12}\normalfont%   
    \ESO@div{\paperwidth}{\ESO@gridDelta}%
    \multiput(0,\ESO@gridDeltaY)(\ESO@gridDelta,0){\@tempcnta}{%
      \@tempcntb=\@tempcnta\advance\@tempcntb-\@multicnt%
      \ifnum\@tempcntb>1\relax
        \multiply\@tempcntb by \ESO@gridDelta\relax%
        \@tempdima=\@tempcntb sp\@tempdima=\ESO@labelfactor\@tempdima%
        \@tempcntb=\@tempdima%
        \makebox(0,0)[c]{\ESO@colorbox{white}{\the\@tempcntb}}%
      \fi}%
%    \end{macrocode}        
%    --- vertical numbers ---
%    \begin{macrocode} 
    \ifx\ESO@gridunitname\@empty\def\@tempa{0}\else\def\@tempa{1}\fi%    
    \ESO@div{\paperheight}{\ESO@gridDelta}%
    \multiput(\ESO@gridDelta,0)(0,\ESO@gridDeltaY){\@tempcnta}{%
      \@tempcntb=\@tempcnta\advance\@tempcntb-\@multicnt%
      \ifnum\@tempcntb>\@tempa\relax
        \multiply\@tempcntb by \ESO@gridDelta\relax%
        \@tempdima=\@tempcntb sp\@tempdima=\ESO@labelfactor\@tempdima%
        \@tempcntb=\@tempdima%
        \makebox(0,0)[c]{\ESO@colorbox{white}{\the\@tempcntb}}%        
      \fi      
    }%     
%    \end{macrocode}     
%    --- the unit label ---
%    \begin{macrocode}
    \ifx\ESO@gridunitname\@empty\else%      
      \thicklines\fboxrule=\@wholewidth%
      \put(\ESO@gridDelta,\ESO@gridDeltaY){\makebox(0,0)[c]{%
        \ESO@fcolorbox{\ESO@gridcolor}{white}{%
          \textbf{\ESO@gridunitname}}}}%
    \fi          
    \normalcolor%
  \endgroup
}
%    \end{macrocode}  
%    \end{macro}    
%  Add the grid to the shipout picture (\cmd{\ESO@HookIII} is independed 
%  from the user commands 
%  \cmd{\AddToShipoutPicture} and \cmd{\AddToShipoutPicture*}).
%    \begin{macrocode}   
\ifESO@grid\g@addto@macro\ESO@HookIII{\ESO@gridpicture}\fi
%    \end{macrocode} 
%
% \Finale
\endinput
