summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/lengthconvert
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-06-23 23:42:59 +0000
committerKarl Berry <karl@freefriends.org>2013-06-23 23:42:59 +0000
commitf42dda28c8d669e48f9adcba4a7809d26e210bea (patch)
treef86c87b22c9820163aceabe18b8a6a15c322a884 /Master/texmf-dist/tex/latex/lengthconvert
parent454227fc2e4964a96196503b509769d20908621d (diff)
lengthconvert (23jun13)
git-svn-id: svn://tug.org/texlive/trunk@30867 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/lengthconvert')
-rw-r--r--Master/texmf-dist/tex/latex/lengthconvert/lengthconvert.sty188
1 files changed, 188 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/lengthconvert/lengthconvert.sty b/Master/texmf-dist/tex/latex/lengthconvert/lengthconvert.sty
new file mode 100644
index 00000000000..6c67883969e
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lengthconvert/lengthconvert.sty
@@ -0,0 +1,188 @@
+%%
+%% This is file `lengthconvert.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lengthconvert.dtx (with options: `package')
+%% ----------------------------------------------------------------
+%% The lengthconvert package --- Convert a length to an other unit.
+%% E-mail: marco.daniel@mada-nada.de
+%% Released under the LaTeX Project Public License v1.3c or later
+%% See http://www.latex-project.org/lppl.txt
+%% ----------------------------------------------------------------
+%%
+\RequirePackage{expl3,xparse}
+
+\ProvidesExplPackage
+ {lengthconvert}{2013/05/13}{1.0}{Convert length to another unit}
+\@ifpackagelater { expl3 } { 2012/11/21 }
+ { }
+ {
+ \PackageError { lengthtconvert } { Support~package~expl3~too~old }
+ {
+ You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
+ 'l3packages'.\MessageBreak
+ Loading~lengthtconvert~will~abort!
+ }
+ \tex_endinput:D
+ }
+\RequirePackage{ l3keys2e }
+\clist_new:N \g__lconv_allowed_shortunits_clist
+\clist_gset:Nn \g__lconv_allowed_shortunits_clist
+ { pt , pc , in , bp , cm , mm , dd , cc ,sp }
+\clist_new:N \g__lconv_allowed_longunits_clist
+\clist_gset:Nn \g__lconv_allowed_longunits_clist
+ { point , pica , inch , big-point , centimeter , millimeter ,
+ didot-point , cicero , scaled-point }
+\clist_new:N \g__lconv_allowed_allunits_clist
+\clist_gset:NV \g__lconv_allowed_allunits_clist \g__lconv_allowed_shortunits_clist
+\clist_gput_right:NV \g__lconv_allowed_allunits_clist \g__lconv_allowed_longunits_clist
+\tl_new:N \l__lconv_unit_tl
+\keys_define:nn { lengthconvert }
+ {
+ unit .tl_set:N = \l__lconv_unit_tl
+ }
+\keys_set:nn { lengthconvert }
+ {
+ unit = cm ,
+ }
+\tl_new:N \l__lconv_default_unit_tl
+\keys_define:nn { lengthconvert }
+ {
+ pt .meta:n =
+ { unit = pt },
+ pc .meta:n =
+ { unit = pc },
+ in .meta:n =
+ { unit = in },
+ bp .meta:n =
+ { unit = bp },
+ cm .meta:n =
+ { unit = cm },
+ mm .meta:n =
+ { unit = mm },
+ dd .meta:n =
+ { unit = dd },
+ cc .meta:n =
+ { unit = cc },
+ sp .meta:n =
+ { unit = sp },
+ point .meta:n =
+ { unit = pt },
+ pica .meta:n =
+ { unit = pc },
+ inch .meta:n =
+ { unit = in },
+ big-point .meta:n =
+ { unit = bp },
+ centimeter .meta:n =
+ { unit = cm },
+ millimeter .meta:n =
+ { unit = mm },
+ didot-point .meta:n =
+ { unit = dd },
+ cicero .meta:n =
+ { unit = cc },
+ scaled-point .meta:n =
+ { unit = sp },
+ }
+\keys_define:nn { lengthconvert } {
+ use-siunitx .bool_set:N = \l__lconv_use_siunitx_bool
+}
+\keys_define:nn { lengthconvert } {
+ precision .int_set:N = \l__lconv_precision_int
+}
+\keys_set:nn { lengthconvert }
+ {
+ precision = 5 ,
+ }
+\keys_define:nn { lengthconvert } {
+ number-only .bool_set:N = \l__lconv_only_num_bool
+}
+\keys_define:nn { lengthconvert } {
+ unknown .code:n =
+ {
+ \msg_error:nnx { lengthconvert } { option-unknown }
+ { \exp_not:V \l_keys_key_tl }
+ }
+}
+\NewDocumentCommand \Convertsetup { m }
+ {
+ \keys_set:nn { lengthconvert } { #1 }
+ }
+\DeclareExpandableDocumentCommand \Convert { O{} m }
+ {
+ \group_begin:
+ \keys_set:nn { lengthconvert } { #1 }
+ \clist_if_in:NVTF \g__lconv_allowed_allunits_clist \l__lconv_unit_tl
+ {
+ \bool_if:NTF \l__lconv_use_siunitx_bool
+ {
+ \__lconv_using_siunitx:n { #2 }
+ }
+ {
+ \__lconv_nousing_siunitx:n { #2 }
+ }
+ }
+ {
+ \msg_error:nnx { lengthconvert } { unit-unknown }
+ { \exp_not:V \l__lconv_unit_tl }
+ }
+ \group_end:
+ }
+\cs_new:Npn \__lconv_calc_dim:n #1
+ {
+ \fp_eval:n
+ {
+ round( \dim_to_fp:n { #1 } / 1\l__lconv_unit_tl , \l__lconv_precision_int)
+ }
+ }
+
+\cs_new:Npn \__lconv_using_siunitx:n #1
+ {
+ \bool_if:NTF \l__lconv_only_num_bool
+ {
+ \num { \__lconv_calc_dim:n { #1 } }
+ }
+ {
+ \SI { \__lconv_calc_dim:n { #1 } } { \l__lconv_unit_tl }
+ }
+ }
+\cs_new:Npn \__lconv_nousing_siunitx:n #1
+ {
+ \bool_if:NTF \l__lconv_only_num_bool
+ {
+ \__lconv_calc_dim:n { #1 }
+ }
+ {
+ \__lconv_calc_dim:n { #1 } \, \l__lconv_unit_tl
+ }
+ }
+\msg_new:nnnn { lengthconvert } { option-unknown }
+ { Unknown~option~'#1'~for~package~#2. }
+ {
+ LaTeX~has~been~asked~to~set~an~option~called~'#1'~
+ but~the~#2~package~has~not~created~an~option~with~this~name.
+ }
+\msg_new:nnnn { lengthconvert } { unit-unknown }
+ { Unknown~unit~'#1'~for~package~#2. }
+ {
+ You~are~setting~an~unit~'#1'~which~
+ is~unknonw~for~the~package~#2.
+ }
+\ProcessKeysOptions { lengthconvert }
+%% Copyright (C) 2013 by
+%% Marco Daniel marco.daniel@mada-nada.de
+%%
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version. The latest
+%% version of this license is in the file:
+%% http://www.latex-project.org/lppl.txt
+%%
+%% This work is "maintained" (as per LPPL maintenance status) by
+%% Marco Daniel.
+%%
+%%
+%% End of file `lengthconvert.sty'.