| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: papermas.dtx |
| 4 |
% Version: 2023-04-12 v1.1a |
| 5 |
% Info: Computes paper mass of a printout |
| 6 |
% |
| 7 |
% Copyright © 2010 - 2023 by |
| 8 |
% H.-Martin Münch <Martin dot Muench at Uni-Bonn dot de> |
| 9 |
% |
| 10 |
% This work may be distributed and/or modified under the |
| 11 |
% conditions of the LaTeX Project Public License, either |
| 12 |
% version 1.3c of this license or (at your option) any later |
| 13 |
% version. This version of this license is in |
| 14 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 15 |
% and the latest version of this license is in |
| 16 |
% https://www.latex-project.org/lppl.txt |
| 17 |
% and version 1.3c or later is part of all distributions of |
| 18 |
% LaTeX version 2005-12-01 or later. |
| 19 |
% |
| 20 |
% This work has the LPPL maintenance status "maintained". |
| 21 |
% |
| 22 |
% The Current Maintainer of this work is H.-Martin Münch. |
| 23 |
% |
| 24 |
% This work consists of the main source file papermas.dtx |
| 25 |
% the README, and the derived files |
| 26 |
% papermas.sty, papermas.pdf, |
| 27 |
% papermas.ins, papermas.drv, |
| 28 |
% papermas-example.tex, papermas-example.pdf. |
| 29 |
% |
| 30 |
% "papermas" is available on CTAN: |
| 31 |
% https://ctan.org/pkg/papermas |
| 32 |
% |
| 33 |
% Also a TDS.ZIP file is provided that contains all the files |
| 34 |
% already sorted in a TDS tree: |
| 35 |
% https://mirror.ctan.org/install/macros/latex/contrib/papermas.tds.zip |
| 36 |
% |
| 37 |
%<*ignore> |
| 38 |
\begingroup |
| 39 |
\catcode123=1 % |
| 40 |
\catcode125=2 % |
| 41 |
\def\x{LaTeX2e}% |
| 42 |
\expandafter\endgroup |
| 43 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 44 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 45 |
\ifx\fmtname\x\else 1\fi\relax |
| 46 |
\else\csname fi\endcsname |
| 47 |
%</ignore> |
| 48 |
%<*install> |
| 49 |
\input docstrip.tex |
| 50 |
\Msg{*****************************************************************************} |
| 51 |
\Msg{* Installation *} |
| 52 |
\Msg{* Package: papermas 2023-04-12 v1.1a Computes paper mass of a printout (HMM)*} |
| 53 |
\Msg{*****************************************************************************} |
| 54 |
|
| 55 |
\keepsilent |
| 56 |
\askforoverwritefalse |
| 57 |
|
| 58 |
\let\MetaPrefix\relax |
| 59 |
\preamble |
| 60 |
|
| 61 |
This is a generated file. |
| 62 |
|
| 63 |
Project: papermas |
| 64 |
Version: 2023-04-12 v1.1a |
| 65 |
Info: Computes paper mass of a printout |
| 66 |
|
| 67 |
Copyright (C) 2010 - 2023 by |
| 68 |
H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de> |
| 69 |
|
| 70 |
This work may be distributed and/or modified under the |
| 71 |
conditions of the LaTeX Project Public License, either |
| 72 |
version 1.3c of this license or (at your option) any later |
| 73 |
version. This version of this license is in |
| 74 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 75 |
and the latest version of this license is in |
| 76 |
https://www.latex-project.org/lppl.txt |
| 77 |
and version 1.3c or later is part of all distributions of |
| 78 |
LaTeX version 2005-12-01 or later. |
| 79 |
|
| 80 |
This work has the LPPL maintenance status "maintained". |
| 81 |
|
| 82 |
The Current Maintainer of this work is H.-Martin Muench. |
| 83 |
|
| 84 |
This work consists of the main source file papermas.dtx |
| 85 |
the README, and the derived files |
| 86 |
papermas.sty, papermas.pdf, |
| 87 |
papermas.ins, papermas.drv, |
| 88 |
papermas-example.tex, papermas-example.pdf. |
| 89 |
|
| 90 |
In memoriam |
| 91 |
Claudia Simone Barth + 1996-01-30 |
| 92 |
Tommy Muench + 2014-01-02 |
| 93 |
Hans-Klaus Muench + 2014-08-24 |
| 94 |
|
| 95 |
\endpreamble |
| 96 |
\let\MetaPrefix\DoubleperCent |
| 97 |
|
| 98 |
\generate{% |
| 99 |
\file{papermas.ins}{\from{papermas.dtx}{install}}% |
| 100 |
\file{papermas.drv}{\from{papermas.dtx}{driver}}% |
| 101 |
\usedir{tex/latex/papermas}% |
| 102 |
\file{papermas.sty}{\from{papermas.dtx}{package}}% |
| 103 |
\usedir{doc/latex/papermas}% |
| 104 |
\file{papermas-example.tex}{\from{papermas.dtx}{example}}% |
| 105 |
} |
| 106 |
|
| 107 |
\catcode32=13\relax% active space |
| 108 |
\let =\space% |
| 109 |
\Msg{************************************************************************} |
| 110 |
\Msg{*} |
| 111 |
\Msg{* To finish the installation you have to move the following} |
| 112 |
\Msg{* file into a directory searched by TeX:} |
| 113 |
\Msg{*} |
| 114 |
\Msg{* papermas.sty} |
| 115 |
\Msg{*} |
| 116 |
\Msg{* To produce the documentation run the file `papermas.drv'} |
| 117 |
\Msg{* through (pdf)LaTeX, e.g.} |
| 118 |
\Msg{* pdflatex papermas.drv} |
| 119 |
\Msg{* makeindex -s gind.ist papermas.idx} |
| 120 |
\Msg{* pdflatex papermas.drv} |
| 121 |
\Msg{* makeindex -s gind.ist papermas.idx} |
| 122 |
\Msg{* pdflatex papermas.drv} |
| 123 |
\Msg{*} |
| 124 |
\Msg{* At least two runs are necessary e.g. to get the} |
| 125 |
\Msg{* references right!} |
| 126 |
\Msg{*} |
| 127 |
\Msg{* Happy TeXing!} |
| 128 |
\Msg{*} |
| 129 |
\Msg{************************************************************************} |
| 130 |
|
| 131 |
\endbatchfile |
| 132 |
%</install> |
| 133 |
%<*ignore> |
| 134 |
\fi |
| 135 |
%</ignore> |
| 136 |
% |
| 137 |
% \section{The documentation driver file} |
| 138 |
% |
| 139 |
% The next bit of code contains the documentation driver file for |
| 140 |
% \TeX, i.\,e., the file that will produce the documentation you |
| 141 |
% are currently reading. It will be extracted from this file by the |
| 142 |
% \texttt{docstrip} programme. That is, run \LaTeX{} on \texttt{docstrip} |
| 143 |
% and specify the \texttt{driver} option when \texttt{docstrip} |
| 144 |
% asks for options. |
| 145 |
% |
| 146 |
% \begin{macrocode} |
| 147 |
%<*driver> |
| 148 |
\NeedsTeXFormat{LaTeX2e}[2022-11-01] |
| 149 |
\ProvidesFile{papermas.drv}% |
| 150 |
[2023-04-12 v1.1a Computes paper mass of a printout (HMM)] |
| 151 |
\documentclass[landscape]{ltxdoc}[2022/06/22]% v2.1i Standard LaTeX documentation class |
| 152 |
\usepackage{geometry}[2020/01/02]% v5.9 Page Geometry |
| 153 |
\usepackage{holtxdoc}[2019/12/09]% v0.30 Private additional ltxdoc support (HO) |
| 154 |
\hypersetup{% |
| 155 |
pdfsubject={Computing paper mass of a printout (HMM)},% |
| 156 |
pdfkeywords={LaTeX, papermas, papermass, paper mass, paper, mass, weight},% |
| 157 |
pdfencoding=auto,% |
| 158 |
pdflang={en},% |
| 159 |
breaklinks=true,% |
| 160 |
linktoc=all,% |
| 161 |
pdfstartview=FitH,% |
| 162 |
pdfpagelayout=OneColumn,% |
| 163 |
bookmarksnumbered=true,% |
| 164 |
bookmarksopen=true,% |
| 165 |
bookmarksopenlevel=3,% |
| 166 |
pdfmenubar=true,% |
| 167 |
pdftoolbar=true,% |
| 168 |
pdfwindowui=true,% |
| 169 |
pdfnewwindow=true% |
| 170 |
} |
| 171 |
\CodelineIndex |
| 172 |
\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n} |
| 173 |
\DeclareRobustCommand{\unit}[1]{\ensuremath{\mathord{\thinspace\mathup{#1}}}} |
| 174 |
\hyphenation{docu-ment} |
| 175 |
\begin{document} |
| 176 |
\DocInput{papermas.dtx}% |
| 177 |
\end{document} |
| 178 |
%</driver> |
| 179 |
% \end{macrocode} |
| 180 |
% \fi |
| 181 |
% |
| 182 |
% \GetFileInfo{papermas.drv} |
| 183 |
% |
| 184 |
% \begingroup |
| 185 |
% \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}% |
| 186 |
% \makeatletter |
| 187 |
% \@onelevel@sanitize\x |
| 188 |
% \expandafter\endgroup |
| 189 |
% \expandafter\DoNotIndex\expandafter{\x} |
| 190 |
% \expandafter\DoNotIndex\expandafter{\string\ } |
| 191 |
% \begingroup |
| 192 |
% \makeatletter |
| 193 |
% \lccode`9=32\relax |
| 194 |
% \lowercase{%^^A |
| 195 |
% \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A |
| 196 |
% }%^^A |
| 197 |
% \expandafter\endgroup\x |
| 198 |
% \DoNotIndex{\,,\@abspage@last,\@auxout,\@bsphack,\@esphack,\@ifundefined,\addtocounter,\AddToHook,\arabic,\begin,\end} |
| 199 |
% \DoNotIndex{\bigskip,\DeclareMathAlphabet,\DeclareRobustCommand,\DeclareStringOption,\divide,\documentclass,\ensuremath} |
| 200 |
% \DoNotIndex{\familydefault,\format,\gdef,\if@filesw,\ifnum,\ifx,\immediate,\intcalcDiv,\intcalcPow,\listfiles,\m@ne} |
| 201 |
% \DoNotIndex{\markboth,\mathord,\mathup,\maxdimen,\message,\MessageBreak,\multiply,\NeedsTeXFormat,\newcounter,\newline} |
| 202 |
% \DoNotIndex{\newpage,\number,\PackageError,\PackageWarningNoLine,\pagenumbering,\papermas@decimalsep,\papermas@format} |
| 203 |
% \DoNotIndex{\papermas@log,\papermas@masss,\papermas@mbs,\papermas@pagespersheet,\papermas@powerof,\papermas@rerun} |
| 204 |
% \DoNotIndex{\papermas@space,\papermas@spaces,\papermas@totmass,\papermas@undefined,\papermassEmpty,\papermassETest} |
| 205 |
% \DoNotIndex{\papermassmd,\papermastmpformat,\papermastmpmasss,\papermastmppagespersheet,\papermastmpr,\papermastmps} |
| 206 |
% \DoNotIndex{\papermastmpt,\pdfinfo,\ProcessKeyvalOptions,\ProvidesPackage,\RequirePackage,\section,\setcounter} |
| 207 |
% \DoNotIndex{\SetupKeyvalOptions,\space,\textbf,\textsf,\texttt,\the,\thepage,\thinspace,\usepackage,\value,\write,\z@} |
| 208 |
% |
| 209 |
% \title{The \xpackage{papermas} package} |
| 210 |
% \date{2023-04-12 v1.1a} |
| 211 |
% \author{H.-Martin Münch\\\xemail{Martin.Muench at Uni-Bonn.de}} |
| 212 |
% |
| 213 |
% \maketitle |
| 214 |
% |
| 215 |
% \begin{abstract} |
| 216 |
% \noindent This \LaTeX{} package allows to compute the number of sheets of paper needed |
| 217 |
% to print a document as well as the mass of that printed version of the document, |
| 218 |
% useful e.\,g. to determine the postage when sending it by snail mail. |
| 219 |
% \end{abstract} |
| 220 |
% |
| 221 |
% \bigskip |
| 222 |
% |
| 223 |
% \noindent Disclaimer for web links: The author is not responsible for any contents |
| 224 |
% referred to in this work unless having full knowledge of illegal contents. |
| 225 |
% If any damage occurs by the use of information presented there, |
| 226 |
% only the author of the respective pages might be liable, |
| 227 |
% not the one who has referred to those pages. |
| 228 |
% |
| 229 |
% |
| 230 |
% \tableofcontents |
| 231 |
% |
| 232 |
% \section{Introduction} |
| 233 |
% \indent This \LaTeX{} package allows to compute the number of sheets of paper |
| 234 |
% needed to print a document (useful when the paper is running out) |
| 235 |
% as well as the mass of that printed version of the document, |
| 236 |
% useful e.\,g. to determine the postage when sending it by snail mail.\\ |
| 237 |
% \indent \textbf{Warning/Disclaimer}: The mass of (printer's) ink has to be added |
| 238 |
% and that of envelope, address sticker, stamps,\ldots\space |
| 239 |
% Thus this is only an estimation without guarantee -- |
| 240 |
% do not sue me, if you have got to pay excess postage!\\ |
| 241 |
% \indent The name \xpackage{papermas} is short for paper mass but written with only one \textsf{s}, |
| 242 |
% because historically some software had problems with names with more than eight letters.\\ |
| 243 |
% It is \textsf{mass} and gives a result in grammes $\left[ \unit{g}\right]$, |
| 244 |
% because the weight $F=m\cdot g$ (really $\overrightarrow{F}=m\cdot \overrightarrow{g}$) |
| 245 |
% $\left[ \unit{N}\right]$ would require the knowledge of the gravitational acceleration |
| 246 |
% $g$ (depending on place and time, in central Europe approximately $9.81\unit{m}/\unit{s}^{2}$) |
| 247 |
% and give a result in \textsc{Newton}, which probably is not very useful. |
| 248 |
% |
| 249 |
% \section{Usage} |
| 250 |
% \indent Just load the package placing |
| 251 |
% \begin{quote} |
| 252 |
% |\usepackage[<|\textit{options}|>]{papermas}| |
| 253 |
% \end{quote} |
| 254 |
% \noindent in the preamble of your \LaTeXe{} source file.\\ |
| 255 |
% Now you can say |
| 256 |
% \begin{verbatim} |
| 257 |
% This document consists of $\papermassPages$~pages. |
| 258 |
% When printing $\papermaspagespersheet$~pages on one sheet of |
| 259 |
% paper, $\papermassheets$~sheets will be needed. For |
| 260 |
% ISO~A~\papermasformat{} paper of $\papermasmasss \unit{g}/\!\unit{m}^{2}$ |
| 261 |
% specific mass, the printout will have a mass of about |
| 262 |
% $\papermasstotal \unit{g}$. |
| 263 |
% \end{verbatim} |
| 264 |
% to get e.\,g. |
| 265 |
% \begin{quote} |
| 266 |
% This document consists of $101$~pages. |
| 267 |
% When printing $4$~pages on one sheet of |
| 268 |
% paper, $26$~sheets will be needed. For |
| 269 |
% ISO~A~4 paper of $80\unit{g}/\!\unit{m}^{2}$ |
| 270 |
% specific mass, the printout will have a mass of about |
| 271 |
% $130\unit{g}$. |
| 272 |
% \end{quote} |
| 273 |
% This information is also presented at the screen while compiling your document |
| 274 |
% (look for \xpackage{papermas}),\newline |
| 275 |
% in the \xfile{log} file (search for \hbox{\textsf{***~Paper~mass~***}),} |
| 276 |
% and can be found near the end of the \xfile{aux} file. |
| 277 |
% |
| 278 |
% \subsection{Options} |
| 279 |
% \DescribeMacro{options} |
| 280 |
% \indent The \xpackage{papermas} package takes the following options: |
| 281 |
% |
| 282 |
% \subsubsection{format} |
| 283 |
% \DescribeMacro{format} |
| 284 |
% \indent The option \texttt{format} wants to know the \hbox{ISO~A\ldots} |
| 285 |
% format of the paper used for printing, i.\,e. |format=4| means ISO~A4 |
| 286 |
% paper format (which is also the default). |
| 287 |
% |
| 288 |
% \subsubsection{masss} |
| 289 |
% \DescribeMacro{masss} |
| 290 |
% \indent The option \texttt{masss} wants to know the specific |
| 291 |
% (therefore the third~\texttt{s}) mass of the paper used for printing |
| 292 |
% in $\unit{g}/\!\unit{m}^{2}$. The default is |masss=80|, |
| 293 |
% i.\,e. $80\unit{g}/\!\unit{m}^{2}$. |
| 294 |
% |
| 295 |
% \subsubsection{pagespersheet} |
| 296 |
% \DescribeMacro{pagespersheet} |
| 297 |
% \indent The option \texttt{pagespersheet} wants to know, how many |
| 298 |
% pages are to be printed on one sheet of paper. |
| 299 |
% |pagespersheet=2| could mean duplex printing or printing two pages |
| 300 |
% on one side of paper while keeping the back side blank. This |
| 301 |
% does not influence the real printing process! So, if this number |
| 302 |
% differs from the one chosen for printing, the result will be wrong, |
| 303 |
% of course. |
| 304 |
% |
| 305 |
% \subsubsection{decimalsep} |
| 306 |
% \DescribeMacro{decimalsep} |
| 307 |
% \indent The option \texttt{decimalsep} wants to know, |
| 308 |
% what should be used for the decimal separator. In English this is |
| 309 |
% \textquotedblleft .\textquotedblright , while in German it is |
| 310 |
% \textquotedblleft ,\textquotedblright . Enclose this in brackets, |
| 311 |
% e.\,g.~|decimalsep={.}| or |decimalsep={,}|. The default is |
| 312 |
% \textquotedblleft .\textquotedblright . This is used for the |
| 313 |
% mass of the printed document, and this value is given at |
| 314 |
% the screen during compilation as well as in the \xfile{log} |
| 315 |
% and \xfile{aux} files. Therefore something like |
| 316 |
% |decimalsep={,\,}| would cause trouble there. |
| 317 |
% |
| 318 |
% \section{Alternatives\label{sec:Alternatives}} |
| 319 |
% With the \xpackage{totpages} package optionally the number of |
| 320 |
% sheets of paper needed to print the document can be computed, |
| 321 |
% but not the mass; \url{https://ctan.org/pkg/totpages}. |
| 322 |
% |
| 323 |
% \bigskip |
| 324 |
% |
| 325 |
% \noindent You programmed or found another alternative, |
| 326 |
% which is available at \url{https://www.CTAN.org/}? |
| 327 |
% OK, send an e-mail to me with the name, location at CTAN, |
| 328 |
% and a short notice, and I will probably include it in the list above. |
| 329 |
% |
| 330 |
% \section{Example} |
| 331 |
% \begin{macrocode} |
| 332 |
%<*example> |
| 333 |
\NeedsTeXFormat{LaTeX2e}[2022-11-01] |
| 334 |
\documentclass[british,a4paper]{article}[2022/07/02]% v1.4n Standard LaTeX document class |
| 335 |
\pdfinfo{ |
| 336 |
/Author (H.-Martin Muench) |
| 337 |
/Title (papermas package example) |
| 338 |
/Subject (Example for the papermas package) |
| 339 |
/Keywords (LaTeX;papermas;papermass;paper mass;paper;mass;weight) |
| 340 |
} |
| 341 |
\usepackage[format=4,masss=80,pagespersheet=2,decimalsep={.}]{papermas}[2023-04-12] |
| 342 |
%% v1.1a Computes paper mass of a printout (HMM) |
| 343 |
%% These are the default options. |
| 344 |
\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n} |
| 345 |
\DeclareRobustCommand{\unit}[1]{\ensuremath{\mathord{\thinspace\mathup{#1}}}} |
| 346 |
\listfiles |
| 347 |
\begin{document} |
| 348 |
\pagenumbering{arabic} |
| 349 |
\section*{Example for papermas} |
| 350 |
\markboth{Example for papermas}{Example for papermas} |
| 351 |
|
| 352 |
This example demonstrates the use of package\newline |
| 353 |
\textsf{papermas}, v1.1a as of 2023-04-12 (HMM).\newline |
| 354 |
The used options were \texttt{format=4} (ISO~A4), |
| 355 |
\texttt{masss=80} ($\unit{g}\unit{m}^{-2}$), and\newline |
| 356 |
\texttt{pagespersheet=2} (pages per sheet of paper, |
| 357 |
i.\,e. either duplex printing or\newline |
| 358 |
printing two pages on one side of a sheet of paper with blank back side).\newline |
| 359 |
(These are the default options.)\newline |
| 360 |
For more details please see the documentation! |
| 361 |
\bigskip |
| 362 |
|
| 363 |
This document consists of $\papermassPages$~pages. |
| 364 |
When printing $\papermaspagespersheet$~pages on one sheet of paper, |
| 365 |
$\papermassheets$~sheets will be needed. For ISO~A~\papermasformat{} |
| 366 |
paper of $\papermasmasss \unit{g}\unit{m}^{-2}$ specific mass, |
| 367 |
the printout will have a mass of about $\papermasstotal \unit{g}$. |
| 368 |
|
| 369 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 370 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 371 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 372 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 373 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 374 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 375 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 376 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 377 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 378 |
\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage\newpage Page \thepage |
| 379 |
\newpage Last page \thepage. |
| 380 |
\end{document} |
| 381 |
%</example> |
| 382 |
% \end{macrocode} |
| 383 |
% \StopEventually{} |
| 384 |
% |
| 385 |
% \section{The implementation} |
| 386 |
% We start off by checking that we are loading into \LaTeXe{} and announcing the name and version of this package. |
| 387 |
% \begin{macrocode} |
| 388 |
%<*package> |
| 389 |
% \end{macrocode} |
| 390 |
% \begin{macrocode} |
| 391 |
\NeedsTeXFormat{LaTeX2e}[2022-11-01] |
| 392 |
\ProvidesPackage{papermas}[2023-04-12 v1.1a Computes paper mass of a printout (HMM)] |
| 393 |
|
| 394 |
% \end{macrocode} |
| 395 |
% |
| 396 |
% A short description of the \xpackage{papermas} package: |
| 397 |
% |
| 398 |
% \begin{macrocode} |
| 399 |
%% Allows to compute the number of sheets of paper |
| 400 |
%% needed to print a document as well as the |
| 401 |
%% mass of that printed version of the document, |
| 402 |
%% useful e.g. to determine the postage when sending it by snail mail. |
| 403 |
%% Warning/Disclaimer: Mass of (printer's) ink has to be added |
| 404 |
%% and that of envelope, address sticker, stamps,...! |
| 405 |
%% So, this is only an estimation without guarantee - |
| 406 |
%% do not sue me, if you have got to pay excess postage! |
| 407 |
|
| 408 |
% \end{macrocode} |
| 409 |
% |
| 410 |
% |\NeedsTeXFormat{LaTeX2e}[2022-11-01]| was demanded. Check for it: |
| 411 |
% |
| 412 |
% \begin{macrocode} |
| 413 |
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} |
| 414 |
|
| 415 |
\IfFormatAtLeastTF{2022/11/01}{\relax}{% |
| 416 |
\PackageError{papermas}{% |
| 417 |
Newer LaTeX format needed or older papermas package% |
| 418 |
}{Needed LaTeX format version: 2022-11-01 or newer.\MessageBreak% |
| 419 |
Found\space\space LaTeX format version: \fmtversion.\MessageBreak% |
| 420 |
Either update your TeX distribution\MessageBreak% |
| 421 |
or use an archived version of papermas\MessageBreak% |
| 422 |
(see section History in the documentation).\MessageBreak% |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
% \end{macrocode} |
| 427 |
% |
| 428 |
% For the handling of the options we need the \xpackage{kvoptions} package |
| 429 |
% and for |\intcalcPow| the \xpackage{intcalc} package: |
| 430 |
% |
| 431 |
% \begin{macrocode} |
| 432 |
\RequirePackage{kvoptions}[2022-06-15]% v3.15 Key value format for package options (HO) |
| 433 |
\RequirePackage{intcalc}[2019/12/15]% v1.3 Expandable calculations with integers (HO) |
| 434 |
|
| 435 |
% \end{macrocode} |
| 436 |
% See subsection~\ref{ss:Downloads} about how to get them.\\ |
| 437 |
% |
| 438 |
% The options are introduced: |
| 439 |
% |
| 440 |
% \begin{macrocode} |
| 441 |
\SetupKeyvalOptions{family = papermas,prefix = papermas@} |
| 442 |
\DeclareStringOption[4]{format}[4]% paper format, ISO A..., default: (ISO A) 4 |
| 443 |
\DeclareStringOption[80]{masss}[80]% specific mass of the paper, default: 80 (g/(m^2)) |
| 444 |
\DeclareStringOption[2]{pagespersheet}[2]% number of pages per sheet, for duplex printing this is 2. |
| 445 |
\DeclareStringOption[.]{decimalsep}[.]% decimal separator, |
| 446 |
%% e.g. "." or ",": decimalsep={,} - brackets are needed!!! |
| 447 |
%% decimalsep={,\,} does not work for screen, aux, log output! |
| 448 |
|
| 449 |
\ProcessKeyvalOptions* |
| 450 |
|
| 451 |
% \end{macrocode} |
| 452 |
% |
| 453 |
% We pre-define some commands as (still) undefined: |
| 454 |
% |
| 455 |
% \begin{macrocode} |
| 456 |
\def\papermas@undefined{\textbf{??}} |
| 457 |
% \end{macrocode} |
| 458 |
% |
| 459 |
% |\papermas@undefined| will also be needed later! |
| 460 |
% |
| 461 |
% \begin{macrocode} |
| 462 |
\let\papermassPages\papermas@undefined |
| 463 |
\let\papermasstotal\papermas@undefined |
| 464 |
\let\papermasformat\papermas@undefined |
| 465 |
\let\papermasmasss\papermas@undefined |
| 466 |
\let\papermaspagespersheet\papermas@undefined |
| 467 |
\let\papermassheets\papermas@undefined |
| 468 |
\let\papermas@rerun\z@ |
| 469 |
|
| 470 |
% \end{macrocode} |
| 471 |
% |
| 472 |
% \begin{macro}{\papermas@totmass} |
| 473 |
% This is the internal command, which computes the total paper mass |
| 474 |
% of the printed document. |
| 475 |
% |
| 476 |
% \begin{macrocode} |
| 477 |
\DeclareRobustCommand\papermas@totmass{% |
| 478 |
\newcounter{papermasA}% paper mass for ISO A... |
| 479 |
\setcounter{papermasA}{\papermas@format}% e.g. 4 |
| 480 |
% \end{macrocode} |
| 481 |
% |
| 482 |
% We check whether |papermasA| has a resonable value: |
| 483 |
% |
| 484 |
% \begin{macrocode} |
| 485 |
\ifnum \value{papermasA}<0% |
| 486 |
\PackageError{papermas}{Option format has no valid value}% |
| 487 |
{The format option of the papermas package\MessageBreak% |
| 488 |
only takes whole, non-negative numbers (0, 1, 2, 3,...),\MessageBreak% |
| 489 |
because this should be the paper format\MessageBreak% |
| 490 |
ISO A 0, 1, 2, 3,...\MessageBreak% |
| 491 |
Found instead: \papermas@format \MessageBreak% |
| 492 |
}% |
| 493 |
\else% |
| 494 |
% \end{macrocode} |
| 495 |
% |
| 496 |
% |papermasA| has a resonable value. We introduce a new counter |
| 497 |
% |papermasmasss| and initialize it with the value given in option |
| 498 |
% |masss|, i.\,e. |\papermas@masss|. |
| 499 |
% |
| 500 |
% \begin{macrocode} |
| 501 |
\newcounter{papermasmasss}% |
| 502 |
\setcounter{papermasmasss}{\papermas@masss}% default 80 |
| 503 |
% \end{macrocode} |
| 504 |
% |
| 505 |
% Counters are integers, but the amount of the mass of a single sheet |
| 506 |
% of paper in most cases is not an integer, therefore we multiply with |
| 507 |
% 100 to get two digits behind the decimal separator.\\ |
| 508 |
% (Later we need to divide by 100 again, of course.) |
| 509 |
% |
| 510 |
% \begin{macrocode} |
| 511 |
\multiply \value{papermasmasss} 100 % default 8000 |
| 512 |
% \end{macrocode} |
| 513 |
% |
| 514 |
% We check whether |papermasmasss| has a resonable value, i.\,e. $> 0$: |
| 515 |
% |
| 516 |
% \begin{macrocode} |
| 517 |
\ifnum \value{papermasmasss}<1% |
| 518 |
\PackageError{papermas}{Option masss has no valid value}% |
| 519 |
{The masss option of the papermas package\MessageBreak% |
| 520 |
only takes positive numbers,\MessageBreak% |
| 521 |
because this should be the mass per square meter\MessageBreak% |
| 522 |
of a single sheet of your paper.\MessageBreak% |
| 523 |
Found instead: \papermas@masss\MessageBreak% |
| 524 |
}% |
| 525 |
\else% |
| 526 |
% \end{macrocode} |
| 527 |
% |
| 528 |
% |masss| has a resonable value, and therefore also |\papermas@masss| and |papermasmasss|.\par |
| 529 |
% We check whether option |pagespersheet| has a resonable value, i.\,e. $\geq 1$: |
| 530 |
% |
| 531 |
% \begin{macrocode} |
| 532 |
\newcounter{papermasPPS}% |
| 533 |
\setcounter{papermasPPS}{\papermas@pagespersheet}% default 2 |
| 534 |
\ifnum \value{papermasPPS}<1% |
| 535 |
\PackageError{papermas}{The number of pages per sheet must be positive.}{% |
| 536 |
You cannot print less than one TeX page per sheet of paper.\MessageBreak% |
| 537 |
The value found was \papermas@pagespersheet .\MessageBreak% |
| 538 |
}% |
| 539 |
\else% |
| 540 |
% \end{macrocode} |
| 541 |
% |
| 542 |
% |pagespersheet| has a resonable value, and therefore also |\papermas@pagespersheet| and |papermasTmpA|.\par |
| 543 |
% We introduce a new counter |papermas@sheets| for the number of sheets printed.\par |
| 544 |
% |\gdef\@abspage@last{...}| has not happened yet in first run. |
| 545 |
% |
| 546 |
% \begin{macrocode} |
| 547 |
\newcounter{papermas@sheets}% |
| 548 |
\let\papermassPages\m@ne% |
| 549 |
\xdef\papermassmd{\number\maxdimen}% |
| 550 |
\ifnum \@abspage@last=\papermassmd\relax% |
| 551 |
\setcounter{papermas@sheets}{1}% |
| 552 |
\gdef\papermas@rerun{1}% |
| 553 |
\else% |
| 554 |
\setcounter{papermas@sheets}{\@abspage@last}% |
| 555 |
\xdef\papermassPages{\@abspage@last}% |
| 556 |
\fi% |
| 557 |
% \end{macrocode} |
| 558 |
% |
| 559 |
% When more than one page is printed on one sheet of paper, |
| 560 |
% the number of sheets needed for printing is decreased: |
| 561 |
% |
| 562 |
% \begin{macrocode} |
| 563 |
\divide \value{papermas@sheets} by \value{papermasPPS}% |
| 564 |
% \end{macrocode} |
| 565 |
% |
| 566 |
% |\divide| cuts off all digits behind the decimal separator, |
| 567 |
% but if there are digits $>0$, this means that there is |
| 568 |
% an additional, last sheet, which is only partially covered |
| 569 |
% with print (e.\,g. only one side of it for duplex printing |
| 570 |
% an odd number of pages). In that case, we have to add |
| 571 |
% one sheet of paper to the number of sheets needed. |
| 572 |
% |
| 573 |
% \begin{macrocode} |
| 574 |
\newcounter{papermas@tmpn}% |
| 575 |
\setcounter{papermas@tmpn}{\arabic{papermas@sheets}}% |
| 576 |
\multiply \value{papermas@tmpn} \value{papermasPPS}% |
| 577 |
\ifnum \value{papermas@tmpn}=\papermassPages% |
| 578 |
\else \addtocounter{papermas@sheets}{1}% |
| 579 |
\fi% |
| 580 |
% \end{macrocode} |
| 581 |
% |
| 582 |
% Now we can multiply the specific mass of 100 sheets |
| 583 |
% with the number of sheets needed for printing: |
| 584 |
% |
| 585 |
% \begin{macrocode} |
| 586 |
\multiply \value{papermasmasss} \value{papermas@sheets}% |
| 587 |
% default: 8000 (no default for this) |
| 588 |
% \end{macrocode} |
| 589 |
% |
| 590 |
% The result is in $\unit{g}\unit{m}^{-2}$.\\ |
| 591 |
% A sheet with format ISO A0 has a size of $1\unit{m}^{2}$,\\ |
| 592 |
% a sheet with format ISO A1 has a size of $1\unit{m}^{2}\cdot 2^{-1}$,\\ |
| 593 |
% a sheet with format ISO A2 has a size of $1\unit{m}^{2}\cdot 2^{-2}$, \ldots, and\\ |
| 594 |
% a sheet with format ISO A\textit{n} has a size of $1\unit{m}^{2}\cdot 2^{-n}$.\\ |
| 595 |
% |
| 596 |
% Therefore we compute $2^{\textrm{\textbackslash value\{papermasA\}}}$ |
| 597 |
% and divide the specific paper mass by that value: |
| 598 |
% |
| 599 |
% \begin{macrocode} |
| 600 |
\divide \value{papermasmasss} by \intcalcPow{2}{\value{papermasA}}% |
| 601 |
% default: 16000 / 2^(\value{papermasA}) |
| 602 |
% \end{macrocode} |
| 603 |
% |
| 604 |
% We need to get the division by 100 and the digits after the decimal separator right: |
| 605 |
% |
| 606 |
% \begin{macrocode} |
| 607 |
% for the example 297 is used |
| 608 |
\newcounter{papermas@tmpm}% |
| 609 |
\setcounter{papermas@tmpm}{\arabic{papermasmasss}}% m:297 n: 0 o:0 p: 0 q:0 |
| 610 |
\setcounter{papermas@tmpn}{\arabic{papermasmasss}}% m:291 n:291 o:0 p: 0 q:0 |
| 611 |
\divide \value{papermas@tmpn} by 100% m:297 n: 2 o:0 p: 0 q:0 |
| 612 |
\newcounter{papermas@tmpo}% |
| 613 |
\setcounter{papermas@tmpo}{\arabic{papermas@tmpn}}% m:291 n: 2 o:2 p: 0 q:0 |
| 614 |
\multiply \value{papermas@tmpn} 10% m:297 n: 20 o:2 p: 0 q:0 |
| 615 |
\divide \value{papermas@tmpm} by 10% m: 29 n: 20 o:2 p: 0 q:0 |
| 616 |
\newcounter{papermas@tmpp}% |
| 617 |
\setcounter{papermas@tmpp}{\arabic{papermas@tmpm}}% |
| 618 |
\addtocounter{papermas@tmpp}{-\arabic{papermas@tmpn}}%m: 29 n: 20 o:2 p: 9 q:0 |
| 619 |
% 29 - 20 = 9 |
| 620 |
\multiply \value{papermas@tmpm} 10% m:290 n: 20 o:2 p: 9 q:0 |
| 621 |
\newcounter{papermas@tmpq}% |
| 622 |
\setcounter{papermas@tmpq}{\arabic{papermasmasss}}% |
| 623 |
\addtocounter{papermas@tmpq}{-\arabic{papermas@tmpm}}%m:290 n: 20 o:2 p: 9 q:7 |
| 624 |
% 297 - 290 = 7 |
| 625 |
% \end{macrocode} |
| 626 |
% \pagebreak |
| 627 |
% |
| 628 |
% Now rounding mathematically correct, i.\,e. $\geq 0.5$ becomes $1$ |
| 629 |
% (and remember a possible amount carried forward!) and $< 0.5$ becomes~$0$. |
| 630 |
% |
| 631 |
% \begin{macrocode} |
| 632 |
\ifnum\value{papermas@tmpq}>4% |
| 633 |
\addtocounter{papermas@tmpp}{1}% m:290 n: 20 o:2 p:10 q:7 |
| 634 |
\ifnum\value{papermas@tmpp}>9% m:290 n: 20 o:2 p:10 q:7 |
| 635 |
\addtocounter{papermas@tmpo}{1}% m:290 n: 20 o:3 p:10 q:7 |
| 636 |
\setcounter{papermas@tmpp}{0}% m:290 n: 20 o:3 p: 0 q:7 |
| 637 |
\fi% |
| 638 |
\fi% |
| 639 |
\ifx\papermassPages\m@ne\relax\let\papermassPages\papermas@undefined\fi% |
| 640 |
% \end{macrocode} |
| 641 |
% |
| 642 |
% The result in the example above is $297/100=2.\,97\approx 3.\,0$. |
| 643 |
% We write this into |\papermastmpr| (where |\papermas@decimalsep|) |
| 644 |
% is the decimal separator) and the (other) options' values into |
| 645 |
% temporary definitions, as well as the number of sheets: |
| 646 |
% |
| 647 |
% \begin{macrocode} |
| 648 |
\edef\papermastmpr{\arabic{papermas@tmpo}\papermas@decimalsep\arabic{papermas@tmpp}}% |
| 649 |
\xdef\papermas@mbs{\arabic{papermas@tmpo}}% |
| 650 |
\edef\papermastmpformat{\papermas@format}% |
| 651 |
\edef\papermastmpmasss{\papermas@masss}% |
| 652 |
\edef\papermastmppagespersheet{\papermas@pagespersheet}% |
| 653 |
\edef\papermastmpt{\arabic{papermas@sheets}}% |
| 654 |
% \end{macrocode} |
| 655 |
% |
| 656 |
% We check for the counter |papermassttl|. If it exists, nothing is done, |
| 657 |
% if it does not exist, it is declared as |\newcounter| |
| 658 |
% (and by default set to zero). |
| 659 |
% |
| 660 |
% \begin{macrocode} |
| 661 |
\@ifundefined{c@papermassttl}{\newcounter{papermassttl}}{\relax}% |
| 662 |
% \end{macrocode} |
| 663 |
% |
| 664 |
% If the |papermassttl| counter value already has the value of |
| 665 |
% |papermasmasss|, everything is fine. |
| 666 |
% |
| 667 |
% \begin{macrocode} |
| 668 |
\ifnum\value{papermassttl}=\value{papermasmasss}% |
| 669 |
% \end{macrocode} |
| 670 |
% |
| 671 |
% Otherwise we need another run of \LaTeX. |
| 672 |
% |
| 673 |
% \begin{macrocode} |
| 674 |
\else\gdef\papermas@rerun{1}% |
| 675 |
\fi% |
| 676 |
% \end{macrocode} |
| 677 |
% |
| 678 |
% In any case, we set the counter |papermassttl| to the |
| 679 |
% current value of |papermasmasss|. |
| 680 |
% |
| 681 |
% \begin{macrocode} |
| 682 |
\setcounter{papermassttl}{\arabic{papermasmasss}}% |
| 683 |
% \end{macrocode} |
| 684 |
% |
| 685 |
% Because we want to write out into the \xfile{aux}-file, |
| 686 |
% we need the expanded value (as string) of |papermasmasss|: |
| 687 |
% |
| 688 |
% \begin{macrocode} |
| 689 |
\edef\papermastmps{\arabic{papermasmasss}}% |
| 690 |
% \end{macrocode} |
| 691 |
% |
| 692 |
% If we are allowed to write into the \xfile{aux}-file, we do it here. If we are not allowed to do it, |
| 693 |
% we give an error message. |
| 694 |
% |
| 695 |
% \begin{macrocode} |
| 696 |
\if@filesw% |
| 697 |
% \end{macrocode} |
| 698 |
% |
| 699 |
% When it is read from the \xfile{aux}-file and when its content is processed, the counter |papermassttl| |
| 700 |
% might not have been defined yet, in which case we define it. |
| 701 |
% |
| 702 |
% \begin{macrocode} |
| 703 |
\immediate\write\@auxout{\string\@ifundefined{c@papermassttl}{\string\newcounter{papermassttl}}{\string\relax}}% |
| 704 |
% \end{macrocode} |
| 705 |
% |
| 706 |
% We set the counter |papermassttl| to the value |\papermastmps|, i.\,e. |\arabic{papermasmasss}|. |
| 707 |
% In the next compilation run it will be checked, whether |\value{papermassttl}=\value{papermasmasss}| (see above).\\ |
| 708 |
% If this is the case, everything is OK, no changes happened, and no rerun is necessary |
| 709 |
% (at least not for \xpackage{papermas}). |
| 710 |
% |
| 711 |
% \begin{macrocode} |
| 712 |
\immediate\write\@auxout{\string\setcounter{papermassttl}{\papermastmps}}% |
| 713 |
% \end{macrocode} |
| 714 |
% |
| 715 |
% What we do need, is to get the determined |\papermastmpr| to the user. Therefore |
| 716 |
% \begin{enumerate} |
| 717 |
% \item we define |\papermasstotal| in the \xfile{aux}-file, where the user can look it up |
| 718 |
% |
| 719 |
% \item we define |\papermasstotal|, so the user can e.\,g. write\\ |
| 720 |
% \begin{verbatim} |
| 721 |
% This document consists of $\papermassPages$~pages. |
| 722 |
% When printing $\papermaspagespersheet$~pages on one sheet of |
| 723 |
% paper, $\papermassheets$~sheets will be needed. For |
| 724 |
% ISO~A~\papermasformat{} paper of $\papermasmasss \unit{g}/\!\unit{m}^{2}$ |
| 725 |
% specific mass, the printout will have a mass of about |
| 726 |
% $\papermasstotal \unit{g}$. |
| 727 |
% \end{verbatim} |
| 728 |
% |
| 729 |
% \begin{macrocode} |
| 730 |
\immediate\write\@auxout{\string\gdef\string\papermassPages{\papermassPages}}% |
| 731 |
\immediate\write\@auxout{\string\gdef\string\papermasstotal{\papermastmpr}}% |
| 732 |
\immediate\write\@auxout{\string\gdef\string\papermasformat{\papermastmpformat}}% |
| 733 |
\immediate\write\@auxout{\string\gdef\string\papermasmasss{\papermastmpmasss}}% |
| 734 |
\immediate\write\@auxout{\string\gdef\string\papermaspagespersheet{\papermastmppagespersheet}}% |
| 735 |
% \end{macrocode} |
| 736 |
% |
| 737 |
% \item we give at the screen the information about the |\papermasstotal| |
| 738 |
% |
| 739 |
% \item which will also appear in the \xfile{log}-file. |
| 740 |
%\end{enumerate} |
| 741 |
% |
| 742 |
% We want to give also |\papermastmpt = \arabic{papermas@sheets}| to the user, |
| 743 |
% i.\,e.~the number of sheets needed to print the document. Therefore we follow the same procedure: |
| 744 |
% \begin{macrocode} |
| 745 |
\immediate\write\@auxout{\string\gdef\string\papermassheets{\papermastmpt}}% |
| 746 |
\else\PackageError{papermas}{No writing to auxiliary file allowed}{% |
| 747 |
It was not allowed to write to an .aux file.\MessageBreak% |
| 748 |
This package does not work without access to an .aux file.\MessageBreak% |
| 749 |
But it is OK if the .aux file was already updated by previouse compiler runs\MessageBreak% |
| 750 |
and would not have changed anyway. In that case just press Enter or Return\MessageBreak% |
| 751 |
to continue the compilation.}% |
| 752 |
\fi% |
| 753 |
\fi% |
| 754 |
\fi% |
| 755 |
\fi% |
| 756 |
} |
| 757 |
|
| 758 |
% \end{macrocode} |
| 759 |
% \end{macro} |
| 760 |
% |
| 761 |
% For pretty printing the message of \xpackage{papermas} three internal commands are needed, needing another counter: |
| 762 |
% |
| 763 |
% \begin{macrocode} |
| 764 |
\newcounter{papermassSpace} |
| 765 |
|
| 766 |
% \end{macrocode} |
| 767 |
% \begin{macro}{\papermas@log} |
| 768 |
% \begin{macrocode} |
| 769 |
\DeclareRobustCommand{\papermas@log}[1]{% |
| 770 |
\ifnum#1>9% |
| 771 |
\addtocounter{papermassSpace}{1}% |
| 772 |
\papermas@log{\intcalcDiv{#1}{10}}% |
| 773 |
\fi% |
| 774 |
} |
| 775 |
|
| 776 |
% \end{macrocode} |
| 777 |
% \end{macro} |
| 778 |
% \begin{macro}{\papermas@spaces} |
| 779 |
% \begin{macrocode} |
| 780 |
\DeclareRobustCommand{\papermas@spaces}[2]{% |
| 781 |
\setcounter{papermassSpace}{1}% |
| 782 |
\papermas@log{#1}% |
| 783 |
\addtocounter{papermassSpace}{-#2}% |
| 784 |
\multiply\value{papermassSpace} -1% |
| 785 |
\papermas@space{\arabic{papermassSpace}}% |
| 786 |
\message{*^^J}% |
| 787 |
} |
| 788 |
|
| 789 |
% \end{macrocode} |
| 790 |
% \end{macro} |
| 791 |
% \begin{macro}{\papermas@space} |
| 792 |
% \begin{macrocode} |
| 793 |
\DeclareRobustCommand{\papermas@space}[1]{% |
| 794 |
\ifnum\value{papermassSpace}>0\relax\message{}\fi% |
| 795 |
\setcounter{papermassSpace}{#1}% |
| 796 |
\addtocounter{papermassSpace}{-1}% |
| 797 |
\ifnum\value{papermassSpace}>0\relax\papermas@space{\arabic{papermassSpace}}\fi% |
| 798 |
} |
| 799 |
|
| 800 |
% \end{macrocode} |
| 801 |
% \end{macro} |
| 802 |
% |
| 803 |
% \indent At |begindocument| it is checked whether some commands, which are/will be defined via the |
| 804 |
% \xfile{aux}-file, are undefined yet. If this is the case, at the end a rerun warning is given. |
| 805 |
% |
| 806 |
% \begin{macrocode} |
| 807 |
\AddToHook{begindocument}{% |
| 808 |
\@bsphack% |
| 809 |
\ifx\papermassPages\papermas@undefined \gdef\papermas@rerun{1}\fi% |
| 810 |
\ifx\papermasstotal\papermas@undefined \gdef\papermas@rerun{1}\fi% |
| 811 |
\ifx\papermasformat\papermas@undefined \gdef\papermas@rerun{1}\fi% |
| 812 |
\ifx\papermasmasss\papermas@undefined \gdef\papermas@rerun{1}\fi% |
| 813 |
\ifx\papermaspagespersheet\papermas@undefined\gdef\papermas@rerun{1}\fi% |
| 814 |
\ifx\papermassheets\papermas@undefined \gdef\papermas@rerun{1}\fi% |
| 815 |
\@esphack% |
| 816 |
% \end{macrocode} |
| 817 |
% |
| 818 |
% What we did not do yet, is to really \textit{call} the command |\papermas@totmass|.\newline |
| 819 |
% We do this after the last page, because we need the total number of pages. |
| 820 |
% |
| 821 |
% \begin{macrocode} |
| 822 |
\AddToHook{enddocument}{% |
| 823 |
\AddToHook{enddocument/afterlastpage}{% |
| 824 |
\papermas@totmass% |
| 825 |
% \end{macrocode} |
| 826 |
% |
| 827 |
% After the final execution of the \xfile{aux}-file, everything should be defined. |
| 828 |
% Otherwise a rerun is needed. |
| 829 |
% |
| 830 |
% \begin{macrocode} |
| 831 |
\AddToHook{enddocument/afteraux}{% |
| 832 |
\ifx\papermassPages\m@ne\relax\gdef\papermas@rerun{1}% |
| 833 |
\else\ifx\papermassPages\@abspage@last\else\gdef\papermas@rerun{1}\fi% |
| 834 |
\fi% |
| 835 |
\AddToHook{enddocument/info}[kernel/filelist]{% |
| 836 |
% \end{macrocode} |
| 837 |
% |
| 838 |
% The final |\PackageInfo| is given, either giving values or a rerun warning. |
| 839 |
% |
| 840 |
% \begin{macrocode} |
| 841 |
\message{^^J}% |
| 842 |
\message{papermas: ******************** Paper mass ********************^^J}% |
| 843 |
\ifx\papermas@rerun\z@\relax% |
| 844 |
\edef\papermassETest{\the\ReadonlyShipoutCounter\thetotalpages\PreviousTotalPages\@abspage@last}% |
| 845 |
\edef\papermassEmpty{0001}% |
| 846 |
\ifx\papermassEmpty\papermassETest\relax% |
| 847 |
\PackageWarningNoLine{papermas}{Your document seems to consists of zero pages.\MessageBreak% |
| 848 |
When printing no pages, no paper will be needed.\MessageBreak% |
| 849 |
No paper has no mass.\MessageBreak% |
| 850 |
Maybe just rerun or fix any mistakes}% |
| 851 |
\gdef\papermassPages{0}% |
| 852 |
\gdef\papermaspagespersheet{0}% |
| 853 |
\gdef\papermasstotal{0}% |
| 854 |
\else% |
| 855 |
\ifnum \papermassPages=1\relax\message{papermas: * This document consists of 1 page.}% |
| 856 |
\papermas@spaces{1}{16}% 16 because page vs. pages |
| 857 |
\else \message{papermas: * This document consists of \papermassPages\space pages.}% |
| 858 |
\papermas@spaces{\papermassPages}{15}% |
| 859 |
\fi% |
| 860 |
\ifnum \papermaspagespersheet=1\relax \message{papermas: * When printing one page on one sheet of paper,}% |
| 861 |
\papermas@spaces{100}{6}% |
| 862 |
\else \message{papermas: * When printing \papermaspagespersheet\space pages on one sheet of paper,}% |
| 863 |
\papermas@spaces{\papermaspagespersheet}{5}% |
| 864 |
\fi% |
| 865 |
\ifnum \papermassheets=1\relax \message{papermas: * one sheet will be needed.}% |
| 866 |
\papermas@spaces{100}{26}% |
| 867 |
\else \message{papermas: * \papermassheets\space sheets will be needed.}% |
| 868 |
\papermas@spaces{\papermassheets}{25}% |
| 869 |
\fi% |
| 870 |
\message{papermas: * For ISO A \papermasformat\space paper of \papermasmasss\space g/m^2 specific mass,}% |
| 871 |
\papermas@spaces{\papermasmasss}{6}% |
| 872 |
\message{papermas: * the printout will have a mass of about \papermasstotal\space g.}% |
| 873 |
\papermas@spaces{\papermas@mbs}{4}% |
| 874 |
\fi% |
| 875 |
\else \PackageWarningNoLine{papermas}{Variables have changed.\MessageBreak Rerun to get them right}% |
| 876 |
\fi% |
| 877 |
\message{papermas: ****************************************************^^J^^J}% |
| 878 |
}}}}}% |
| 879 |
% \end{macrocode} |
| 880 |
% |
| 881 |
% \begin{macro}{\papermas@powerof} |
| 882 |
% The command |\papermas@powerof| is obsolete since \xpackage{papermas} 2011/06/02 v1.0f. |
| 883 |
% As there was ample time to remove it from documents, the replacement has been removed |
| 884 |
% from the package in version 2023-04-12 v1.1a. If you really need to use it, here is the code: |
| 885 |
% \begin{verbatim} |
| 886 |
% \makeatletter% |
| 887 |
% \DeclareRobustCommand\papermas@powerof[2]{% |
| 888 |
% \@ifundefined{c@papermas@result}{\newcounter{papermas@result}}{\relax}% |
| 889 |
% \setcounter{papermas@result}{\intcalcPow{#1}{#2}}}% |
| 890 |
% \makeatother% |
| 891 |
% \end{verbatim} |
| 892 |
% \end{macro} |
| 893 |
% |
| 894 |
% \begin{macrocode} |
| 895 |
%</package> |
| 896 |
% \end{macrocode} |
| 897 |
% |
| 898 |
% \section{Installation} |
| 899 |
% \subsection{Downloads\label{ss:Downloads}} |
| 900 |
% Everything is available at \url{https://ctan.org}, |
| 901 |
% but may need additional packages themselves.\\ |
| 902 |
% |
| 903 |
% \DescribeMacro{papermas.dtx} |
| 904 |
% For unpacking the |papermas.dtx| file and constructing the documentation |
| 905 |
% it is required: |
| 906 |
% \begin{description} |
| 907 |
% \item[-] \TeX-format \LaTeXe{} 2022-11-01 or newer: \url{https://www.CTAN.org/} |
| 908 |
% |
| 909 |
% \item[-] document class \xclass{ltxdoc}, 2022/06/22, v2.1i, |
| 910 |
% \url{https://ctan.org/pkg/ltxdoc} |
| 911 |
% |
| 912 |
% \item[-] package \xpackage{geometry}, 2020/01/02, v5.9, |
| 913 |
% \url{https://ctan.org/pkg/geometry} |
| 914 |
% |
| 915 |
% \item[-] package \xpackage{holtxdoc}, 2019/12/09, v0.30, |
| 916 |
% \url{https://ctan.org/pkg/holtxdoc} |
| 917 |
% \end{description} |
| 918 |
% |
| 919 |
% \DescribeMacro{papermas.sty} |
| 920 |
% The |papermas.sty| for \LaTeXe{} (i.\,e. each document using |
| 921 |
% the \xpackage{papermas} package) requires: |
| 922 |
% \begin{description} |
| 923 |
% \item[-] \TeX{}-format \LaTeXe{} 2022-11-01 or newer, \url{https://www.CTAN.org/} |
| 924 |
% |
| 925 |
% \item[-] package \xpackage{kvoptions}, 2022-06-15, v3.15, |
| 926 |
% \url{https://ctan.org/pkg/kvoptions} |
| 927 |
% |
| 928 |
% \item[-] package \xpackage{intcalc}, 2019/12/15, v1.3, |
| 929 |
% \url{https://ctan.org/pkg/intcalc} |
| 930 |
% |
| 931 |
% \item[-] package \xpackage{papermas}, 2023-04-12, v1.1a, |
| 932 |
% \url{https://ctan.org/pkg/papermas} (Because you are reading the documentation for the \xpackage{papermas} |
| 933 |
% package, it can be assumed that you already have some version of it~-- is it the current one?) |
| 934 |
% \end{description} |
| 935 |
% |
| 936 |
% \DescribeMacro{papermas-example.tex} |
| 937 |
% The |papermas-example.tex| requires the same files as all |
| 938 |
% documents using the \xpackage{papermas} package and additionally: |
| 939 |
% \begin{description} |
| 940 |
% \item[-] class \xpackage{article}, 2022/07/02, v1.4n, from \xpackage{classes}: \url{https://ctan.org/pkg/classes} |
| 941 |
% \end{description} |
| 942 |
% |
| 943 |
% \DescribeMacro{totpages} |
| 944 |
% As possible alternative in section \ref{sec:Alternatives} there is listed |
| 945 |
% \begin{description} |
| 946 |
% \item[-] package \xpackage{totpages}, 2005/09/19, v2.00, \url{https://ctan.org/pkg/totpages} |
| 947 |
% \end{description} |
| 948 |
% |
| 949 |
% \DescribeMacro{Oberdiek} |
| 950 |
% \DescribeMacro{holtxdoc} |
| 951 |
% \DescribeMacro{kvoptions} |
| 952 |
% All packages of the `oberdiek' bundle |
| 953 |
% (especially \xpackage{holtxdoc} and \xpackage{kvoptions}) |
| 954 |
% are also available in a TDS compliant ZIP archive:\\ |
| 955 |
% \url{https://mirror.ctan.org/install/macros/latex/contrib/oberdiek.tds.zip}.\\ |
| 956 |
% It is probably best to download and use this, because the packages in there |
| 957 |
% are quite probably both recent and compatible among themselves.\\ |
| 958 |
% |
| 959 |
% \DescribeMacro{intcalc} |
| 960 |
% The \xpackage{intcalc} is available at \url{https://www.ctan.org/pkg/intcalc}, also as \xfile{tds}:\\ |
| 961 |
% \url{https://mirrors.ctan.org/install/macros/latex/contrib/intcalc.tds.zip}.\\ |
| 962 |
% |
| 963 |
% \DescribeMacro{hyperref} |
| 964 |
% \noindent \xpackage{hyperref} is not included in that bundle and needs to be downloaded separately,\\ |
| 965 |
% \url{https://mirror.ctan.org/install/macros/latex/contrib/hyperref.tds.zip}.\\ |
| 966 |
% |
| 967 |
% \DescribeMacro{Münch} |
| 968 |
% A hyperlinked list of my (other) packages can be found at |
| 969 |
% \url{https://ctan.org/author/muench-hm}.\\ |
| 970 |
% |
| 971 |
% \subsection{Package, unpacking TDS} |
| 972 |
% \paragraph{Package.} This package is available on \url{https://www.CTAN.org}. |
| 973 |
% \begin{description} |
| 974 |
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/papermas/papermas.dtx}]\ % |
| 975 |
% The source file. |
| 976 |
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/papermas/papermas.pdf}]\ % |
| 977 |
% The documentation. |
| 978 |
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/papermas/papermas-example.pdf}]\ % |
| 979 |
% The compiled example file, as it should look like. |
| 980 |
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/papermas/README}]\ % |
| 981 |
% The README file. |
| 982 |
% \end{description} |
| 983 |
% |
| 984 |
% \noindent There is also a |papermas.tds.zip| available: |
| 985 |
% \begin{description} |
| 986 |
% \item[\url{https://mirror.ctan.org/install/macros/latex/contrib/papermas.tds.zip}]\ % |
| 987 |
% Everything in TDS compliant, compiled format. |
| 988 |
% \end{description} |
| 989 |
% which additionally contains\\ |
| 990 |
% \begin{tabular}{ll} |
| 991 |
% papermas.ins & The installation file.\\ |
| 992 |
% papermas.drv & The driver to generate the documentation.\\ |
| 993 |
% papermas.sty & The \xext{sty}le file.\\ |
| 994 |
% papermas-example.tex & The example file. |
| 995 |
% \end{tabular} |
| 996 |
% |
| 997 |
% \bigskip |
| 998 |
% |
| 999 |
% \noindent For required other packages please see the preceding subsection. |
| 1000 |
% |
| 1001 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 1002 |
% \docstrip{} archive. The files are extracted by running the |
| 1003 |
% \xext{dtx} through \plainTeX{}: |
| 1004 |
% \begin{quote} |
| 1005 |
% \verb|tex papermas.dtx| |
| 1006 |
% \end{quote} |
| 1007 |
% |
| 1008 |
% About generating the documentation see paragraph~\ref{GenDoc} below.\\ |
| 1009 |
% |
| 1010 |
% \paragraph{TDS.} Now the different files must be moved into |
| 1011 |
% the different directories in your installation TDS tree |
| 1012 |
% (also known as \xfile{texmf} tree): |
| 1013 |
% \begin{quote} |
| 1014 |
% \def\t{^^A |
| 1015 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 1016 |
% papermas.sty & tex/latex/papermas.sty\\ |
| 1017 |
% papermas.pdf & doc/latex/papermas.pdf\\ |
| 1018 |
% papermas-example.tex & doc/latex/papermas-example.tex\\ |
| 1019 |
% papermas-example.pdf & doc/latex/papermas-example.pdf\\ |
| 1020 |
% papermas.dtx & source/latex/papermas.dtx\\ |
| 1021 |
% \end{tabular}^^A |
| 1022 |
% }^^A |
| 1023 |
% \sbox0{\t}^^A |
| 1024 |
% \ifdim\wd0>\linewidth |
| 1025 |
% \begingroup |
| 1026 |
% \advance\linewidth by\leftmargin |
| 1027 |
% \advance\linewidth by\rightmargin |
| 1028 |
% \edef\x{\endgroup |
| 1029 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 1030 |
% }\x |
| 1031 |
% \def\lwbox{^^A |
| 1032 |
% \leavevmode |
| 1033 |
% \hbox to \linewidth{^^A |
| 1034 |
% \kern-\leftmargin\relax |
| 1035 |
% \hss |
| 1036 |
% \usebox0 |
| 1037 |
% \hss |
| 1038 |
% \kern-\rightmargin\relax |
| 1039 |
% }^^A |
| 1040 |
% }^^A |
| 1041 |
% \ifdim\wd0>\lw |
| 1042 |
% \sbox0{\small\t}^^A |
| 1043 |
% \ifdim\wd0>\linewidth |
| 1044 |
% \ifdim\wd0>\lw |
| 1045 |
% \sbox0{\footnotesize\t}^^A |
| 1046 |
% \ifdim\wd0>\linewidth |
| 1047 |
% \ifdim\wd0>\lw |
| 1048 |
% \sbox0{\scriptsize\t}^^A |
| 1049 |
% \ifdim\wd0>\linewidth |
| 1050 |
% \ifdim\wd0>\lw |
| 1051 |
% \sbox0{\tiny\t}^^A |
| 1052 |
% \ifdim\wd0>\linewidth |
| 1053 |
% \lwbox |
| 1054 |
% \else |
| 1055 |
% \usebox0 |
| 1056 |
% \fi |
| 1057 |
% \else |
| 1058 |
% \lwbox |
| 1059 |
% \fi |
| 1060 |
% \else |
| 1061 |
% \usebox0 |
| 1062 |
% \fi |
| 1063 |
% \else |
| 1064 |
% \lwbox |
| 1065 |
% \fi |
| 1066 |
% \else |
| 1067 |
% \usebox0 |
| 1068 |
% \fi |
| 1069 |
% \else |
| 1070 |
% \lwbox |
| 1071 |
% \fi |
| 1072 |
% \else |
| 1073 |
% \usebox0 |
| 1074 |
% \fi |
| 1075 |
% \else |
| 1076 |
% \lwbox |
| 1077 |
% \fi |
| 1078 |
% \else |
| 1079 |
% \usebox0 |
| 1080 |
% \fi |
| 1081 |
% \end{quote} |
| 1082 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 1083 |
% TDS installing feature, then some files can already be in the right |
| 1084 |
% place, see the documentation of \docstrip. |
| 1085 |
% |
| 1086 |
% \subsection{Refresh file name databases} |
| 1087 |
% |
| 1088 |
% If your \TeX~distribution (\TeX\,Live, \mikTeX, \dots) relies on |
| 1089 |
% file name databases, you must refresh these. For example, \TeX\,Live\ users |
| 1090 |
% run \verb|texhash| or \verb|mktexlsr|. |
| 1091 |
% |
| 1092 |
% \subsection{Some details for the interested} |
| 1093 |
% |
| 1094 |
% \paragraph{Unpacking with \LaTeX{}.} |
| 1095 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 1096 |
% \begin{description} |
| 1097 |
% \item[\plainTeX:] Run \docstrip{} and extract the files. |
| 1098 |
% \item[\LaTeX:] Generate the documentation. |
| 1099 |
% \end{description} |
| 1100 |
% If you insist on using \LaTeX{} for \docstrip{} (really, |
| 1101 |
% \docstrip{} does not need \LaTeX ), then inform the autodetect routine |
| 1102 |
% about your intention: |
| 1103 |
% \begin{quote} |
| 1104 |
% \verb|latex \let\install=y\input{papermas.dtx}| |
| 1105 |
% \end{quote} |
| 1106 |
% Do not forget to quote the argument according to the demands of your shell. |
| 1107 |
% |
| 1108 |
% \paragraph{Generating the documentation.\label{GenDoc}} |
| 1109 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 1110 |
% the documentation. The process can be configured by a |
| 1111 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put the following |
| 1112 |
% line into this file, if you want to have A4 as paper format: |
| 1113 |
% \begin{quote} |
| 1114 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 1115 |
% \end{quote} |
| 1116 |
% |
| 1117 |
% \noindent An example follows how to generate the documentation with \pdfLaTeX : |
| 1118 |
% |
| 1119 |
% \begin{quote} |
| 1120 |
%\begin{verbatim} |
| 1121 |
%pdflatex papermas.dtx |
| 1122 |
%makeindex -s gind.ist papermas.idx |
| 1123 |
%pdflatex papermas.dtx |
| 1124 |
%makeindex -s gind.ist papermas.idx |
| 1125 |
%pdflatex papermas.dtx |
| 1126 |
%\end{verbatim} |
| 1127 |
% \end{quote} |
| 1128 |
% |
| 1129 |
% \subsection{Compiling the example} |
| 1130 |
% The example file, \textsf{papermas-example.tex}, can be compiled via |(pdf)latex papermas-example.tex| |
| 1131 |
% and will need at least two compiler runs to get everything right. |
| 1132 |
% |
| 1133 |
% \section{Acknowledgements} |
| 1134 |
% |
| 1135 |
% I would like to thank \textsc{Heiko Oberdiek} for providing a lot of |
| 1136 |
% useful packages (from which I also got everything I know about creating |
| 1137 |
% a file in \xext{dtx} format, OK, say it: copying). |
| 1138 |
% |
| 1139 |
% \phantomsection |
| 1140 |
% \begin{History}\label{History} |
| 1141 |
% \begin{Version}{2010/06/01 v1.0(a)} |
| 1142 |
% \item First version of this \xpackage{papermas} package. |
| 1143 |
% \end{Version} |
| 1144 |
% \begin{Version}{2010/06/03 v1.0b} |
| 1145 |
% \item New |\papermassheets| and reruncheck introduced; several small changes. |
| 1146 |
% \item Example adapted to other examples of mine. |
| 1147 |
% \item TDS locations updated. |
| 1148 |
% \item Several changes in the documentation and the Readme file. |
| 1149 |
% \end{Version} |
| 1150 |
% \begin{Version}{2010/06/24 v1.0c} |
| 1151 |
% \item \xpackage{holtxdoc} warning in \xfile{drv} updated. |
| 1152 |
% \item Corrected the location of the package at CTAN. |
| 1153 |
% (TDS was still missing due to packaging error.) |
| 1154 |
% \item Several changes to the documentation. |
| 1155 |
% \item Introduced new \textbf{option}: |decimalsep|. |
| 1156 |
% \end{Version} |
| 1157 |
% \begin{Version}{2010/07/29 v1.0d} |
| 1158 |
% \item Corrected given url of \texttt{papermas.tds.zip} and other urls. |
| 1159 |
% \item Included a |\CheckSum| [was leter removed again]. |
| 1160 |
% \end{Version} |
| 1161 |
% \begin{Version}{2011/02/01 v1.0e} |
| 1162 |
% \item Removed wrong \%\ from the driver file. |
| 1163 |
% \item Changed the |\unit| definition (got rid of an old |\rm|). |
| 1164 |
% \item Replaced the list of my packages with a link to a web page list of those, |
| 1165 |
% which has the advantage of showing the recent versions of all those packages. |
| 1166 |
% \item Now using |\@ifundefined|. |
| 1167 |
% \item Removed |/muench/| from the path at diverse locations. |
| 1168 |
% \item Some small changes. |
| 1169 |
% \end{Version} |
| 1170 |
% \begin{Version}{2011/06/02 v1.0f} |
| 1171 |
% \item The \xpackage{holtxdoc} package was fixed (recent version: 2011/02/04,~v0.21), |
| 1172 |
% therefore the warning in \xfile{drv} could be removed.~-- Adapted the style of |
| 1173 |
% this documentation to new \textsc{Oberdiek} \xfile{dtx} style. |
| 1174 |
% \item The rerun warnings are given after the \texttt{filelist} (if that is called |
| 1175 |
% with |\listfiles|) and the final \xpackage{papermas} information is presented |
| 1176 |
% |\AtVeryVeryEnd| (now only ones instead of twice) |
| 1177 |
% [later replaced by use of the new hook management]. |
| 1178 |
% \item Instead of compiling \textquotedblleft $a$ to the power of $b$\textquotedblright\ itself, |
| 1179 |
% \xpackage{papermas} now uses the \xpackage{intcalc} package. |
| 1180 |
% \item Removed five counters. |
| 1181 |
% \end{Version} |
| 1182 |
% \begin{Version}{2011/08/08 v1.0g} |
| 1183 |
% \item The \xpackage{pagesLTS} package has been renamed to \xpackage{pageslts}: 2011/08/08,~v1.2a. |
| 1184 |
% \item Replaced |\global\edef| by |\xdef|. |
| 1185 |
% \end{Version} |
| 1186 |
% \begin{Version}{2011/08/22 v1.0h} |
| 1187 |
% \item Hot fix: \TeX{} 2011-06-27 changed |\enddocument| and thus broke the |\AtVeryVeryEnd| |
| 1188 |
% command/hooking of \xpackage{atveryend} package as of 2011-04-23, v1.7. |
| 1189 |
% Until fixed, |\AtEndAfterFileList| was used. [changed back in v1.0i] |
| 1190 |
% \item This version was archived at |
| 1191 |
% \url{https://web.archive.org/web/20190417084752/https://mirror.ctan.org/install/macros/latex/contrib/papermas.tds.zip}. |
| 1192 |
% \end{Version} |
| 1193 |
% \begin{Version}{-{}-{}-{}-/-{}-/-{}- v1.0i} |
| 1194 |
% \item Made |\newcommand|s robust. |
| 1195 |
% \item Moved from |\AtEndAfterFileList| to |\AtVeryVeryEnd| again. |
| 1196 |
% [later replaced by use of new hook management] |
| 1197 |
% \item By error this version was never released to the public. |
| 1198 |
% \end{Version} |
| 1199 |
% \begin{Version}{2023-04-12 v1.1a} |
| 1200 |
% \item |\NeedsTeXFormat{LaTeX2e}[2022-11-01]|, older package version available from archive |
| 1201 |
% (see version 2011/08/22 v1.0h above). |
| 1202 |
% \item Using the new hook management and \LaTeX's |\@abspage@last|. |
| 1203 |
% \item Package \xpackage{pageslts} is neither needed nor used by the |
| 1204 |
% \xpackage{papermas} package any longer. |
| 1205 |
% \item Removed |\papermas@powerof| (obsolete since version 2011-06-02~v1.0f). |
| 1206 |
% \item Converted to UTF-8. |
| 1207 |
% \item A lot of details; extensive documentation updates. |
| 1208 |
% \end{Version} |
| 1209 |
% \end{History} |
| 1210 |
% |
| 1211 |
% \bigskip |
| 1212 |
% |
| 1213 |
% When you find a mistake or have a suggestion for an improvement of this package, |
| 1214 |
% please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.) |
| 1215 |
% |
| 1216 |
% \bigskip |
| 1217 |
% |
| 1218 |
% \PrintIndex |
| 1219 |
% |
| 1220 |
% \Finale |
| 1221 |
\endinput |