summaryrefslogtreecommitdiff
path: root/macros/generic/texdimens/texdimens.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/texdimens/texdimens.tex')
-rw-r--r--macros/generic/texdimens/texdimens.tex238
1 files changed, 83 insertions, 155 deletions
diff --git a/macros/generic/texdimens/texdimens.tex b/macros/generic/texdimens/texdimens.tex
index 7068d57db9..189caca95d 100644
--- a/macros/generic/texdimens/texdimens.tex
+++ b/macros/generic/texdimens/texdimens.tex
@@ -1,9 +1,13 @@
% 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/14 v0.9gamma
+% 2021/07/15 v0.9delta
\edef\texdimensendinput{\endlinechar\the\endlinechar\catcode`\noexpand _=\the\catcode`\_\relax\noexpand\endinput}%
\endlinechar13\relax%
\catcode`\_=11
+%
+% Mathematics
+% ===========
+%
% Is T sp attainable from unit "uu"?. Here we suppose T>0.
% phi>1, psi=1/phi, psi<1
% U(N,phi)=trunc(N phi) is strictly increasing
@@ -119,211 +123,135 @@
% applies, i.e. the units uu > 2pt (phi>2, psi<1/2), i.e.
% all units except bp, nd and dd.
%
-\def\texdimfirstofone#1{#1}%
+% Implementation
+% ==============
+%
+\def\texdimenfirstofone#1{#1}%
+{\catcode`p 12\catcode`t 12
+ \csname expandafter\endcsname\gdef\csname texdimenstrippt\endcsname#1pt{#1}}%
+%
+% down macros:
+% for units with phi < 2:
+\def\texdimendown_A#1{\if-#1\texdimendown_neg\fi\texdimendown_B#1}%
+\def\texdimendown_B#1;#2;{\expandafter\texdimendown_c\the\numexpr(2*#1+1)#2;#1;}%
+% for units with phi > 2:
+\def\texdimendown_a#1{\if-#1\texdimendown_neg\fi\texdimendown_b#1}%
+\def\texdimendown_b#1;#2;{\expandafter\texdimendown_c\the\numexpr#1#2;#1;}%
+% shared macros:
+\def\texdimendown_c#1;{\expandafter\texdimendown_d\the\dimexpr#1sp;#1;}%
+{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimendown_d#1PT};#2;#3;#4;%
+ {\ifdim#1#4>#3sp \texdimendown_e{#2}\fi\texdimenfirstofone{#1}}%
+}%
% this #2 will be \fi
-\def\texdiminuudown_e#1#2#3#4{#2\expandafter\texdiminpt_\the\dimexpr\numexpr(#1-1)sp\relax}%
-\def\texdiminuuup_e#1#2#3#4{#2\expandafter\texdiminpt_\the\dimexpr\numexpr(#1+1)sp\relax}%
-% this #1 will be \fi
-\def\texdiminuuup_neg#1#2-{#1-#2}%
+\def\texdimendown_e#1#2#3#4{#2\expandafter\texdimenstrippt\the\dimexpr\numexpr#1-1sp\relax}%
+% negative branch:
+% The problem here is that if input very small, output can be 0.0, and we
+% do not want -0.0 as output.
+% So let's do this somewhat brutally and non-efficiently.
+% Anyhow, negative inputs are not our priority.
+% #1 is \fi here and #2 is \texdimendown_b or _B:
+\def\texdimendown_neg#1#2-#3;#4;#5;{#1\expandafter\texdimenstrippt\the\dimexpr-#2#3;#4;#5;pt\relax}%
+%
+% up macros:
+\def\texdimenup_A#1{\if-#1\texdimenup_neg\fi\texdimenup_B#1}%
+\def\texdimenup_B#1;#2;{\expandafter\texdimenup_c\the\numexpr(2*#1+1)#2;#1;}%
+\def\texdimenup_a#1{\if-#1\texdimenup_neg\fi\texdimenup_b#1}%
+\def\texdimenup_b#1;#2;{\expandafter\texdimenup_c\the\numexpr#1#2;#1;}%
+\def\texdimenup_c#1;{\expandafter\texdimenup_d\the\dimexpr#1sp;#1;}%
+{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimenup_d#1PT};#2;#3;#4;%
+ {\ifdim#1#4<#3sp \texdimenup_e{#2}\fi\texdimenfirstofone{#1}}%
+}%
+% this #2 will be \fi
+\def\texdimenup_e#1#2#3#4{#2\expandafter\texdimenstrippt\the\dimexpr\numexpr#1+1sp\relax}%
+% negative branch:
+% Here we can me more expeditive than for the "down" macros.
+% But this breaks f-expandability.
+% #1 will be \fi and #2 is \texdimenup_b or _B:
+\def\texdimenup_neg#1#2-{#1-#2}%
%
% pt
%
-\def\texdiminpt#1{\expandafter\texdiminpt_\the\dimexpr#1\relax}%
-{\catcode`p 12\catcode`t 12\csname expandafter\endcsname\gdef\csname texdiminpt_\endcsname#1pt{#1}}%
+\def\texdiminpt#1{\expandafter\texdimenstrippt\the\dimexpr#1\relax}%
%
% bp 7227/7200 = 803/800
%
\def\texdiminbp#1{\expandafter\texdiminbp_\the\numexpr\dimexpr#1;}%
-\def\texdiminbp_#1#2;{\texdiminpt{\numexpr(2*#1#2+\if-#1-\fi1)*400/803sp}}%
-% \texdiminbpdown: maximal dim exactly expressible in bp and at most equal to input
-\def\texdiminbpdown#1{\expandafter\texdiminbpdown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminbpdown_a#1{\if-#1\texdiminbpdown_neg\fi\texdiminbpdown_b#1}%
-\def\texdiminbpdown_b#1;{\expandafter\texdiminbpdown_c\the\numexpr(2*#1+1)*400/803;#1;}%
-\def\texdiminbpdown_c#1;{\expandafter\texdiminbpdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminbpdown_d#1PT};#2;#3;%
- {\ifdim#1bp>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
+\def\texdiminbp_#1#2;{%
+ \expandafter\texdimenstrippt\the\dimexpr\numexpr(2*#1#2+\if-#1-\fi1)*400/803sp\relax
}%
-% The problem here is that if close to 0sp, output can be 0.0, and we do not want
-% -0.0 as output. So let's do this somewhat brutally. Anyhow, negative inputs are
-% not our priority. #1 is \fi here:
-\def\texdiminbpdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminbpdown_b#3;pt\relax}%
+% \texdiminbpdown: maximal dim exactly expressible in bp and at most equal to input
+\def\texdiminbpdown#1{\expandafter\texdimendown_A\the\numexpr\dimexpr#1;*400/803;bp;}%
% \texdiminbpup: minimal dim exactly expressible in bp and at least equal to input
-\def\texdiminbpup#1{\expandafter\texdiminbpup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminbpup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminbpup_b#1}%
-\def\texdiminbpup_b#1;{\expandafter\texdiminbpup_c\the\numexpr(2*#1+1)*400/803;#1;}%
-\def\texdiminbpup_c#1;{\expandafter\texdiminbpup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminbpup_d#1PT};#2;#3;%
- {\ifdim#1bp<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminbpup#1{\expandafter\texdimenup_A\the\numexpr\dimexpr#1;*400/803;bp;}%
%
% nd 685/642
%
\def\texdiminnd#1{\expandafter\texdiminnd_\the\numexpr\dimexpr#1;}%
-\def\texdiminnd_#1#2;{\texdiminpt{\numexpr(2*#1#2+\if-#1-\fi1)*321/685sp}}%
-% \texdiminnddown: maximal dim exactly expressible in nd and at most equal to input
-\def\texdiminnddown#1{\expandafter\texdiminnddown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminnddown_a#1{\if-#1\texdiminnddown_neg\fi\texdiminnddown_b#1}%
-\def\texdiminnddown_b#1;{\expandafter\texdiminnddown_c\the\numexpr(2*#1+1)*321/685;#1;}%
-\def\texdiminnddown_c#1;{\expandafter\texdiminnddown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminnddown_d#1PT};#2;#3;%
- {\ifdim#1nd>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
+\def\texdiminnd_#1#2;{%
+ \expandafter\texdimenstrippt\the\dimexpr\numexpr(2*#1#2+\if-#1-\fi1)*321/685sp\relax
}%
-\def\texdiminnddown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminnddown_b#3;pt\relax}%
+% \texdiminnddown: maximal dim exactly expressible in nd and at most equal to input
+\def\texdiminnddown#1{\expandafter\texdimendown_A\the\numexpr\dimexpr#1;*321/685;nd;}%
% \texdiminndup: minimal dim exactly expressible in nd and at least equal to input
-\def\texdiminndup#1{\expandafter\texdiminndup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminndup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminndup_b#1}%
-\def\texdiminndup_b#1;{\expandafter\texdiminndup_c\the\numexpr(2*#1+1)*321/685;#1;}%
-\def\texdiminndup_c#1;{\expandafter\texdiminndup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminndup_d#1PT};#2;#3;%
- {\ifdim#1nd<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminndup#1{\expandafter\texdimenup_A\the\numexpr\dimexpr#1;*321/685;nd;}%
%
% dd 1238/1157
%
\def\texdimindd#1{\expandafter\texdimindd_\the\numexpr\dimexpr#1;}%
-\def\texdimindd_#1#2;{\texdiminpt{\numexpr(2*#1#2+\if-#1-\fi1)*1157/2476sp}}%
-% \texdimindddown: maximal dim exactly expressible in dd and at most equal to input
-\def\texdimindddown#1{\expandafter\texdimindddown_a\the\numexpr\dimexpr#1;}%
-\def\texdimindddown_a#1{\if-#1\texdimindddown_neg\fi\texdimindddown_b#1}%
-\def\texdimindddown_b#1;{\expandafter\texdimindddown_c\the\numexpr(2*#1+1)*1157/2476;#1;}%
-\def\texdimindddown_c#1;{\expandafter\texdimindddown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimindddown_d#1PT};#2;#3;%
- {\ifdim#1dd>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
+\def\texdimindd_#1#2;{%
+ \expandafter\texdimenstrippt\the\dimexpr\numexpr(2*#1#2+\if-#1-\fi1)*1157/2476sp\relax
}%
-\def\texdimindddown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdimindddown_b#3;pt\relax}%
+% \texdimindddown: maximal dim exactly expressible in dd and at most equal to input
+\def\texdimindddown#1{\expandafter\texdimendown_A\the\numexpr\dimexpr#1;*1157/2476;dd;}%
% \texdiminddup: minimal dim exactly expressible in dd and at least equal to input
-\def\texdiminddup#1{\expandafter\texdiminddup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminddup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminddup_b#1}%
-\def\texdiminddup_b#1;{\expandafter\texdiminddup_c\the\numexpr(2*#1+1)*1157/2476;#1;}%
-\def\texdiminddup_c#1;{\expandafter\texdiminddup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminddup_d#1PT};#2;#3;%
- {\ifdim#1dd<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminddup#1{\expandafter\texdimenup_A\the\numexpr\dimexpr#1;*1157/2476;dd;}%
%
% mm 7227/2540 phi now >2, use from here on the simpler approach
%
-\def\texdiminmm#1{\expandafter\texdiminpt_\the\dimexpr(#1)*2540/7227\relax}%
+\def\texdiminmm#1{\expandafter\texdimenstrippt\the\dimexpr(#1)*2540/7227\relax}%
% \texdiminmmdown: maximal dim exactly expressible in mm and at most equal to input
-\def\texdiminmmdown#1{\expandafter\texdiminmmdown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminmmdown_a#1{\if-#1\texdiminmmdown_neg\fi\texdiminmmdown_b#1}%
-\def\texdiminmmdown_b#1;{\expandafter\texdiminmmdown_c\the\numexpr#1*2540/7227;#1;}%
-\def\texdiminmmdown_c#1;{\expandafter\texdiminmmdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminmmdown_d#1PT};#2;#3;%
- {\ifdim#1mm>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdiminmmdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminmmdown_b#3;pt\relax}%
+\def\texdiminmmdown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;*2540/7227;mm;}%
% \texdiminmmup: minimal dim exactly expressible in mm and at least equal to input
-\def\texdiminmmup#1{\expandafter\texdiminmmup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminmmup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminmmup_b#1}%
-\def\texdiminmmup_b#1;{\expandafter\texdiminmmup_c\the\numexpr#1*2540/7227;#1;}%
-\def\texdiminmmup_c#1;{\expandafter\texdiminmmup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminmmup_d#1PT};#2;#3;%
- {\ifdim#1mm<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminmmup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;*2540/7227;mm;}%
%
% pc 12/1
%
-\def\texdiminpc#1{\expandafter\texdiminpt_\the\dimexpr(#1)/12\relax}%
+\def\texdiminpc#1{\expandafter\texdimenstrippt\the\dimexpr(#1)/12\relax}%
% \texdiminpcdown: maximal dim exactly expressible in pc and at most equal to input
-\def\texdiminpcdown#1{\expandafter\texdiminpcdown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminpcdown_a#1{\if-#1\texdiminpcdown_neg\fi\texdiminpcdown_b#1}%
-\def\texdiminpcdown_b#1;{\expandafter\texdiminpcdown_c\the\numexpr#1/12;#1;}%
-\def\texdiminpcdown_c#1;{\expandafter\texdiminpcdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminpcdown_d#1PT};#2;#3;%
- {\ifdim#1pc>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdiminpcdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminpcdown_b#3;pt\relax}%
+\def\texdiminpcdown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;/12;pc;}%
% \texdiminpcup: minimal dim exactly expressible in pc and at least equal to input
-\def\texdiminpcup#1{\expandafter\texdiminpcup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminpcup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminpcup_b#1}%
-\def\texdiminpcup_b#1;{\expandafter\texdiminpcup_c\the\numexpr#1/12;#1;}%
-\def\texdiminpcup_c#1;{\expandafter\texdiminpcup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminpcup_d#1PT};#2;#3;%
- {\ifdim#1pc<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminpcup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;/12;pc;}%
%
% nc 1370/107
%
-\def\texdiminnc#1{\expandafter\texdiminpt_\the\dimexpr(#1)*107/1370\relax}%
+\def\texdiminnc#1{\expandafter\texdimenstrippt\the\dimexpr(#1)*107/1370\relax}%
% \texdiminncdown: maximal dim exactly expressible in nc and at most equal to input
-\def\texdiminncdown#1{\expandafter\texdiminncdown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminncdown_a#1{\if-#1\texdiminncdown_neg\fi\texdiminncdown_b#1}%
-\def\texdiminncdown_b#1;{\expandafter\texdiminncdown_c\the\numexpr#1*107/1370;#1;}%
-\def\texdiminncdown_c#1;{\expandafter\texdiminncdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminncdown_d#1PT};#2;#3;%
- {\ifdim#1nc>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdiminncdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminncdown_b#3;pt\relax}%
+\def\texdiminncdown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;*107/1370;nc;}%
% \texdiminncup: minimal dim exactly expressible in nc and at least equal to input
-\def\texdiminncup#1{\expandafter\texdiminncup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminncup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminncup_b#1}%
-\def\texdiminncup_b#1;{\expandafter\texdiminncup_c\the\numexpr#1*107/1370;#1;}%
-\def\texdiminncup_c#1;{\expandafter\texdiminncup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminncup_d#1PT};#2;#3;%
- {\ifdim#1nc<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminncup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;*107/1370;nc;}%
%
% cc 14856/1157
%
-\def\texdimincc#1{\expandafter\texdiminpt_\the\dimexpr(#1)*1157/14856\relax}%
+\def\texdimincc#1{\expandafter\texdimenstrippt\the\dimexpr(#1)*1157/14856\relax}%
% \texdiminccdown: maximal dim exactly expressible in cc and at most equal to input
-\def\texdiminccdown#1{\expandafter\texdiminccdown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminccdown_a#1{\if-#1\texdiminccdown_neg\fi\texdiminccdown_b#1}%
-\def\texdiminccdown_b#1;{\expandafter\texdiminccdown_c\the\numexpr#1*1157/14856;#1;}%
-\def\texdiminccdown_c#1;{\expandafter\texdiminccdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminccdown_d#1PT};#2;#3;%
- {\ifdim#1cc>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdiminccdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminccdown_b#3;pt\relax}%
+\def\texdiminccdown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;*1157/14856;cc;}%
% \texdiminccup: minimal dim exactly expressible in cc and at least equal to input
-\def\texdiminccup#1{\expandafter\texdiminccup_a\the\numexpr\dimexpr#1;}%
-\def\texdiminccup_a#1{\if-#1\texdiminuuup_neg\fi\texdiminccup_b#1}%
-\def\texdiminccup_b#1;{\expandafter\texdiminccup_c\the\numexpr#1*1157/14856;#1;}%
-\def\texdiminccup_c#1;{\expandafter\texdiminccup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminccup_d#1PT};#2;#3;%
- {\ifdim#1cc<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdiminccup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;*1157/14856;cc;}%
%
% cm 7227/254
%
-\def\texdimincm#1{\expandafter\texdiminpt_\the\dimexpr(#1)*254/7227\relax}%
+\def\texdimincm#1{\expandafter\texdimenstrippt\the\dimexpr(#1)*254/7227\relax}%
% \texdimincmdown: maximal dim exactly expressible in cm and at most equal to input
-\def\texdimincmdown#1{\expandafter\texdimincmdown_a\the\numexpr\dimexpr#1;}%
-\def\texdimincmdown_a#1{\if-#1\texdimincmdown_neg\fi\texdimincmdown_b#1}%
-\def\texdimincmdown_b#1;{\expandafter\texdimincmdown_c\the\numexpr#1*254/7227;#1;}%
-\def\texdimincmdown_c#1;{\expandafter\texdimincmdown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimincmdown_d#1PT};#2;#3;%
- {\ifdim#1cm>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdimincmdown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdimincmdown_b#3;pt\relax}%
+\def\texdimincmdown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;*254/7227;cm;}%
% \texdimincmup: minimal dim exactly expressible in cm and at least equal to input
-\def\texdimincmup#1{\expandafter\texdimincmup_a\the\numexpr\dimexpr#1;}%
-\def\texdimincmup_a#1{\if-#1\texdiminuuup_neg\fi\texdimincmup_b#1}%
-\def\texdimincmup_b#1;{\expandafter\texdimincmup_c\the\numexpr#1*254/7227;#1;}%
-\def\texdimincmup_c#1;{\expandafter\texdimincmup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimincmup_d#1PT};#2;#3;%
- {\ifdim#1cm<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdimincmup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;*254/7227;cm;}%
%
% in 7227/100
%
-\def\texdiminin#1{\expandafter\texdiminpt_\the\dimexpr(#1)*100/7227\relax}%
+\def\texdiminin#1{\expandafter\texdimenstrippt\the\dimexpr(#1)*100/7227\relax}%
% \texdiminindown: maximal dim exactly expressible in in and at most equal to input
-\def\texdiminindown#1{\expandafter\texdiminindown_a\the\numexpr\dimexpr#1;}%
-\def\texdiminindown_a#1{\if-#1\texdiminindown_neg\fi\texdiminindown_b#1}%
-\def\texdiminindown_b#1;{\expandafter\texdiminindown_c\the\numexpr#1*100/7227;#1;}%
-\def\texdiminindown_c#1;{\expandafter\texdiminindown_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdiminindown_d#1PT};#2;#3;%
- {\ifdim#1in>#3sp \texdiminuudown_e{#2}\fi\texdimfirstofone{#1}}%
-}%
-\def\texdiminindown_neg#1#2-#3;{#1\expandafter\texdiminpt_\the\dimexpr-\texdiminindown_b#3;pt\relax}%
+\def\texdiminindown#1{\expandafter\texdimendown_a\the\numexpr\dimexpr#1;*100/7227;in;}%
% \texdimininup: minimal dim exactly expressible in in and at least equal to input
-\def\texdimininup#1{\expandafter\texdimininup_a\the\numexpr\dimexpr#1;}%
-\def\texdimininup_a#1{\if-#1\texdiminuuup_neg\fi\texdimininup_b#1}%
-\def\texdimininup_b#1;{\expandafter\texdimininup_c\the\numexpr#1*100/7227;#1;}%
-\def\texdimininup_c#1;{\expandafter\texdimininup_d\the\dimexpr#1sp;#1;}%
-{\catcode`P 12\catcode`T 12\lowercase{\gdef\texdimininup_d#1PT};#2;#3;%
- {\ifdim#1in<#3sp \texdiminuuup_e{#2}\fi\texdimfirstofone{#1}}%
-}%
+\def\texdimininup#1{\expandafter\texdimenup_a\the\numexpr\dimexpr#1;*100/7227;in;}%
%
\texdimensendinput