summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xprintlen
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-12-30 17:17:01 +0000
committerKarl Berry <karl@freefriends.org>2014-12-30 17:17:01 +0000
commit54cfbffe63a3055a3a42d556f8de243ada39b588 (patch)
treece8faec362ad9701418786f089c229cba071ea17 /Master/texmf-dist/tex/latex/xprintlen
parentfc2e88f51b7f2984c54bab370576d8ad5cfab2a1 (diff)
xprintlen (27dec14)
git-svn-id: svn://tug.org/texlive/trunk@35928 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xprintlen')
-rw-r--r--Master/texmf-dist/tex/latex/xprintlen/xprintlen.sty34
1 files changed, 34 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/xprintlen/xprintlen.sty b/Master/texmf-dist/tex/latex/xprintlen/xprintlen.sty
new file mode 100644
index 00000000000..ec7cccf2df6
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/xprintlen/xprintlen.sty
@@ -0,0 +1,34 @@
+%%
+%% This is file `xprintlen.sty',
+%% part of the package xprintlen.
+%%
+%% Copyright (C) 2014 by Liam Huang <liamhuang0205+xprintlen@gmail.com>
+%% --------------------------------------------------------------------------
+%% This work 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{xprintlen}[2014/12/25 v1.0 print lengths with units]
+\RequirePackage{fp}
+\newlength{\CMarg}
+\newlength{\CMunit}
+\newcommand{\CMspace}{\,}
+\newcommand{\defaultunit}{mm}
+\newcommand{\defaultsignificant}{2}
+\newcommand*{\printlen}[1][\defaultsignificant]{%
+ \providecommand{\printlenFirstParameter}{}%
+ \renewcommand{\printlenFirstParameter}{#1}%
+ \printlenCalculate%
+}
+\newcommand*{\printlenCalculate}[2][\defaultunit]{%
+ \setlength{\CMunit}{1#1}%
+ \setlength{\CMarg}{#2}%
+ \FPdiv\CMres{\strip@pt\CMarg}{\strip@pt\CMunit}%
+ \FPround\CMres\CMres{\printlenFirstParameter}%
+ \CMres\CMspace\texttt{#1}%
+}