diff options
author | Karl Berry <karl@freefriends.org> | 2021-11-03 20:48:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-11-03 20:48:42 +0000 |
commit | d8d54b2f11fbd0b283af6c46782927b3f5778373 (patch) | |
tree | 502f8ac1354ec54d832e1afcb9f33e94270d812b /Master/texmf-dist/tex | |
parent | 57eeaa0c416fd9cd99918ca2ae7fdd2cc348e0a7 (diff) |
texdimens (3nov21)
git-svn-id: svn://tug.org/texlive/trunk@60934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/texdimens/texdimens.sty | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/texdimens/texdimens.tex | 49 |
2 files changed, 48 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/generic/texdimens/texdimens.sty b/Master/texmf-dist/tex/generic/texdimens/texdimens.sty index 8467e69a6f0..1b41c47d68e 100644 --- a/Master/texmf-dist/tex/generic/texdimens/texdimens.sty +++ b/Master/texmf-dist/tex/generic/texdimens/texdimens.sty @@ -1,5 +1,5 @@ % This is file texdimens.tex, part of texdimens package, which % is distributed under the LPPL 1.3c. Copyright (c) 2021 Jean-François Burnol -\ProvidesPackage{texdimens}[2021/07/21 v0.9 conversion of TeX dimensions to decimals (JFB)] +\ProvidesPackage{texdimens}[2021/11/02 v0.99 conversion of TeX dimensions to decimals (JFB)] \@@input texdimens.tex\relax \endinput
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/texdimens/texdimens.tex b/Master/texmf-dist/tex/generic/texdimens/texdimens.tex index 8103bef1cd0..d8bf99e0bc4 100644 --- a/Master/texmf-dist/tex/generic/texdimens/texdimens.tex +++ b/Master/texmf-dist/tex/generic/texdimens/texdimens.tex @@ -1,6 +1,6 @@ % This is file texdimens.tex, part of texdimens package, which % is distributed under the LPPL 1.3c. Copyright (c) 2021 Jean-François Burnol -% 2021/07/21 v0.9 +% 2021/11/02 v0.99 % All macros from 0.9delta release have changed names: \texdimen prefix % has replaced \texdimin. \edef\texdimensendinput{\endlinechar\the\endlinechar\catcode`\noexpand _=\the\catcode`\_\relax\noexpand\endinput}% @@ -10,6 +10,12 @@ % Mathematics ("down" and "up" macros) % =========== % +% In the entire discussion here, "uu" stands for some core unit, +% or some unit corresponding to a dimension > 1pt. For the case +% of a unit corresponding to a dimension < 1pt, i.e. to +% \texdimenwithunit macro added at 0.99, refer to the +% comments of issue #2 on the tracker site. +% % Is T sp attainable from unit "uu"?. % If not, what is largest dimension < Tsp which is attainable? % Here we suppose T>0. @@ -325,7 +331,7 @@ % there is ample room for 7227k+1 using \numexpr. % % But this step, as well as initial step to get kmax will require to separate -% hangdling of negative input from positive one. +% handling of negative input from positive one. % % Alternative % ----------- @@ -368,4 +374,43 @@ \def\texdimenbothsp_neg#1#2-#3;{#1-\numexpr(((2*#3-3612)/7227)*7227+1)/2-1\relax\relax}% % \let\texdimenbothcminsp\texdimenbothincmsp +% (\texdimenwithunit, added at 0.99) +% Mathematics +% =========== +% +% <comments to be added> (see discussion #2) +% +% Implementation +% ============== +% +% <comments to be added> (see discussion #2) +% #2 is unit, assumed positive. We will need to branch whether +% #2 is <1pt or >1pt. +% pre-multiplication of #1 by 2 here +\def\texdimenwithunit#1#2{\expandafter\texdimenwithunit_ + \the\numexpr\dimexpr#2\expandafter;\the\numexpr2*\dimexpr#1;}% +\def\texdimenwithunit_#1;#2{\ifnum#1>65535 + \expandafter\texdimenwithunit_A\else\expandafter\texdimenwithunit_B\fi + #2#1;% +}% +% unit>=1pt, handle this as for bp +\def\texdimenwithunit_A#1#2;#3;{\expandafter\texdimenstrippt + \the\dimexpr\numexpr(#1#3+\if-#1-\fi1)*32768/#2sp\relax +}% +% unit<1pt +% if dim1<0, simply negate result for dim1>0 as it can not be 0.0 +\def\texdimenwithunit_B#1{\if-#1\expandafter\texdimenwithunit_Bneg\fi\texdimenwithunit_Ba#1}% +\def\texdimenwithunit_Ba#1#2;#3;{\expandafter\texdimenwithunit_Bb\the\numexpr#1#3+1;#2;}% +\def\texdimenwithunit_Bb#1;#2;{\expandafter\texdimenwithunit_Bc\the\numexpr(#1-#2)/(2*#2);#1;#2;}% +% not adding f-expandability slight overhead here +% oh well, let's do \the\numexpr..+0.ddddd which does the trick and allows +% recycling strippt here with no need of another utility +% (thinking about it it means we could do this for unit >1pt as this method +% works even for \the\dimexpr producing 1pt or more... (as TeX outputs 1.0pt, not 1pt +% so the dot remains to stop the \numexpr scan) +\def\texdimenwithunit_Bc#1;#2;#3;{\the\numexpr#1+\expandafter\texdimenstrippt + \the\dimexpr\numexpr(#2-#1*2*#3)*32768/#3sp\relax}% +% definitly not caring about f-expandability here +\def\texdimenwithunit_Bneg\texdimenwithunit_Ba-#1;#2;% + {-\expandafter\texdimenwithunit_Bb\the\numexpr#2+1;#1;}% \texdimensendinput |