% \iffalse meta-comment
%
% papermas package
% file version: v1.0c
% file date:          2010/06/24
% documentation date: 2010/06/24
%
% Copyright (C) 2010 H.-Martin M\"{u}nch (Martin dot Muench at Uni-Bonn dot de)
% Portions of code copyrighted by other people as marked.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. This version of this license is in
%    http://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is H.-Martin Muench.
%
% This work consists of the main source file papermas.dtx
% and the derived files
%    papermas.sty, papermas.ins, papermas.drv,
%    papermas-example.tex, papermas.pdf.
%
% Unpacking:
%    (a) If papermas.ins is present:
%           tex papermas.ins
%    (b) Without papermas.ins:
%           tex papermas.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{papermas.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%    (a) If papermas.drv is present:
%           (pdf)latex papermas.drv
%           makeindex -s gind.ist papermas.idx
%           (pdf)latex papermas.drv
%           makeindex -s gind.ist papermas.idx
%           (pdf)latex papermas.drv
%    (b) Without papermas.drv:
%           (pdf)latex papermas.dtx
%           makeindex -s gind.ist papermas.idx
%           (pdf)latex papermas.dtx
%           makeindex -s gind.ist papermas.idx
%           (pdf)latex papermas.dtx
%
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use DIN A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
%
%    Programm calls to get the documentation (for example):
%       pdflatex papermas.dtx
%       makeindex -s gind.ist papermas.idx
%       % makeindex -s gglo.ist -o papermas.gls papermas.glo
%       pdflatex papermas.dtx
%       makeindex -s gind.ist papermas.idx
%       % makeindex -s gglo.ist -o papermas.gls papermas.glo
%       pdflatex papermas.dtx
%
% Installation:
%    TDS:tex/latex/muench/papermas/papermas.sty
%    TDS:doc/latex/muench/papermas/papermas.pdf
%    TDS:doc/latex/muench/papermas/papermas-example.tex
%    TDS:source/latex/muench/papermas/papermas.dtx
%
%<*ignore>
\begingroup
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex

\obeyspaces
\Msg{******************************************************}
\Msg{* Installation                                       *}
\Msg{* Package: papermas v1.0c 2010/06/24 LaTeX2e package *}
\Msg{* Computes paper mass of a printout (HMM)            *}
\Msg{******************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

IMPORTANT NOTICE:
The package takes options.

The usual disclaimers apply:
If it doesn't work right that's your problem.
(Nevertheless, send an e-mail to the maintainer
 when you find an error in this package.)

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
   http://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
   http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of
LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is H.-Martin Muench
(Martin dot Muench at Uni-Bonn dot de).

This work consists of the main source file papermas.dtx
and the derived files
   papermas.sty, papermas.pdf, papermas.ins, papermas.drv,
   papermas-example.tex.

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{papermas.ins}{\from{papermas.dtx}{install}}%
  \file{papermas.drv}{\from{papermas.dtx}{driver}}%
  \file{ltxdoc.cfg}{\from{papermas.dtx}{ltxdoc}}%
  \usedir{tex/latex/muench/papermas}%
  \file{papermas.sty}{\from{papermas.dtx}{package}}%
  \usedir{doc/latex/muench/papermas}%
  \file{papermas-example.tex}{\from{papermas.dtx}{example}}%
}

\obeyspaces
\Msg{**************************************************************}
\Msg{*                                                            *}
\Msg{* To finish the installation you have to move the following  *}
\Msg{* file into a directory searched by TeX:                     *}
\Msg{*                                                            *}
\Msg{* papermas.sty                                               *}
\Msg{*                                                            *}
\Msg{* To produce the documentation run the file `papermas.drv'   *}
\Msg{* through (pdf)LaTeX, e. g.                                  *}
\Msg{*  pdflatex papermas.dtx                                     *}
\Msg{*  makeindex -s gind.ist papermas.idx                        *}
\Msg{*  pdflatex papermas.dtx                                     *}
\Msg{*  makeindex -s gind.ist papermas.idx                        *}
\Msg{*  pdflatex papermas.dtx                                     *}
\Msg{*                                                            *}
\Msg{* At least two runs are necessary e. g. to get the           *}
\Msg{*  references right!                                         *}
\Msg{*                                                            *}
\Msg{* Happy TeXing!                                              *}
\Msg{*                                                            *}
\Msg{**************************************************************}

\endbatchfile

%</install>
%<*ignore>
\fi
%</ignore>
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.\,e., the file that will produce the documentation you
% are currently reading. It will be extracted from this file by the
% \texttt{docstrip} programme. That is, run \LaTeX\ on \texttt{docstrip}
% and specify the \texttt{driver} option when \texttt{docstrip}
% asks for options.
%
%    \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesFile{papermas.drv}[2010/06/24 v1.0c%
            Computes paper mass of a printout (HMM)]%
\documentclass{ltxdoc}[2007/11/11]% v2.0u
\usepackage{holtxdoc}[2010/04/24]% v0.19
%% papermas may work with earlier versions of LaTeX2e and those
%% class and package, but this was not tested.
%% Please consider updating your LaTeX, class, and package
%% to the most recent version (if they are not already the most
%% recent version).
%% Warning: holtxdoc, 2010/04/24 v0.19, requires the packages
%% hypdoc, 2010/03/26, v1.9
%% hyperref, 2010/03/30, v6.80u (latest: 2010/06/04 v6.81f)
%% pdftexcmds, 2010/04/01, v0.9
%% ltxcmds, 2010/03/09, v1.4 (latest: 2010/04/26, v1.7)
%% hologo, 2010/04/24, v1.2
%% array (latest: 2008/09/09, v2.4c)
%% (or more recent versions) and does neither work with
%% nor check for earlier versions!
\hypersetup{%
 pdfsubject={Computes paper mass of a printout (HMM)},%
 pdfkeywords={LaTeX, papermas, papermass, paper mass, paper, mass, weight, totpages, pagesLTS, Hans-Martin Muench},%
 pdfencoding=auto,%
 pdflang={en},%
 breaklinks=true,%
 linktoc=all,%
 pdfstartview=FitH,%
 pdfpagelayout=OneColumn,%
 bookmarksnumbered=true,%
 bookmarksopen=true,%
 bookmarksopenlevel=3,%
 pdfmenubar=true,%
 pdftoolbar=true,%
 pdfwindowui=true,%
 pdfnewwindow=true%
}
\setlength\hfuzz{1pt} % Ignore slight overfulls.
\CodelineIndex
%\PageIndex           % instead of \CodelineIndex to get the page numbers
\EnableCrossrefs
%\DisableCrossrefs    % Say \DisableCrossrefs if index is ready.
%\RecordChanges       % Gather update information.
%\OnlyDescription     % Comment out for implementation details.
\hyphenation{created document docu-menta-tion every-thing ignored}
\makeatletter
%% Code from tcilatex.tex, Macros for Scientific Word and Scientific WorkPlace 5.5 <06 Oct 2005> %%
%% Copyright (C) 2005 Mackichan Software, Inc.                                                   %%
%% That macro file is NOT proprietary and may be freely copied and distributed.                  %%
  \def\unit#1{\mathord{\thinspace\rm #1}}%
%  These macros are for doing the AMS \text{} construct
\def\RIfM@{\relax\protect\ifmmode}
\def\text{\RIfM@\expandafter\text@\else\expandafter\mbox\fi}
\let\nfss@text\text
\def\text@#1{\mathchoice
   {\textdef@\displaystyle\f@size{#1}}%
   {\textdef@\textstyle\tf@size{\firstchoice@false #1}}%
   {\textdef@\textstyle\sf@size{\firstchoice@false #1}}%
   {\textdef@\textstyle \ssf@size{\firstchoice@false #1}}%
   \glb@settings}
\def\textdef@#1#2#3{\hbox{{%
                    \everymath{#1}%
                    \let\f@size#2\selectfont
                    #3}}}
\newif\iffirstchoice@
\firstchoice@true
%% End of code from tcilatex.tex                                                                 %%
\makeatother
\begin{document}
  \DocInput{papermas.dtx}%
\end{document}
%</driver>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*ltxdoc>
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesFile{ltxdoc.cfg}[2010/05/15 v1.0 configuration file for papermas (HMM)]
  %% Code from original ltxdoc.cfg [2007/01/08 latex-tds: ltxdoc.cls configuration (HO)],  %%
  % copyrighted 2006, 2007 Heiko Oberdiek, part of project `latex-tds'.
  % That file may be distributed and/or modified under the
  % conditions of the LaTeX Project Public License, either version 1.3
  % 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.3c or later is part of all distributions of LaTeX
  % version 2005/12/01 or later.
  % That work has the LPPL maintenance status `maintained'.
  % The Current Maintainer of that work is Heiko Oberdiek.
  %
  \PassOptionsToClass{a4paper}{article}
  \AtEndOfClass{%
    \RequirePackage[numbered]{hypdoc}[2010/03/26]% v1.9
    \pdfstringdefDisableCommands{%
      \let\env\relax % longtable.dtx
      \let\mytt\relax % tabularx.dtx
    }%
    \addtolength{\topmargin}{-10mm}%
    \addtolength{\textheight}{20mm}%
    % Depending on the page style, the head or foot area
    % are put into the text area.
    % Usually the page style is the default "plain".
    % tools/verbatim.dtx uses "myheadings".
    \def\string@plain{plain}%
    \def\string@myheadings{myheadings}%
    \def\current@pagestyle{plain}%
    \let\ltxdoc@cfg@pagestyle\pagestyle
    \def\pagestyle#1{%
      \def\current@pagestyle{#1}%
      \ltxdoc@cfg@pagestyle{#1}%
    }%
    \edef\ltxdoc@cfg@jobname{\jobname}%
    \def\ltxdoc@cfg@longtable{longtable}%
    \@onelevel@sanitize\ltxdoc@cfg@longtable
    \ifx\ltxdoc@cfg@jobname\ltxdoc@cfg@longtable
      \def\current@pagestyle{both}%
    \fi
    \let\ltxdoc@cfg@document\document
    \def\document{%
      \ifx\current@pagestyle\string@plain
        \addtolength{\textheight}{\headheight}%
        \addtolength{\textheight}{\headsep}%
        \setlength{\headheight}{0pt}%
        \setlength{\headsep}{0pt}%
        \global\textheight\textheight
        \global\headheight\headheight
        \global\headsep\headsep
      \fi
      \ifx\current@pagestyle\string@myheadings
        \addtolength{\textheight}{\footskip}%
        \global\textheight\textheight
      \fi
      \ltxdoc@cfg@document
    }%
  %% End of code from original ltxdoc.cfg [2007/01/08 latex-tds: ltxdoc.cls configuration (HO)]  %%
  %% Place additional code here.  %%
  }

%</ltxdoc>
%    \end{macrocode}
%
% \fi
%
% \CheckSum{0}
%
% \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         \~}
%
% \GetFileInfo{papermas.drv}
%
% \begingroup
%   \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
%   \makeatletter
%   \@onelevel@sanitize\x
% \expandafter\endgroup
% \expandafter\DoNotIndex\expandafter{\x}
% \expandafter\DoNotIndex\expandafter{\string\ }
% \begingroup
%   \makeatletter
%     \lccode`9=32\relax
%     \lowercase{%^^A
%       \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
%     }%^^A
%   \expandafter\endgroup\x
% \DoNotIndex{\documentclass,\usepackage,\hfuzz,\small,\tt,\begin,\end}
% \DoNotIndex{\NeedsTeXFormat,\filedate,\fileversion,\DoNotIndex}
% \DoNotIndex{\def,\edef,\divide,\advance,\multiply}
% \DoNotIndex{\",\-,\,,\\,\hskip,\H,\ldots,\indent,\noindent,\textbackslash}
% \DoNotIndex{\textbf,\textit,\textquotedblleft,\textquotedblright,\textsf,\texttt}
% \DoNotIndex{\ifthenelse,\and,\equal,\whiledo,\if,\ifx,\ifnum,\else,\fi}
% \DoNotIndex{\CodelineIndex,\EnableCrossrefs,\DisableCrossrefs}
% \DoNotIndex{\DocInput,\AltMacroFont}
% \DoNotIndex{\@ne,\tw@,\thr@@}
% \DoNotIndex{\newpage,\pagebreak,\newline,\linebreak,\nolinebreak}
% \DoNotIndex{\lipsum,\MessageBreak,\pageref,\protect}
% \DoNotIndex{\RecordChanges,\OnlyDescription}
% \DoNotIndex{\smallskip,\medskip,\bigskip,\space,\thinspace}
% \DoNotIndex{\item}
% \DoNotIndex{\plainTeX,\TeX,\LaTeX,\pdfLaTeX}
% \DoNotIndex{\holtxdoc,\kvoptions,\Oberdiek}
% \DoNotIndex{\gdef,\listfiles,\thepage,\totpages,\undefined,\value}
% \DoNotIndex{\markboth,\M"{u}ench,\section,\totpages}
%
% \title{The \textsf{papermas} package\footnote{This file%
%        has version number v1.0c, last%
%        revised 2010/06/24, documentation dated 2010/06/24.}}
% \author{H.-Martin M\"{u}nch\\
% (\texttt{Martin dot Muench at Uni-Bonn dot de})}
% \date{2010/06/24}
%
% \maketitle
%
% \begin{abstract}
% This package allows to compute the number of sheets of paper needed to print a document
% as well as the mass of that printed version of the document,
% useful e.\,g. when sending it by mail to determine the postage.\\
% (The number of pages of a document can be determined with the
% \textsf{pagesLTS} package.)~--\\
% Further this package allows to compute
% \textquotedblleft \textit{base} to the power of \textit{exponent}\textquotedblright
% \ inside \LaTeX.
% \end{abstract}
%
% \bigskip
%
% \noindent Disclaimer for web links: The author is not responsible for any contents
% referred to in this work unless he has full knowledge of illegal contents.
% If any damage occurs by the use of information presented there, only the
% author of the respective pages might be liable, not the one who has referred
% to these pages.
%
% \bigskip
%
% \noindent Save per page about $200\unit{ml}$ water,
% $2\unit{g}$ CO$_{2}$ and $2\unit{g}$ wood:\\
% Therefore please print only if this is really necessary.
%
% \bigskip
%
% %\newpage
%
% \tableofcontents
%
% \bigskip
%
% \section{Introduction}
% \indent This package is kind of an add-on to my \textsf{pagesLTS} package,
% but because that already uses some resources and computing the
% number of sheets of paper or the paper mass probably is not
% needed so often, this was made into a separate package.\\
% \indent It allows to compute the number of sheets of paper needed to print a document
% (useful when the paper is running out)
% as well as the mass of that printed version of the document,
% useful e.\,g. when sending it by mail to determine the postage.\\
% \indent \textbf{Warning/Disclaimer}: The mass of (printer's) ink has to be added
% (and that of envelope, address sticker, stamps,...).
% So, this is only an estimation without guarantee --
% do not sue me, if you have got to pay excess postage!\\
% \indent Further this package allows to compute
% \textquotedblleft \textit{base} to the power of \textit{exponent}\textquotedblright
% \ inside \LaTeX.\\
% \indent The name \textsf{papermas} is short for paper mass but written with only one \textsf{s},
% because some software has problems with names with more than eight letters.\\
% It is \textsf{mass} and gives a result in grammes $\left[ \unit{g}\right]$,
% because the weight $F=m\cdot g$ (really $\overrightarrow{F}=m\cdot \overrightarrow{g}$)
% $\left[ \unit{N}\right]$ would need the knowledge about the gravitational acceleration
% $g$ (depending on place and time, in central Europe approximately $9.81\unit{m}/\unit{s}^{2}$)
% and give a result in \textsc{Newton}, which probably is not very useful.
%
% \pagebreak
%
% \section{Usage}
%
% \indent Just load the package placing
% \begin{quote}
%   |\usepackage[<|\textit{options}|>]{papermas}|
% \end{quote}
% \noindent in the preamble of your \LaTeXe\ source file
% (preferrrably after calling the \textsf{pagesLTS} package).\\
% Because the \textsf{pagesLTS} package is used to get the total
% number of pages, please place a |\pagenumbering{...}| with
% appropriate argument (e.\,g.~arabic, roman, Roman, fnsymbol,
% alph, or Alph) right behind |\begin{document}| (see
% documentation of \textsf{pagesLTS} package).\\
% Now you can say
% \begin{verbatim}
% This document consists of $\arabic{pagesLTS.pagenr}$~pages.
% When printing $\papermaspagespersheet$~pages on one sheet of
% paper, $\papermassheets$~sheets will be needed. For
% ISO~A~\papermasformat\ paper of $\papermasmasss \unit{g}\unit{m}^{-2}$
% specific mass, the printout will have a mass of about
% $\papermasstotal \unit{g}$.
% \end{verbatim}
% to get e.\,g.
% \begin{quote}
% This document consists of $101$~pages.
% When printing $4$~pages on one sheet of
% paper, $26$~sheets will be needed. For
% ISO~A~4 paper of $80\unit{g}\unit{m}^{-2}$
% specific mass, the printout will have a mass of about
% $130\unit{g}$.
% \end{quote}
% This information is also presented at the screen while compiling
% your document (look for \textsf{papermas}), in the \xfile{log}
% file (search for \textsf{Package papermas Info}), and can be found
% in the \xfile{aux} file~-- probably one does not want to have the
% information in the printed document.\\
% (One could use the \textsf{color} package and
% \begin{verbatim}
% {\color{white} This document ... of about $\papermasstotal \unit{g}$.}
% \end{verbatim}
% which does not show in the printed document (white background of the page
% assumed), but can be made visible on the screen be marking that text.)
%
% \subsection{Options}
% \DescribeMacro{options}
% \indent The \textsf{papermas} package takes the following options:
%
% \subsubsection{format\label{sss:format}}
% \DescribeMacro{format}
% \indent Option |format| wants to know the ISO~A\ldots format
% of the paper used for printing, i.\,e. |format=4| means ISO~A4
% paper format (which is also the default).
%
% \subsubsection{masss\label{sss:mass}}
% \DescribeMacro{masss}
% \indent Option |masss| wants to know the specific (therefore the third~s)
% mass of the paper used for printing in $\unit{g}/\unit{m}^{2}$.
% The default is |masss=80|, i.\,e. $80\unit{g}/\unit{m}^{2}$.
%
% \subsubsection{pagespersheet\label{sss:pagespersheet}}
% \DescribeMacro{pagespersheet}
% \indent Option |pagespersheet| wants to know, how many
% pages are to be printed on one sheet of paper.
% |pagespersheet=2| could mean duplex printing or printing two pages
% on one side of paper while keeping the back side blank. This
% does not influence the real printing process! So, if this number
% differs from the one chosen for printing, the result will be wrong,
% of course.
%
% \subsubsection{decimalsep\label{sss:decimalsep}}
% \DescribeMacro{decimalsep}
% \indent Option |decimalsep| wants to know, what should be used
% for the decimal separator. In English this is
% \textquotedblleft .\textquotedblright , while in German it is
% \textquotedblleft ,\textquotedblright . Enclose this in brackets,
% e.\,g.~|decimalsep={.}| or |decimalsep={,}|. The default is
% \textquotedblleft .\textquotedblright . This is used for the
% mass of the printed document, and this value is given at
% the screen during compilation as well as in the \xfile{log}
% and \xfile{aux} files. Therefore something like
% |decimalsep={,\,}| would cause trouble there.
%
% \section{Alternatives\label{sec:Alternatives}}
%
% For determining the number of pages (not sheets of paper)
% instead of the \textsf{pagesLTS} package the alternatives listed
% in the description of that package could be used, but then
% the according code in this package would need to be changed
% (and also e.\,g. the |ifcounter| used here).\\
% With the \textsf{totpages} package optionally the number of
% sheets of paper needed to print the document can be computed, too.\\
% (See \textsf{pagesLTS} documentation.)\\
%
% \bigskip
%
% \noindent (You programmed or found another alternative,
%  which is available at \CTAN{}?\\
%  OK, send an e-mail to me with the name, location at \CTAN{},
%  and a short notice, and I will probably include it in
%  the list above.)\\
%
% \smallskip
%
% \noindent About how to get those packages, please see subsection~\ref{ss:Downloads}.
%
% \newpage
%
% \section{Example}
%
%    \begin{macrocode}
%<*example>
\documentclass[british,a4paper]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}[2010/06/04]% v6.81f
\hypersetup{%
 extension=pdf,%
 plainpages=false,%
 pdfpagelabels=true,%
 hyperindex=false,%
 pdflang={en},%
 pdftitle={papermas package example},%
 pdfauthor={Hans-Martin Muench},%
 pdfsubject={Example for the papermas package},%
 pdfkeywords={LaTeX, papermas, Hans-Martin Muench},%
 pdfview=Fit,%
 pdfstartview=Fit,%
 pdfpagelayout=SinglePage,%
 bookmarksopen=false%
}
\usepackage{alphalph}[2010/04/18]% v2.3
\usepackage[pagecontinue=true,alphMult=ab,AlphMulti=AB,fnsymbolmult=true,romanMult=true,RomanMulti=true]{pagesLTS}[2010/06/24]% v1.1c
%% These are the default options. %%
\usepackage[format=4,masss=80,pagespersheet=2,decimalsep={.}]{papermas}
%% These are the default options. %%
\listfiles
\begin{document}
\pagenumbering{arabic}

\section*{Example for papermas}
\markboth{Example for papermas}{Example for papermas}

This example demonstrates the use of package\newline
\textsf{papermas}, v1.0c as of 2010/06/24 (HMM).\newline
The used options were \texttt{format=4} (ISO~A4),
\texttt{masss=80} ($\unit{g}\unit{m}^{-2}$), and\newline
\texttt{pagespersheet=2} (pages per sheet of paper,
i.\,e. either duplex printing or\newline
printing two pages on one side of a sheet of paper with blank back side).\newline
(These are the default options.)\newline
For more details please see the documentation!\newline

\bigskip

This document consists of
\lastpageref{LastPages}~(\arabic{pagesLTS.pagenr})~pages.
When printing $\papermaspagespersheet$~pages on one sheet of
paper, $\papermassheets$~sheets will be needed. For
ISO~A~\papermasformat\ paper of $\papermasmasss \unit{g}\unit{m}^{-2}$
specific mass, the printout will have a mass of about
$\papermasstotal \unit{g}$.

\bigskip

Save per page about $200\unit{ml}$~water, $2\unit{g}$~CO$_{2}$
and $2\unit{g}$~wood:\newline
Therefore please print only if this is really necessary.\newline
I do NOT think, that it is necessary to print THIS file, really\newline
(at least not after this page)!

%    \end{macrocode}
%
% \pagebreak
%
%    \begin{macrocode}

\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Page \thepage
\newpage Last page \thepage.
\end{document}
%</example>
%    \end{macrocode}
%
% \pagebreak
%
% \section{The implementation}
%
% We start off by checking that we are loading into \LaTeXe\ and
% announcing the name and version of this package.
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{papermas}[2010/06/24 v1.0c
            Computes paper mass of a printout (HMM)]%

%    \end{macrocode}
%
% A short description of the \textsf{papermas} package:
%
%    \begin{macrocode}
%% Allows to compute the number of sheets of paper
%% needed to print a document as well as the
%% mass of that printed version of the document,
%% useful e. g. when sending it by mail to determine the postage.
%% Warning/Disclaimer: Mass of (printer's) ink has to be added
%% (and that of envelope, address sticker, stamps,...)!
%% So, this is only an estimation without guarantee -
%% do not sue me, if you have got to pay excess postage!
%% Further this package allows to compute
%%  "base to the power of exponent" inside TeX.

%    \end{macrocode}
%
% For the handling of the options we need the \textsf{kvoptions}
% package of Heiko Oberdiek (see subsection~\ref{ss:Downloads}):
%
%    \begin{macrocode}
\RequirePackage{kvoptions}[2010/02/22]% v3.7
%    \end{macrocode}
%
% For the total number of pages we need the \textsf{pagesLTS}
% package of myself (see subsection~\ref{ss:Downloads}):
%
%    \begin{macrocode}
\RequirePackage{pagesLTS}[2010/06/24]% v1.1c
%    \end{macrocode}
%
% A last information for the user(s):
%
%    \begin{macrocode}
%% papermas may work with earlier versions of those packages,
%% but this was not tested. Please consider updating your packages
%% to the most recent version (if they are not already the most
%% recent version).

%    \end{macrocode}
% See subsection~\ref{ss:Downloads} about how to get them.\\
%
% The options are introduced:
%
%    \begin{macrocode}
\SetupKeyvalOptions{family = papermas,prefix = papermas@}
\DeclareStringOption[4]{format}[4]%        paper foormat, ISO A...,
                                  %         default: (ISO A) 4
\DeclareStringOption[80]{masss}[80]%       specific mass of the paper,
                                   %        default: 80 (g/(m^2))
\DeclareStringOption[2]{pagespersheet}[2]% number of pages per sheet,
                                         %  for duplex printing this is 2.
\DeclareStringOption[.]{decimalsep}[.]%    decimal separator,
             % e. g. "." or ",": decimalsep={,} - brackets are needed!!!
             % decimalsep={,\,} does not work for screen, aux, log output!

\ProcessKeyvalOptions*

%    \end{macrocode}
%
% \begin{macro}{unit}
% We want to use the |\unit| command from {\sl Scientific WorkPlace\/},
% therefore we need to copy the definition:
%
%    \begin{macrocode}
%% Code from tcilatex.tex, Macros for Scientific Word and Scientific WorkPlace 5.5 <06 Oct 2005> %%
%% Copyright (C) 2005 Mackichan Software, Inc.                                                   %%
%% That macro file is NOT proprietary and may be freely copied and distributed.                  %%
%% \def was changed to \gdef                                                                     %%
  \gdef\unit#1{\mathord{\thinspace\rm #1}}%
%% End of code from tcilatex.tex                                                                 %%

%    \end{macrocode}
% \end{macro}
%
% \pagebreak
%
% Even if diverse commands are not defined yet, we do not want~a\\
% \LaTeX \texttt{\ Error:~\ldots\ undefined}.
%
%    \begin{macrocode}
\ifx\papermasstotal\undefined \gdef\papermasstotal{\textbf{??}}%
\fi
\ifx\papermasstotal\undefined \gdef\papermasstotal{\textbf{??}}%
\fi
\ifx\papermasformat\undefined \gdef\papermasformat{\textbf{??}}%
\fi
\ifx\papermasmasss\undefined \gdef\papermasmasss{\textbf{??}}%
\fi
\ifx\papermaspagespersheet\undefined \gdef\papermaspagespersheet{\textbf{??}}%
\fi
\ifx\papermassheets\undefined \gdef\papermassheets{\textbf{??}}%
\fi

%    \end{macrocode}
%
% Introducing some new counters:
%
%    \begin{macrocode}
\newcounter{papermas@rerun}
\newcounter{papermas@base}
\newcounter{papermas@exp}
\newcounter{papermas@result}
\newcounter{papermas@ini}
\setcounter{papermas@ini}{1}

%    \end{macrocode}
%
% \begin{macro}{\papermas@powerof}
% We need a command to compute
% \textquotedblleft base to the power of exponent\textquotedblright\ $\left( base^{exponent}\right) $.\\
% (Is this really not already implementet in \LaTeX?!)
%
%    \begin{macrocode}
\newcommand\papermas@powerof[2]{%
  \setcounter{papermas@base}{#1}
  \setcounter{papermas@exp}{#2}
  \ifnum \value{papermas@ini}=1
    \setcounter{papermas@result}{\value{papermas@base}}
    \setcounter{papermas@ini}{0}
    \ifnum \value{papermas@exp}=0%
      \setcounter{papermas@result}{1}
    \else
      \addtocounter{papermas@exp}{-1}
    \fi
  \fi
  \ifnum \value{papermas@exp}=0%
    \setcounter{papermas@ini}{1}
  \else
    \multiply \value{papermas@result} \value{papermas@base}
    \addtocounter{papermas@exp}{-1}
    \papermas@powerof{#1}{\value{papermas@exp}}
  \fi%
  }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\papermas@totmass}
% This is the internal command, which computes the total paper mass
% of the printed document.
%
%    \begin{macrocode}
\newcommand\papermas@totmass{%
  \newcounter{papermasA}% paper mass for ISO A...
  \setcounter{papermasA}{\papermas@format}% e. g. 4
%    \end{macrocode}
%
% We check whether |papermasA| has a resonable value:
%
%    \begin{macrocode}
  \ifnum \value{papermasA}<0%
    \PackageError{papermas}{Option format has no valid value}%
     {The format option of the papermas package\MessageBreak%
      only takes whole, non-negative numbers (0, 1, 2, 3,...),\MessageBreak%
      because this should be the paper format\MessageBreak%
      ISO A 0, 1, 2, 3,...\MessageBreak%
      Found instead: \papermas@format \MessageBreak%
     }
  \else%
%    \end{macrocode}
%
% |papermasA| has a resonable value. We introduce a new counter
% |papermasmasss| and initialize it with the value given in option
% |masss|, i.\,e. |\papermas@masss|.
%
%    \begin{macrocode}
    \newcounter{papermasmasss}% always 0
    \setcounter{papermasmasss}{\papermas@masss}% default: 80
%    \end{macrocode}
%
% Counters are integers, but the amount of the mass of a single sheet
% of paper in most cases is not an integer, therefore we multiply with
% 100 to get two digits behind the decimal separator.\\
% (Later we need to devide by 100 again, of course.)
%
%    \begin{macrocode}
    \multiply \value{papermasmasss} 100 % default: 8000
%    \end{macrocode}
%
% We check whether |papermasmasss| has a resonable value, i.\,e. $> 0$:
%
%    \begin{macrocode}
    \ifnum \value{papermasmasss}<1%
      \PackageError{pagesLTS}{Option masss has no valid value}%
       {The masss option of the papermas package\MessageBreak%
        only takes positive numbers,\MessageBreak%
        because this should be the mass per square meter\MessageBreak%
        of a single sheet of your paper.\MessageBreak%
        Found instead: \papermas@masss \MessageBreak%
       }
    \else
%    \end{macrocode}
%
% |masss| has a resonable value, and therefore also
% |\papermas@masss| and |papermasmasss|.\\
%
% We check whether option |pagespersheet| has a resonable value, i.\,e. $\geq 1$:
%
%    \begin{macrocode}
      \newcounter{papermasPPS}% is 0
      \setcounter{papermasPPS}{\papermas@pagespersheet}% default 2
      \ifnum \value{papermasPPS} < 1%
        \PackageError{papermas}{%
          The number of pages per sheet must be positive.}{%
          You cannot print less than one TeX page per sheet of paper.\MessageBreak%
          The value found was \papermas@pagespersheet .\MessageBreak%
          }
      \else
%    \end{macrocode}
%
% |pagespersheet| has a resonable value, and therefore also\\
% |\papermas@pagespersheet| and |papermasTmpA|.\\
%
% We introduce a new counter |papermas@sheets| for the number of
% sheets printed and initialize it with the number of pages
% as computed by package \textsf{pagesLTS},\newline
% i.\,e. |pagesLTS.pagenr|.
%
%    \begin{macrocode}
        \newcounter{papermas@sheets}
        \setcounter{papermas@sheets}{\arabic{pagesLTS.pagenr}}%
%    \end{macrocode}
%
% When more than one page is printed on one sheet of paper,
% the number of sheets needed for printing is decreased:
%
%    \begin{macrocode}
        \divide \value{papermas@sheets} by \value{papermasPPS}%
%    \end{macrocode}
%
% |\divide| cuts off all digits behind the decimal separator,
% but if there are digits $>0$, this means that there is
% an additional, last sheet, which is only partially covered
% with print (e.\,g. only one side of it for duplex printing
% an odd number of pages). In that case, we have to add
% one sheet of paper to the number of sheets needed.
%
%    \begin{macrocode}
        \newcounter{papermas@tmpn}
        \setcounter{papermas@tmpn}{\arabic{papermas@sheets}}%
        \multiply \value{papermas@tmpn} \value{papermasPPS}%
        \ifnum \value{papermas@tmpn}=\value{pagesLTS.pagenr}
          \relax
        \else
          \addtocounter{papermas@sheets}{1}%
        \fi
%    \end{macrocode}
%
% Now we can multiply the specific mass of 100 sheets
% with the number of sheets needed for printing:
%
%    \begin{macrocode}
        \multiply \value{papermasmasss} \value{papermas@sheets}
  % default:                  8000       (no default for this)
%    \end{macrocode}
%
% The result is in $\unit{g}\unit{m}^{-2}$.\\
% A sheet with format ISO A0 has a size of $1\unit{m}^{2}$,\\
% a sheet with format ISO A1 has a size of $1\unit{m}^{2}\cdot 2^{-1}$,\\
% a sheet with format ISO A2 has a size of $1\unit{m}^{2}\cdot 2^{-2}$,\\
% \ldots, and\\
% a sheet with format ISO A\textit{n} has a size of $1\unit{m}^{2}\cdot 2^{-n}$.\\
% Therefore we compute $2^{\text{\textbackslash value\{papermasA\}}}$:
%
%    \begin{macrocode}
        \papermas@powerof{2}{\value{papermasA}}
%    \end{macrocode}
%
% The result is saved in |papermas@result|.\\
% We divide the specific paper mass by |papermas@result|:
%
%    \begin{macrocode}
        \divide \value{papermasmasss} by \value{papermas@result}
  % default:               16000      /   2^(\value{papermasA})
%    \end{macrocode}
%
% We need to get the division by 100 and the digits after the decimal separator right:
%
%    \begin{macrocode}
        % for the example 297 is used
        \newcounter{papermas@tmpm}
        \setcounter{papermas@tmpm}{\arabic{papermasmasss}}%   m:297 n:    o:  p:  q:
        \setcounter{papermas@tmpn}{\arabic{papermasmasss}}%   m:291 n:291 o:  p:  q:
        \divide \value{papermas@tmpn} by 100%                 m:297 n:2   o:  p:  q:
        \newcounter{papermas@tmpo}
        \setcounter{papermas@tmpo}{\arabic{papermas@tmpn}}%   m:291 n:2   o:2 p:  q:
        \multiply \value{papermas@tmpn} 10%                   m:297 n:20  o:2 p:  q:
        \divide \value{papermas@tmpm} by 10%                  m:29  n:20  o:2 p:  q:
        \newcounter{papermas@tmpp}
        \setcounter{papermas@tmpp}{\arabic{papermas@tmpm}}
        \addtocounter{papermas@tmpp}{-\arabic{papermas@tmpn}}%m:29  n:20  o:2 p:9 q:
        %        29              - 20 = 9
        \multiply \value{papermas@tmpm} 10%                   m:290 n:20  o:2 p:9 q:
        \newcounter{papermas@tmpq}
        \setcounter{papermas@tmpq}{\arabic{papermasmasss}}
        \addtocounter{papermas@tmpq}{-\arabic{papermas@tmpm}}%m:290 n:20  o:2 p:9 q:7
        %       297              - 290 = 7
%    \end{macrocode}
%
% Now rounding mathematically correct, i.\,e. $\geq 0.5$ becomes $1$
% (and remember a possible amount carried forward!) and $< 0.5$ becomes %0%.
%
%    \begin{macrocode}
        \ifnum\value{papermas@tmpq}>4
          \addtocounter{papermas@tmpp}{1}%                    m:290 n:20 o:2 p:10 q:7
          \ifnum\value{papermas@tmpp}>9%                      m:290 n:20 o:2 p:10 q:7
            \addtocounter{papermas@tmpo}{1}%                  m:290 n:20 o:3 p:10 q:7
            \setcounter{papermas@tmpp}{0}%                    m:290 n:20 o:3 p:0  q:7
          \fi
        \fi
%    \end{macrocode}
%
% The result in the example above is $297/100=2.\,97\approx 3.\,0$.
% We write this into |\papermastmpr| (where |\papermas@decimalsep|) is
% the decimal separator) and the (other) options' values into
% temporary definitions, as well as the number of sheets:
%
%    \begin{macrocode}
        \edef\papermastmpr{\arabic{papermas@tmpo}\papermas@decimalsep\arabic{papermas@tmpp}}%
        \edef\papermastmpformat{\papermas@format}%
        \edef\papermastmpmasss{\papermas@masss}%
        \edef\papermastmppagespersheet{\papermas@pagespersheet}%
        \edef\papermastmpt{\arabic{papermas@sheets}}%
%    \end{macrocode}
%
% We use the \textsf{pagesLTS} package, which already was used
% to determine the total number of pages, to check for the
% counter |papermassttl|. If it exists, nothing is done,
% if it does not exist, it is declared as |\newcounter|
% (and by default set to zero).
%
%    \begin{macrocode}
        \pagesLTS@ifcounter{papermassttl}
%    \end{macrocode}
%
% If the |papermassttl| counter value already has the value of
% |papermasmasss|, everything is fine.
%
%    \begin{macrocode}
        \ifnum\value{papermassttl}=\value{papermasmasss}
          \relax
%    \end{macrocode}
%
% Otherwise we need another run of \LaTeX.
%
%    \begin{macrocode}
        \else
          \PackageWarningNoLine{papermas}{%
            Number of pages may have changed.\MessageBreak%
            Rerun to get it right.\MessageBreak%
            }%
        \fi
%    \end{macrocode}
%
% In any case, we set the counter |papermassttl| to the
% current value of |papermasmasss|.
%
%    \begin{macrocode}
        \setcounter{papermassttl}{\arabic{papermasmasss}}
%    \end{macrocode}
%
% Because we want to write out into the \xfile{aux}-file,
% we need the expanded value (as string) of |papermasmasss|:
%
%    \begin{macrocode}
        \edef\papermastmps{\arabic{papermasmasss}}%
%    \end{macrocode}
%
% If we are allowed to write into the \xfile{aux}-file,
% we do it here. If we are not allowed to do it,
% the \textsf{pagesLTS} package already gave an according
% error message.
%
%    \begin{macrocode}
        \if@filesw%
%    \end{macrocode}
%
% When it is read from the \xfile{aux}-file and
% when its content is processed, the counter |papermassttl|
% might not have been defined yet. Therefore we again use the
% |\pagesLTS@ifcounter| command of the \textsf{pagesLTS} package.
%
%    \begin{macrocode}
          \immediate\write\@auxout{\string
            \pagesLTS@ifcounter{papermassttl}}%
%    \end{macrocode}
%
% We set the counter |papermassttl| to the value |\papermastmps|,\\
% i.\,e. |\arabic{papermasmasss}|. In the next compilation run,
% it will be checked,\\
% whether |\value{papermassttl}=\value{papermasmasss}| (see above).\\
% If this is the case, everything is OK, no changes happened,
% and no rerun is necessary (at least not for \textsf{papermas}).
%
%    \begin{macrocode}
          \immediate\write\@auxout{\string
            \setcounter{papermassttl}{\papermastmps}}%
%    \end{macrocode}
%
% What we do need, is to get the determined |\papermastmpr| to
% the user.\\
% Therefore
%
% \begin{enumerate}
% \item we define |\papermasstotal| in the \xfile{aux}-file,
%    where the user can look it up
%
% \item we define |\papermasstotal|, so the user can e.\,g. write\\
% \begin{verbatim}
% This document consists of $\arabic{pagesLTS.pagenr}$~pages.
% When printing $\papermaspagespersheet$~pages on one sheet of
% paper, $\papermassheets$~sheets will be needed. For
% ISO~A~\papermasformat\ paper of $\papermasmasss\unit{g}\unit{m}^{-2}$
% specific mass, the printout will have a mass of about
% $\papermasstotal\unit{g}$.
% \end{verbatim}
%
%    \begin{macrocode}
          \immediate\write\@auxout{\string
            \gdef\string\papermasstotal{\papermastmpr}}%
          \immediate\write\@auxout{\string
            \gdef\string\papermasformat{\papermastmpformat}}%
          \immediate\write\@auxout{\string
            \gdef\string\papermasmasss{\papermastmpmasss}}%
          \immediate\write\@auxout{\string
            \gdef\string\papermaspagespersheet{\papermastmppagespersheet}}%
%    \end{macrocode}
%
% \item we give at the screen the information about the |\papermasstotal|\\
%   (see |\AtVeryEnd| below)
%
% \item which will also appear in the \xfile{log}-file.
%\end{enumerate}
%
% \pagebreak
%
% We want to give also |\papermastmpt = \arabic{papermas@sheets}| to the user,
% i.\,e.~the number of sheets needed to print the document.
% Therefore we follow the same procedure:
%    \begin{macrocode}
          \immediate\write\@auxout{\string
            \gdef\string\papermassheets{\papermastmpt}}%
        \fi%
      \fi%
    \fi%
  \fi%
  }

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AtBeginDocument}
% \indent |\AtBeginDocument| it is checked whether some commands,
% which are/will be defined via the \xfile{aux}-file, are undefined yet:
%
%    \begin{macrocode}
\AtBeginDocument{%
  \def\papermas@undefined{\textbf{??}}
  \setcounter{papermas@rerun}{0}
  \ifx\papermasstotal\papermas@undefined        \addtocounter{papermas@rerun}{000001} \fi
  \ifx\papermasstotal\papermas@undefined        \addtocounter{papermas@rerun}{000010} \fi
  \ifx\papermasformat\papermas@undefined        \addtocounter{papermas@rerun}{000100} \fi
  \ifx\papermasmasss\papermas@undefined         \addtocounter{papermas@rerun}{001000} \fi
  \ifx\papermaspagespersheet\papermas@undefined \addtocounter{papermas@rerun}{010000} \fi
  \ifx\papermassheets\papermas@undefined        \addtocounter{papermas@rerun}{100000} \fi
  }

%    \end{macrocode}
%
% If any one of those commands is undefined, |papermas@rerun| is $>1$,
% and we know that we need another compiler run.\\
%
% \end{macro}
%
% \begin{macro}{\AfterLastShipout}
% What we did not do yet, is to really \textit{call} the command
% |\papermas@totmass|.\linebreak
% We do this |\AfterLastShipout|, because we need the total number of pages,
% and asking for them at the end of the document might save another
% compilation run.
%
%    \begin{macrocode}
\AfterLastShipout{%
  \papermas@totmass%
  }%

%    \end{macrocode}
%
% |\AfterLastShipout| is a command from the \textsf{atveryend}
% package of Heiko Oberdiek, which is already loaded by my
% \textsf{pagesLTS} package (about how to get the \textsf{atveryend}
% package, please see the documentation of the \textsf{pagesLTS}
% package -- you may need to get further packages for
% \textsf{pagesLTS} anyway, if they have not been installed
% within your \LaTeX\ system).
%
% \end{macro}
%
% \begin{macro}{\AtVeryEndDocument}
%
%    \begin{macrocode}
\AtVeryEndDocument{%
%    \end{macrocode}
%
% \indent |\AtVeryEndDocument{...}| is even later:
% \begin{quote}
% \textquotedblleft The code is called after the \xext{aux} file
% is closed and read in again. It is the place for final checks,
% rerun hints, final messages.\textquotedblright
% \end{quote}
% (\textsf{atveryend} package of Heiko Oberdiek, v1.5 as of 2010/03/24)\\
%
% \DescribeMacro{Error code}
% Here it is used to give a rerun warning, when it is needed:
%
%    \begin{macrocode}
  \ifnum\value{papermas@rerun}>0
    \PackageWarningNoLine{papermas}{!\MessageBreak%
      Variable(s) still undefined.\MessageBreak%
      (Error code \arabic{papermas@rerun}.)\MessageBreak%
      Rerun to get the variable(s) right.\MessageBreak%
    }%
%    \end{macrocode}
%
% \pagebreak
%
% The \textquotedblleft Error code\textquotedblright\ can be deciphered as follows:\\
%
% |\papermasstotal         000001|\\
% \indent |\papermasstotal         000010|\\
% \indent |\papermasformat         000100|\\
% \indent |\papermasmasss          001000|\\
% \indent |\papermaspagespersheet  010000|\\
% \indent |\papermassheets         100000|\\
%
% e.\,g. error code |1001| is |001001| is |\papermasmasss| and |\papermasstotal|.\\
%
% If no necessarity for a rerun was \textit{detected} (Check for other rerun warnings!),
% the final |\PackageInfo| is given:
%
%    \begin{macrocode}
  \else
    \message{papermas: ***************************************************}
    \message{papermas: * This document consists of \arabic{pagesLTS.pagenr} pages. *}
    \message{papermas: * When printing \papermaspagespersheet\space pages on one sheet of paper, *}
    \message{papermas: * \papermassheets\space sheets will be needed. *}
    \message{papermas: * For ISO A \papermasformat\space paper of \papermasmasss\space g/m^2 specific mass, *}
    \message{papermas: * the printout will have a mass of about \papermasstotal\space g. *}
    \message{papermas: ***************************************************}
    \PackageInfo{papermas}{***************************************************\MessageBreak%
      * This document consists of \arabic{pagesLTS.pagenr} pages. *\MessageBreak%
      * When printing \papermaspagespersheet\space pages on one sheet of paper, *\MessageBreak%
      * \papermassheets\space sheets will be needed. *\MessageBreak%
      * For ISO A \papermasformat\space paper of \papermasmasss\space g/m^2 specific mass, *\MessageBreak%
      * the printout will have a mass of about \papermasstotal\space g. *\MessageBreak%
      ***************************************************\MessageBreak%
    }%
  \fi%
  }

%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \newpage
%
% \section{Installation}
%
% \subsection{Downloads\label{ss:Downloads}}
%
% Everything should be available on \CTAN{}, \url{ftp://ftp.ctan.org/tex-archive/},
% but may need additional packages themselves.\\
%
% \DescribeMacro{papermas.dtx}
% For unpacking the |papermas.dtx| file and constructing the documentation it is required:
% \begin{description}
% \item[-] \TeX Format \LaTeXe, 1994/06/01, v2$\varepsilon $: \CTAN{}
%
% \item[-] document class \textsf{ltxdoc}, 2007/11/11, v2.0u,\\
%           \CTAN{macros/latex/base/ltxdoc.dtx}
%
% \item[-] package \textsf{holtxdoc}, 2010/04/24, v0.19,\\
%           \CTAN{macros/latex/contrib/oberdiek/holtxdoc.dtx}
%
% \item[-] package \textsf{hypdoc}, 2010/03/26, v1.9,\\
%           \CTAN{macros/latex/contrib/oberdiek/hypdoc.dtx}
% \end{description}
%
% \DescribeMacro{papermas.sty}
% The |papermas.sty| for \LaTeXe\ (i.\,e. all documents using
% the \textsf{papermas} package) requires:
% \begin{description}
% \item[-] \TeX Format \LaTeXe, 1994/06/01, v2$\varepsilon $, \CTAN{}
%
% \item[-] package \textsf{kvoptions}, 2010/02/22, v3.7,\\
%           \CTAN{macros/latex/contrib/oberdiek/kvoptions.dtx}
%
% \item[-] package \textsf{pagesLTS}, 2010/06/24, v1.1c,\\
%           \CTAN{macros/latex/contrib/pagesLTS/pagesLTS.dtx}\\
% \end{description}
%
% \DescribeMacro{papermas-example.tex}
% The |papermas-example.tex| requires the same files as all
% documents using the \textsf{papermas} package, especially:
% \begin{description}
% \item[-] package \textsf{papermas}, 2010/06/24, v1.0c,\\
%           \CTAN{macros/latex/contrib/papermas/papermas.dtx}\\
%   (Well, it is the example file for this package, and because you are reading the
%    documentation for the \textsf{papermas} package, it can be assumed that you already
%    have some version of it -- is it the current one?)
% \end{description}
%
% \DescribeMacro{totpages}
% As possible alternatives in section \ref{sec:Alternatives} there are listed
% \begin{description}
% \item[-] package \textsf{totpages}, 2005/09/19, v2.00,\\
%           \CTAN{macros/latex/contrib/totpages/totpages.dtx}
% \end{description}
%
% \DescribeMacro{Oberdiek}
% \DescribeMacro{holtxdoc}
% \DescribeMacro{atveryend}
% \DescribeMacro{kvoptions}
% All packages of Heiko Oberdiek's bundle `oberdiek'
% (especially \textsf{holtxdoc}, \textsf{atveryend}, \textsf{kvoptions})
% are also available in a TDS compliant ZIP archive:\\
% \CTAN{install/macros/latex/contrib/oberdiek.tds.zip}.\\
% \textbf{Warning}: holtxdoc, 2010/04/24 v0.19, requires the packages
% \begin{description}
% \item[-] hypdoc, 2010/03/26, v1.9
% \item[-] hyperref, 2010/03/30, v6.80u (latest: 2010/06/04, v6.81f)
% \item[-] pdftexcmds, 2010/04/01, v0.9
% \item[-] ltxcmds, 2010/03/09, v1.4 (latest: 2010/04/26, v1.7)
% \item[-] hologo, 2010/04/24, v1.2
% \item[-] array (latest: 2008/09/09, v2.4c)
% \end{description}
% (or more recent versions) and does neither work with
% nor check for earlier versions!\\
% (It is probably best to download\\
% \CTAN{install/macros/latex/contrib/oberdiek.tds.zip}
% and use this, because the packages in there should be both
% recent and compatible.)\\
%
% \pagebreak
%
% \DescribeMacro{M\"{u}nch}
% Packages of mine:\\
% \begin{description}
% \item[undolabl] 2010/06/24, v1.0c, \CTAN{macros/latex/contrib/undolabl.dtx}\\
%  That package allows to override existing labels, especially automatically generated ones.
%
% \item[pagesLTS] 2010/06/24, v1.1c, \CTAN{macros/latex/contrib/pagesLTS.dtx}\\
%  That package allows to refer to the (very) last page, gives the total number of
%  pages, references to special pages, facilitates the use of nearly any pagenumbering
%  you like (e.\,g. negative |Roman| numbers or more than |Z| pages with |Alph| page numbering),
%  and works even with |fnsymbol| page numbers.
%
% \item[papermas] 2010/06/24, v1.0c, \CTAN{macros/latex/contrib/papermas.dtx}\\
%  The package described in this very documentation.
%
% \item[hrefhide] 2010/06/24, v1.0c, \CTAN{macros/latex/contrib/hrefhide.dtx}\\
%  That package allows to \textquotedblleft hide\textquotedblright\ some (hyperlinked)
%  text when printing the document while keeping the layout.
% \end{description}
%
% \subsection{Package, unpacking TDS}
%
% \paragraph{Package.} This package is available on \CTAN{}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/papermas/papermas.dtx}]\hspace*{0.1cm} \\
%           The source file.
% \item[\CTAN{macros/latex/contrib/papermas/papermas.ins}]\hspace*{0.1cm} \\
%           The installation file.
% \item[\CTAN{macros/latex/contrib/papermas/papermas.drv}]\hspace*{0.1cm} \\
%           The driver to generate the documentation.
% \item[\CTAN{macros/latex/contrib/papermas/ltxdoc.cfg}]\hspace*{0.1cm} \\
%           The \LaTeX documentation configuration file, also for generating the documentation.
% \item[\CTAN{macros/latex/contrib/papermas/papermas.pdf}]\hspace*{0.1cm} \\
%           The documentation.
% \item[\CTAN{macros/latex/contrib/papermas/papermas.sty}]\hspace*{0.1cm} \\
%           The \xext{sty}le file.
% \item[\CTAN{macros/latex/contrib/papermas/papermas-example.tex}]\hspace*{0.1cm} \\
%           The example file.
% \item[\CTAN{macros/latex/contrib/papermas/papermas-example.pdf}]\hspace*{0.1cm} \\
%           The compiled example file, as it should look like.
% \item[\CTAN{install/macros/latex/contrib/papermas/papermas.tds.zip}]\hspace*{0.1cm} \\
%           Everything in TDS compliant, compiled format (submitted, should become available soon).
% \end{description}
%
% For required other packages, see the preceding subsection.
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex papermas.dtx|
% \end{quote}
%
% About generating the documentation see paragraph~\ref{GenDoc} below.\\
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   papermas.sty & tex/latex/muench/papermas.sty\\
%   papermas.pdf & doc/latex/muench/papermas.pdf\\
%   papermas-example.tex & doc/latex/muench/papermas-example.tex\\
%   papermas-example.pdf & doc/latex/muench/papermas-example.pdf\\
%   papermas.dtx & source/latex/muench/papermas.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution (\teTeX, \mikTeX,\dots) relies on file name
% databases, you must refresh these. For example, \teTeX\ users run
% \verb|texhash| or \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{papermas.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.\label{GenDoc}}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put the following
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
%
% \noindent An example follows how to generate the
% documentation with \pdfLaTeX :
%
% \begin{quote}
%\begin{verbatim}
%pdflatex papermas.dtx
%makeindex -s gind.ist papermas.idx
%pdflatex papermas.dtx
%makeindex -s gind.ist papermas.idx
%pdflatex papermas.dtx
%\end{verbatim}
% \end{quote}
%
% \subsection{Compiling the example}
%
% The example file, \textsf{papermas-example.tex}, can be compiled via\\
% \indent |latex papermas-example.tex|\\
% or (recommended)\\
% \indent |pdflatex papermas-example.tex|\\
% but will need probably three compiler runs to get everything right.
%
% \section{Things suggested to be done\label{sec:todo}}
%
% \begin{itemize}
%  \item Include a correct checksum for \textsf{papermas}.
%  \item Insert the final reference where to get the \xfile{tds.zip} file at \CTAN{}.
% \end{itemize}
%
% \section{Acknowledgements}
%
% I (H.-Martin M\"{u}nch) would like to thank Heiko Oberdiek
% (heiko dot oberdiek at googlemail dot com) for providing
% a~lot~(!) of useful packages (from which I also got everything I
% know about creating a file in \xfile{dtx} format, ok, say it: copying),
% and the \Newsgroup{comp.text.tex} and \Newsgroup{de.comp.text.tex}
% newsgroups for their help in all things \TeX.
%
% \phantomsection
% \begin{History}\label{History}
%   \begin{Version}{2010/06/01 v1.0}
%     \item First version of this package.
%   \end{Version}
%   \begin{Version}{2010/06/03 v1.0b}
%     \item New |\papermassheets| and reruncheck introduced; several small changes.
%     \item Example adapted to other examples of mine.
%     \item Updated references to other packages.
%     \item TDS locations updated.
%     \item Several changes in the documentation and the Readme file.
%   \end{Version}
%   \begin{Version}{2010/06/24 v1.0c}
%     \item \textsf{holtxdoc} warning in \xfile{drv} updated.
%     \item Corrected the location of the package at CTAN.\\
%            (TDS still missing due to packaging error.)
%     \item Updated references to other packages: \textsf{hyperref} and \textsf{pagesLTS}.
%     \item Added a list of my other packages.
%     \item Several changes to the documentation.
%     \item Introduced new \textbf{option}: |decimalsep|.
%   \end{Version}
% \end{History}
%
% % \PrintChanges
%
% \bigskip
%
% When you find a mistake or have a suggestion for an improvement of this package,
% please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
%
% \pagebreak
%
% \PrintIndex
%
% \Finale
%
\endinput