From 254c4051242f5550c4ed5b7e073d60dcc1d67903 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 4 Sep 2009 18:21:33 +0000 Subject: printlen.sty update (3sep09) git-svn-id: svn://tug.org/texlive/trunk@15091 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/printlen/printlen.sty | 137 ++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/printlen/printlen.sty (limited to 'Master/texmf-dist/tex/latex/printlen') diff --git a/Master/texmf-dist/tex/latex/printlen/printlen.sty b/Master/texmf-dist/tex/latex/printlen/printlen.sty new file mode 100644 index 00000000000..7156670a20f --- /dev/null +++ b/Master/texmf-dist/tex/latex/printlen/printlen.sty @@ -0,0 +1,137 @@ +% printlen.sty Print lengths in a variety of units +% +% Author: Peter Wilson, Herries Press +% Maintainer: Will Robertson (will dot robertson at latex-project dot org) +% Copyright 2001 Peter R. Wilson +% Released under the LaTeX Project Public License +% +% Extensions courtesy of Harald Harders (h.harders@tu-bs.de) +% +% Usage instructions are at the end of this file. +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{printlen}[2009/09/03 v1.1a print lengths with units] +% +% \uselengthunit{} sets \l@nunits to the value of +% and \l@nunitperpt to the number of in 1pt. +\newcommand{\uselengthunit}[1]{% + \def\l@nunitperpt{1.0}\def\l@nunits{pt}% + \def\l@nta{#1}\def\l@ntb{pt}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{1.0}\def\l@nunits{pt}% + \else + \def\l@ntb{pc}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.083333}\def\l@nunits{pc}% + \else + \def\l@ntb{in}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.013837}\def\l@nunits{in}% + \else + \def\l@ntb{mm}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.351459}\def\l@nunits{mm}% + \else + \def\l@ntb{cm}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.0351459}\def\l@nunits{cm}% + \else + \def\l@ntb{bp}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.996264}\def\l@nunits{bp}% + \else + \def\l@ntb{dd}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.9345718}\def\l@nunits{dd}% + \else + \def\l@ntb{cc}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{0.0778809}\def\l@nunits{cc}% + \else + \def\l@ntb{PT}% + \ifx \l@nta\l@ntb + \def\l@nunitperpt{1.0}\def\l@nunits{PT}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi +} +\uselengthunit{pt} + +% \printlength{} prints the value of in the units set +% by \uselengthunit. +\newcommand{\printlength}[1]{% + \def\l@nta{pt}\ifx\l@nta\l@nunits\the#1\else + \def\l@nta{PT}% + \@tempdimc=\l@nunitperpt #1\relax\strip@pt\@tempdimc + \unitspace\relax\ifmmode + \mathrm{\ifx\l@nta\l@nunits pt\else\l@nunits\fi}% + \else + \ifx\l@nta\l@nunits pt\else\l@nunits\fi + \fi\fi} + +% \rndprintlength{} prints the rounded value of in +% the units set by \uselengthunit. Contributed by Harald Harders. +\def\@round#1.#2\@empty{#1}% +\newcommand{\rndprintlength}[1]{% + \def\l@nta{pt}\ifx\l@nta\l@nunits\the#1\else + \def\l@nta{PT}% + \setlength{\@tempdimc}{\l@nunitperpt #1}% + \addtolength{\@tempdimc}{0.5pt}% + \edef\@@round{\strip@pt\@tempdimc}% + \expandafter\@round\@@round.\@empty + \unitspace\relax\ifmmode + \mathrm{\ifx\l@nta\l@nunits pt\else\l@nunits\fi}% + \else + \ifx\l@nta\l@nunits pt\else\l@nunits\fi + \fi\fi} + +% Small space. Contributed by Harald Harders. +\newcommand{\unitspace}{\,} + +\endinput + +% USAGE: +% +% \printlength{} prints the value of a LaTeX length in the +% units specified by \uselengthunit{}, where may be any TeX +% length unit except for scaled point. That is, may be any of: +% pt, pc, in, mm, cm, bp, dd or cc. When pt is set the printed length +% value will include any stretch or shrink values, otherwise these +% are not printed. The argument may also be PT, in which case +% length values will be printed in pt units but without any stretch +% or shrink values. An unknown value for is treated as though it +% had been specified as pt. +% The unit is separated from the number using the command +% \unitspace which is set to \, by default. In math mode the units are +% printed upright. +% \rndprintlength{} prints the rounded value of a LaTeX length. +% Use PT instead of pt for rounded points if there are stretch or +% shrink values. +% +% The initial setting is \uselengthunit{pt} +% +% Example: +% +% The \verb|\textwidth| is \printlength{\textwidth} which is also +% \uselengthunit{in}\printlength{\textwidth} and +% \uselengthunit{mm}\printlength{\textwidth}. +% +% +% CHANGE HISTORY +% +% Version 1.1a (2009/09/03) +% - New maintainer (Will Robertson) +% +% Version 1.1 (2001/12/09) +% - Print rounded values +% - Space between value and units +% +% Version 1.0 (2001/11/03) +% - First public release +% -- cgit v1.2.3