blob: ec7cccf2df6ea076ba00524df997b096d05ac6ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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}%
}
|