summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/papermas
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-11 00:43:33 +0000
committerKarl Berry <karl@freefriends.org>2010-06-11 00:43:33 +0000
commit1f2855b00ed53226ad9141e4d313f42af42b83a7 (patch)
tree512958193c7d1f5cdab0ab9db4e713d7dfa30036 /Master/texmf-dist/tex/latex/papermas
parent030ea45adcac9c8cf31e5e2ad474965155c8d4e0 (diff)
papermas 1.0b (10jun10)
git-svn-id: svn://tug.org/texlive/trunk@18884 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/papermas')
-rw-r--r--Master/texmf-dist/tex/latex/papermas/papermas.sty273
1 files changed, 273 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/papermas/papermas.sty b/Master/texmf-dist/tex/latex/papermas/papermas.sty
new file mode 100644
index 00000000000..391052311fc
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/papermas/papermas.sty
@@ -0,0 +1,273 @@
+%%
+%% This is file `papermas.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% papermas.dtx (with options: `package')
+%%
+%% 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.
+%%
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{papermas}[2010/06/03 v1.0b
+ Computes paper mass of a printout (HMM)]%
+
+%% 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,
+%% usefull 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.
+
+\RequirePackage{kvoptions}[2010/02/22]% v3.7
+\RequirePackage{pagesLTS}[2010/06/03]% v1.1b
+%% 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).
+
+\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.
+
+\ProcessKeyvalOptions*
+
+%% 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 %%
+
+\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
+
+\newcounter{papermas@rerun}
+\newcounter{papermas@base}
+\newcounter{papermas@exp}
+\newcounter{papermas@result}
+\newcounter{papermas@ini}
+\setcounter{papermas@ini}{1}
+
+\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%
+ }
+
+\newcommand\papermas@totmass{%
+ \newcounter{papermasA}% paper mass for ISO A...
+ \setcounter{papermasA}{\papermas@format}% e. g. 4
+ \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%
+ \newcounter{papermasmasss}% always 0
+ \setcounter{papermasmasss}{\papermas@masss}% default: 80
+ \multiply \value{papermasmasss} 100 % default: 8000
+ \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
+ \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
+ \newcounter{papermas@sheets}
+ \setcounter{papermas@sheets}{\arabic{pagesLTS.pagenr}}%
+ \divide \value{papermas@sheets} by \value{papermasPPS}%
+ \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
+ \multiply \value{papermasmasss} \value{papermas@sheets}
+ % default: 8000
+ \papermas@powerof{2}{\value{papermasA}}
+ \divide \value{papermasmasss} by \value{papermas@result}
+ % default: 16000 / 2^(\value{papermasA})
+ % 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
+ \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
+ \edef\papermastmpr{\arabic{papermas@tmpo}.\arabic{papermas@tmpp}}%
+ \edef\papermastmpformat{\papermas@format}%
+ \edef\papermastmpmasss{\papermas@masss}%
+ \edef\papermastmppagespersheet{\papermas@pagespersheet}%
+ \edef\papermastmpt{\arabic{papermas@sheets}}%
+ \pagesLTS@ifcounter{papermassttl}
+ \ifnum\value{papermassttl}=\value{papermasmasss}
+ \relax
+ \else
+ \PackageWarningNoLine{papermas}{%
+ Number of pages may have changed.\MessageBreak%
+ Rerun to get it right.\MessageBreak%
+ }%
+ \fi
+ \setcounter{papermassttl}{\arabic{papermasmasss}}
+ \edef\papermastmps{\arabic{papermasmasss}}%
+ \if@filesw%
+ \immediate\write\@auxout{\string
+ \pagesLTS@ifcounter{papermassttl}}%
+ \immediate\write\@auxout{\string
+ \setcounter{papermassttl}{\papermastmps}}%
+ \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}}%
+ \immediate\write\@auxout{\string
+ \gdef\string\papermassheets{\papermastmpt}}%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ }
+
+\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
+ }
+
+\AfterLastShipout{%
+ \papermas@totmass%
+ }%
+
+\AtVeryEndDocument{%
+ \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%
+ }%
+ \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%
+ }
+
+\endinput
+%%
+%% End of file `papermas.sty'.