texlive[54050] Master/texmf-dist: diagbox (1mar20)

commits+karl at tug.org commits+karl at tug.org
Wed Mar 4 00:05:10 CET 2020


Revision: 54050
          http://tug.org/svn/texlive?view=revision&revision=54050
Author:   karl
Date:     2020-03-04 00:05:10 +0100 (Wed, 04 Mar 2020)
Log Message:
-----------
diagbox (1mar20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf
    trunk/Master/texmf-dist/source/latex/diagbox/diagbox.dtx
    trunk/Master/texmf-dist/source/latex/diagbox/diagbox.ins
    trunk/Master/texmf-dist/tex/latex/diagbox/diagbox.sty

Modified: trunk/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/diagbox/diagbox.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/diagbox/diagbox.dtx	2020-03-03 23:04:57 UTC (rev 54049)
+++ trunk/Master/texmf-dist/source/latex/diagbox/diagbox.dtx	2020-03-03 23:05:10 UTC (rev 54050)
@@ -58,6 +58,7 @@
 \makeatother
 \usepackage[numbered]{hypdoc}
 \hypersetup{pdfstartview=FitH}
+\fvset{gobble=1} %% 删除例子代码开头的 %
 \EnableCrossrefs
 \CodelineIndex
 \RecordChanges
@@ -69,7 +70,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{661}
+% \CheckSum{901}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -97,7 +98,8 @@
 % \newbox, \newdimen, \p@, \PackageError, \pkg, \put, \relax, \RequirePackage,
 % \setbox, \setkeys, \setlength, \strip at pt, \unexpanded, \unitlength,
 % \vcenter, \wd, \xdef, \z@, \@ifnextchar, \bgroup, \FPadd, \FPmul, \FPneg,
-% \FPsub, \FPupn, \let, \unless, \hspace}
+% \FPsub, \FPupn, \let, \unless, \hspace, \@tempskipa, \newif, \detokenize,
+% \@@, \\, \c, \l, \cs, \fp, \dim, \msg, \scan}
 %
 % \providecommand*{\pkg}{\textsf}
 % \GetFileInfo{diagbox.dtx}
@@ -629,13 +631,8 @@
 %    \begin{macrocode}
 \RequirePackage{pict2e}
 %    \end{macrocode}
-% 计算依赖 \pkg{fp} 宏包。
 % \changes{v2.2}{2016/12/28}{避免 \pkg{fp} 包的 \texttt{nomessages} 选项在使用
 % \pkg{catoptions} 包时冲突}
-%    \begin{macrocode}
-\RequirePackage{fp}
-\FPmessagesfalse
-%    \end{macrocode}
 % 长度计算 \pkg{calc} 宏包。
 % \changes{v2.2}{2016/12/28}{使用 \pkg{calc} 包计算选项参数,以支持
 % \cs{widthof} 等命令。}
@@ -1004,7 +1001,89 @@
 % \changes{v2.3}{2020/02/09}{检测二次方程无解、异常解的情形}
 % 分成三部分的盒子。四个参数,分别为 key-value 格式的可选项、左半边内容、中间
 % 内容、右半边内容。
+%    \begin{macrocode}
+\def\diagbox at triple#1#2#3#4{%
+  \begingroup
+  \diagbox at clear
+  \def\diagbox at part{triple}%
+  \setkeys{diagbox}{dir=NW,#1}%
+  \@nameuse{diagbox at triple@setbox@\diagbox at dir}{#2}{#3}{#4}%
+%    \end{macrocode}
+% 在宏包最后定义,需要返回 "\x", "\xm", "\xxm", "\y", "\ym" 和 "\yym"。
+%    \begin{macrocode}
+  \diagbox at solve@equations
+  $\vcenter{\hbox{\diagbox at pict}}$%
+  \endgroup}
+%    \end{macrocode}
+% \end{macro}
 %
+% \subsection{用户命令}
+%
+% \begin{macro}{\diagbox}
+% \changes{v2.0}{2011/11/22}{判断参数个数,选择两部分或三部分盒子。}
+% 主要的用户命令。判断使用两部分还是三部分的盒子。
+%    \begin{macrocode}
+\newcommand\diagbox[3][]{%
+  \@ifnextchar\bgroup
+    {\diagbox at triple{#1}{#2}{#3}}{\diagbox at double{#1}{#2}{#3}}}
+%    \end{macrocode}
+% \end{macro}
+%
+% 以下代码用来模拟 \pkg{slashbox} 宏包的功能。
+%
+% 禁止读入 \pkg{slashbox}。
+%    \begin{macrocode}
+\expandafter\xdef\csname ver at slashbox.\@pkgextension\endcsname{9999/99/99}
+%    \end{macrocode}
+%
+%
+% \begin{macro}{\slashbox}
+% 模拟 "\slashbox"。
+%    \begin{macrocode}
+\def\slashbox{%
+  \def\diagbox at slashbox@options{dir=SW,}%
+  \slashbox@}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\backslashbox}
+% 模拟 "\backslashbox"。
+%    \begin{macrocode}
+\def\backslashbox{%
+  \def\diagbox at slashbox@options{dir=NW,}%
+  \slashbox@}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\slashbox@}
+%    \begin{macrocode}
+\newcommand\slashbox@[1][]{%
+  \ifx\relax#1\relax\else
+    \edef\diagbox at slashbox@options{%
+      \unexpanded\expandafter{\diagbox at slashbox@options}%
+      \unexpanded{width=#1,}}%
+  \fi
+  \slashbox@@}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\slashbox@@}
+%    \begin{macrocode}
+\newcommand\slashbox@@[3][]{%
+  \edef\diagbox at slashbox@options{%
+    \unexpanded\expandafter{\diagbox at slashbox@options}%
+    \unexpanded{trim=#1,}}%
+  \expandafter\diagbox\expandafter[\diagbox at slashbox@options]{#2}{#3}}
+%    \end{macrocode}
+% \end{macro}
+%
+% \changes{v2.4}{2020/02/28}{利用 \pkg{l3fp} 解方程组。}
+%
+% \subsection{解方程组}
+%
 % 这里计算双斜线盒子宽、高的算法是简单而直观的。如下图所示,将 A、M、B 三个子盒
 % 子分别放在斜线盒的三个角后,斜线正好使 M 盒、A 或 B 盒、斜线盒的一角三点共
 % 线。
@@ -1023,6 +1102,16 @@
 %   \frac{y}{y_b} &= \frac{x - x_m}{x - x_m - x_b}.
 % \end{align*}
 % 该方程组通常可化简为一个一元二次方程求解,两组共轭根中可以只需要较大的一组。
+% 通过 Mathematica 软件,容易得到方程组的解为:
+% \begin{align*}
+% x & = \frac{u + v \pm \sqrt{\Delta}} {2(t - y_b)}, \\
+% y & = \frac{u - v \mp \sqrt{\Delta}} {2(x_a - s)}, \\
+% \Delta & := (u + v)^2 + 4 x_a (t - y_b) \bigl(x_m (y_b - y_m) - x_b y_m\bigr), \\
+%      u & := x_a y_m - x_m y_b, \\
+%      v & := st - x_a y_b, \\
+%      s & := x_b + x_m, \\
+%      t & := y_a + y_m.
+% \end{align*}
 % 但须注意上面的方程组并非总有正的实根,经过简单的代数分析可知,要给出几何直观
 % 的可行解(正实根),需要同时满足以下条件:
 % \begin{align*}
@@ -1030,14 +1119,165 @@
 %   y_b &< y_m + y_a.
 % \end{align*}
 % 该条件需要在计算中予以检查。
+%
+% \begin{macro}{\diagbox at solve@equations}
+% 如果 \pkg{expl3} 环境可用,就使用 \pkg{l3fp} 计算,否则使用 \pkg{fp} 包。
 %    \begin{macrocode}
-\def\diagbox at triple#1#2#3#4{%
-  \begingroup
-  \diagbox at clear
-  \def\diagbox at part{triple}%
-  \setkeys{diagbox}{dir=NW,#1}%
-  \@nameuse{diagbox at triple@setbox@\diagbox at dir}{#2}{#3}{#4}%
+\ifcsname\detokenize{fp_eval:n}\endcsname
+\csname fi\endcsname
+\ExplSyntaxOn
+%<@@=diagbox>
+\cs_new_protected:Npn \@@_solve_equations:
+  {
 %    \end{macrocode}
+% 取长宽。
+%    \begin{macrocode}
+    \fp_set:Nn \l_@@_xa_fp
+      { \dim_to_fp:n { \wd \diagbox at boxa } }
+    \fp_set:Nn \l_@@_ya_fp
+      { \dim_to_fp:n { \ht \diagbox at boxa + \dp \diagbox at boxa } }
+    \fp_set:Nn \l_@@_xb_fp
+      { \dim_to_fp:n { \wd \diagbox at boxb } }
+    \fp_set:Nn \l_@@_yb_fp
+      { \dim_to_fp:n { \ht \diagbox at boxb + \dp \diagbox at boxb } }
+    \fp_set:Nn \l_@@_xm_fp
+      { \dim_to_fp:n { \wd \diagbox at boxm } }
+    \fp_set:Nn \l_@@_ym_fp
+      { \dim_to_fp:n { \ht \diagbox at boxm + \dp \diagbox at boxm } }
+    \fp_set:Nn \l_@@_s_fp { \l_@@_xb_fp + \l_@@_xm_fp }
+    \fp_set:Nn \l_@@_t_fp { \l_@@_ya_fp + \l_@@_ym_fp }
+%    \end{macrocode}
+% 如果宽度和长度都被指定了,就不需要列方程组求解。
+%    \begin{macrocode}
+    \fp_set_eq:NN \l_@@_delta_fp \c_nan_fp
+    \dim_compare:nNnTF \diagbox at wd = \c_zero_dim
+      { \@@_calculate_width: }
+      { \fp_set:Nn \l_@@_x_fp { \dim_to_fp:n { \diagbox at wd } } }
+    \dim_compare:nNnTF \diagbox at ht = \c_zero_dim
+      { \@@_calculate_height: }
+      { \fp_set:Nn \l_@@_y_fp { \dim_to_fp:n { \diagbox at ht } } }
+    \edef \x   { \fp_use:N \l_@@_x_fp }
+    \edef \y   { \fp_use:N \l_@@_y_fp }
+    \edef \xm  { \fp_use:N \l_@@_xm_fp }
+    \edef \ym  { \fp_use:N \l_@@_ym_fp }
+    \edef \xxm { \fp_eval:n { \l_@@_x_fp - \l_@@_xm_fp } }
+    \edef \yym { \fp_eval:n { \l_@@_y_fp - \l_@@_ym_fp } }
+  }
+%    \end{macrocode}
+% 检查可行解条件,解二次方程。这里对于无正实根的情形,会给出一个宽松的值作为斜
+% 线盒子的宽高:
+% \begin{align*}
+%  x &= 2 \max(x_a + x_m, x_b + x_m),\\
+%  y &= 2 \max(y_a + y_m, y_b + y_m).
+% \end{align*}
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_calculate_width:
+  {
+    \fp_zero:N \l_@@_x_fp
+    \fp_compare:nNnT \l_@@_yb_fp < \l_@@_t_fp
+      {
+        \@@_calculate_coefficient:
+        \fp_if_nan:nF { \l_@@_sqrt_fp }
+          {
+            \fp_set:Nn \l_@@_x_fp
+              {
+                ( \l_@@_u_fp + \l_@@_v_fp + \l_@@_sqrt_fp ) /
+                ( 2 ( \l_@@_t_fp - \l_@@_yb_fp ) )
+              }
+          }
+      }
+    \fp_compare:nNnF \l_@@_x_fp > \c_zero_fp
+      {
+        \fp_set:Nn \l_@@_x_fp
+          { 2 ( max( \l_@@_xa_fp , \l_@@_xb_fp ) + \l_@@_xm_fp ) }
+        \msg_warning:nnxx { diagbox } { calculate-error }
+          { width } { \fp_use:N \l_@@_x_fp }
+      }
+    \diagbox at wd = \fp_to_dim:N \l_@@_x_fp \scan_stop:
+  }
+\cs_new_protected:Npn \@@_calculate_height:
+  {
+    \fp_zero:N \l_@@_y_fp
+    \fp_compare:nNnT \l_@@_xa_fp < \l_@@_s_fp
+      {
+        \@@_calculate_coefficient:
+        \fp_if_nan:nF { \l_@@_sqrt_fp }
+          {
+            \fp_set:Nn \l_@@_y_fp
+              {
+                ( \l_@@_u_fp - \l_@@_v_fp - \l_@@_sqrt_fp ) /
+                ( 2 ( \l_@@_xa_fp - \l_@@_s_fp ) )
+              }
+          }
+      }
+    \fp_compare:nNnF \l_@@_y_fp > \c_zero_fp
+      {
+        \fp_set:Nn \l_@@_y_fp
+          { 2 ( max( \l_@@_ya_fp , \l_@@_yb_fp ) + \l_@@_ym_fp ) }
+        \msg_warning:nnxx { diagbox } { calculate-error }
+          { height } { \fp_use:N \l_@@_y_fp }
+      }
+    \diagbox at ht = \fp_to_dim:N \l_@@_y_fp \scan_stop:
+  }
+\cs_new_protected:Npn \@@_calculate_coefficient:
+  {
+    \fp_if_nan:nT { \l_@@_delta_fp }
+      { \@@_calculate_coefficient_aux: }
+  }
+\cs_new_protected:Npn \@@_calculate_coefficient_aux:
+  {
+    \fp_set:Nn \l_@@_u_fp
+      {
+        \l_@@_xa_fp * \l_@@_ym_fp -
+        \l_@@_xm_fp * \l_@@_yb_fp
+      }
+    \fp_set:Nn \l_@@_v_fp
+      {
+        \l_@@_s_fp * \l_@@_t_fp -
+        \l_@@_xa_fp * \l_@@_yb_fp
+      }
+    \fp_set:Nn \l_@@_delta_fp
+      {
+        ( \l_@@_u_fp + \l_@@_v_fp )^2 +
+        4 * \l_@@_xa_fp * ( \l_@@_t_fp - \l_@@_yb_fp ) *
+          ( \l_@@_xm_fp * ( \l_@@_yb_fp - \l_@@_ym_fp ) -
+            \l_@@_xb_fp * \l_@@_ym_fp )
+      }
+    \fp_compare:nNnTF \l_@@_delta_fp < \c_zero_fp
+      { \fp_set_eq:NN \l_@@_sqrt_fp \c_nan_fp }
+      { \fp_set:Nn \l_@@_sqrt_fp { sqrt(\l_@@_delta_fp) } }
+  }
+\cs_new_eq:NN \diagbox at solve@equations \@@_solve_equations:
+\fp_new:N \l_@@_xa_fp
+\fp_new:N \l_@@_ya_fp
+\fp_new:N \l_@@_xb_fp
+\fp_new:N \l_@@_yb_fp
+\fp_new:N \l_@@_xm_fp
+\fp_new:N \l_@@_ym_fp
+\fp_new:N \l_@@_x_fp
+\fp_new:N \l_@@_y_fp
+\fp_new:N \l_@@_s_fp
+\fp_new:N \l_@@_t_fp
+\fp_new:N \l_@@_u_fp
+\fp_new:N \l_@@_v_fp
+\fp_new:N \l_@@_sqrt_fp
+\fp_new:N \l_@@_delta_fp
+\msg_new:nnn { diagbox } { calculate-error }
+  {
+    Cannot~calculate~proper~#1~of~triple~diagbox~
+    \msg_line_context:. \\
+    Use~#2pt~instead.
+  }
+\file_input_stop:
+%    \end{macrocode}
+%
+% 若 \pkg{l3fp} 不可用,则引入 \pkg{fp} 包计算。
+%    \begin{macrocode}
+\fi
+\RequirePackage{fp}
+\FPmessagesfalse
+\def\diagbox at solve@equations{%
+%    \end{macrocode}
 % 取长宽
 %    \begin{macrocode}
   \edef\xa{\strip at pt\wd\diagbox at boxa}%
@@ -1096,81 +1336,12 @@
   \else
     \edef\y{\strip at pt\diagbox at ht}%
   \fi
-%    \end{macrocode}
-% 画盒子
-%    \begin{macrocode}
   \FPsub\xxm\x\xm
   \FPsub\yym\y\ym
-  $\vcenter{\hbox{\diagbox at pict}}$%
-  \endgroup}
+}
 %    \end{macrocode}
 % \end{macro}
 %
-% \subsection{用户命令}
-%
-% \begin{macro}{\diagbox}
-% \changes{v2.0}{2011/11/22}{判断参数个数,选择两部分或三部分盒子。}
-% 主要的用户命令。判断使用两部分还是三部分的盒子。
-%    \begin{macrocode}
-\newcommand\diagbox[3][]{%
-  \@ifnextchar\bgroup
-    {\diagbox at triple{#1}{#2}{#3}}{\diagbox at double{#1}{#2}{#3}}}
-%    \end{macrocode}
-% \end{macro}
-%
-% 以下代码用来模拟 \pkg{slashbox} 宏包的功能。
-%
-% 禁止读入 \pkg{slashbox}。
-%    \begin{macrocode}
-\expandafter\xdef\csname ver at slashbox.\@pkgextension\endcsname{9999/99/99}
-%    \end{macrocode}
-%
-%
-% \begin{macro}{\slashbox}
-% 模拟 "\slashbox"。
-%    \begin{macrocode}
-\def\slashbox{%
-  \def\diagbox at slashbox@options{dir=SW,}%
-  \slashbox@}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\backslashbox}
-% 模拟 "\backslashbox"。
-%    \begin{macrocode}
-\def\backslashbox{%
-  \def\diagbox at slashbox@options{dir=NW,}%
-  \slashbox@}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\slashbox@}
-%    \begin{macrocode}
-\newcommand\slashbox@[1][]{%
-  \ifx\relax#1\relax\else
-    \edef\diagbox at slashbox@options{%
-      \unexpanded\expandafter{\diagbox at slashbox@options}%
-      \unexpanded{width=#1,}}%
-  \fi
-  \slashbox@@}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\slashbox@@}
-%    \begin{macrocode}
-\newcommand\slashbox@@[3][]{%
-  \edef\diagbox at slashbox@options{%
-    \unexpanded\expandafter{\diagbox at slashbox@options}%
-    \unexpanded{trim=#1,}}%
-  \expandafter\diagbox\expandafter[\diagbox at slashbox@options]{#2}{#3}}
-\endinput
-%    \end{macrocode}
-% \end{macro}
-%
-%
 % \iffalse
 %</package>
 % \fi

Modified: trunk/Master/texmf-dist/source/latex/diagbox/diagbox.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/diagbox/diagbox.ins	2020-03-03 23:04:57 UTC (rev 54049)
+++ trunk/Master/texmf-dist/source/latex/diagbox/diagbox.ins	2020-03-03 23:05:10 UTC (rev 54050)
@@ -16,7 +16,7 @@
 %% and the derived filebase diagbox.sty.
 %%
 
-\input docstrip.tex
+\input l3docstrip.tex
 \keepsilent
 
 \usedir{tex/latex/diagbox}

Modified: trunk/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/diagbox/diagbox.sty	2020-03-03 23:04:57 UTC (rev 54049)
+++ trunk/Master/texmf-dist/tex/latex/diagbox/diagbox.sty	2020-03-03 23:05:10 UTC (rev 54050)
@@ -23,8 +23,6 @@
     [2020/02/09 v2.3 Making table heads with diagonal lines]
 \RequirePackage{keyval}
 \RequirePackage{pict2e}
-\RequirePackage{fp}
-\FPmessagesfalse
 \RequirePackage{calc}
 \RequirePackage{array}
 \newbox\diagbox at boxa
@@ -208,6 +206,166 @@
   \def\diagbox at part{triple}%
   \setkeys{diagbox}{dir=NW,#1}%
   \@nameuse{diagbox at triple@setbox@\diagbox at dir}{#2}{#3}{#4}%
+  \diagbox at solve@equations
+  $\vcenter{\hbox{\diagbox at pict}}$%
+  \endgroup}
+\newcommand\diagbox[3][]{%
+  \@ifnextchar\bgroup
+    {\diagbox at triple{#1}{#2}{#3}}{\diagbox at double{#1}{#2}{#3}}}
+\expandafter\xdef\csname ver at slashbox.\@pkgextension\endcsname{9999/99/99}
+\def\slashbox{%
+  \def\diagbox at slashbox@options{dir=SW,}%
+  \slashbox@}
+\def\backslashbox{%
+  \def\diagbox at slashbox@options{dir=NW,}%
+  \slashbox@}
+\newcommand\slashbox@[1][]{%
+  \ifx\relax#1\relax\else
+    \edef\diagbox at slashbox@options{%
+      \unexpanded\expandafter{\diagbox at slashbox@options}%
+      \unexpanded{width=#1,}}%
+  \fi
+  \slashbox@@}
+\newcommand\slashbox@@[3][]{%
+  \edef\diagbox at slashbox@options{%
+    \unexpanded\expandafter{\diagbox at slashbox@options}%
+    \unexpanded{trim=#1,}}%
+  \expandafter\diagbox\expandafter[\diagbox at slashbox@options]{#2}{#3}}
+\ifcsname\detokenize{fp_eval:n}\endcsname
+\csname fi\endcsname
+\ExplSyntaxOn
+\cs_new_protected:Npn \__diagbox_solve_equations:
+  {
+    \fp_set:Nn \l__diagbox_xa_fp
+      { \dim_to_fp:n { \wd \diagbox at boxa } }
+    \fp_set:Nn \l__diagbox_ya_fp
+      { \dim_to_fp:n { \ht \diagbox at boxa + \dp \diagbox at boxa } }
+    \fp_set:Nn \l__diagbox_xb_fp
+      { \dim_to_fp:n { \wd \diagbox at boxb } }
+    \fp_set:Nn \l__diagbox_yb_fp
+      { \dim_to_fp:n { \ht \diagbox at boxb + \dp \diagbox at boxb } }
+    \fp_set:Nn \l__diagbox_xm_fp
+      { \dim_to_fp:n { \wd \diagbox at boxm } }
+    \fp_set:Nn \l__diagbox_ym_fp
+      { \dim_to_fp:n { \ht \diagbox at boxm + \dp \diagbox at boxm } }
+    \fp_set:Nn \l__diagbox_s_fp { \l__diagbox_xb_fp + \l__diagbox_xm_fp }
+    \fp_set:Nn \l__diagbox_t_fp { \l__diagbox_ya_fp + \l__diagbox_ym_fp }
+    \fp_set_eq:NN \l__diagbox_delta_fp \c_nan_fp
+    \dim_compare:nNnTF \diagbox at wd = \c_zero_dim
+      { \__diagbox_calculate_width: }
+      { \fp_set:Nn \l__diagbox_x_fp { \dim_to_fp:n { \diagbox at wd } } }
+    \dim_compare:nNnTF \diagbox at ht = \c_zero_dim
+      { \__diagbox_calculate_height: }
+      { \fp_set:Nn \l__diagbox_y_fp { \dim_to_fp:n { \diagbox at ht } } }
+    \edef \x   { \fp_use:N \l__diagbox_x_fp }
+    \edef \y   { \fp_use:N \l__diagbox_y_fp }
+    \edef \xm  { \fp_use:N \l__diagbox_xm_fp }
+    \edef \ym  { \fp_use:N \l__diagbox_ym_fp }
+    \edef \xxm { \fp_eval:n { \l__diagbox_x_fp - \l__diagbox_xm_fp } }
+    \edef \yym { \fp_eval:n { \l__diagbox_y_fp - \l__diagbox_ym_fp } }
+  }
+\cs_new_protected:Npn \__diagbox_calculate_width:
+  {
+    \fp_zero:N \l__diagbox_x_fp
+    \fp_compare:nNnT \l__diagbox_yb_fp < \l__diagbox_t_fp
+      {
+        \__diagbox_calculate_coefficient:
+        \fp_if_nan:nF { \l__diagbox_sqrt_fp }
+          {
+            \fp_set:Nn \l__diagbox_x_fp
+              {
+                ( \l__diagbox_u_fp + \l__diagbox_v_fp + \l__diagbox_sqrt_fp ) /
+                ( 2 ( \l__diagbox_t_fp - \l__diagbox_yb_fp ) )
+              }
+          }
+      }
+    \fp_compare:nNnF \l__diagbox_x_fp > \c_zero_fp
+      {
+        \fp_set:Nn \l__diagbox_x_fp
+          { 2 ( max( \l__diagbox_xa_fp , \l__diagbox_xb_fp ) + \l__diagbox_xm_fp ) }
+        \msg_warning:nnxx { diagbox } { calculate-error }
+          { width } { \fp_use:N \l__diagbox_x_fp }
+      }
+    \diagbox at wd = \fp_to_dim:N \l__diagbox_x_fp \scan_stop:
+  }
+\cs_new_protected:Npn \__diagbox_calculate_height:
+  {
+    \fp_zero:N \l__diagbox_y_fp
+    \fp_compare:nNnT \l__diagbox_xa_fp < \l__diagbox_s_fp
+      {
+        \__diagbox_calculate_coefficient:
+        \fp_if_nan:nF { \l__diagbox_sqrt_fp }
+          {
+            \fp_set:Nn \l__diagbox_y_fp
+              {
+                ( \l__diagbox_u_fp - \l__diagbox_v_fp - \l__diagbox_sqrt_fp ) /
+                ( 2 ( \l__diagbox_xa_fp - \l__diagbox_s_fp ) )
+              }
+          }
+      }
+    \fp_compare:nNnF \l__diagbox_y_fp > \c_zero_fp
+      {
+        \fp_set:Nn \l__diagbox_y_fp
+          { 2 ( max( \l__diagbox_ya_fp , \l__diagbox_yb_fp ) + \l__diagbox_ym_fp ) }
+        \msg_warning:nnxx { diagbox } { calculate-error }
+          { height } { \fp_use:N \l__diagbox_y_fp }
+      }
+    \diagbox at ht = \fp_to_dim:N \l__diagbox_y_fp \scan_stop:
+  }
+\cs_new_protected:Npn \__diagbox_calculate_coefficient:
+  {
+    \fp_if_nan:nT { \l__diagbox_delta_fp }
+      { \__diagbox_calculate_coefficient_aux: }
+  }
+\cs_new_protected:Npn \__diagbox_calculate_coefficient_aux:
+  {
+    \fp_set:Nn \l__diagbox_u_fp
+      {
+        \l__diagbox_xa_fp * \l__diagbox_ym_fp -
+        \l__diagbox_xm_fp * \l__diagbox_yb_fp
+      }
+    \fp_set:Nn \l__diagbox_v_fp
+      {
+        \l__diagbox_s_fp * \l__diagbox_t_fp -
+        \l__diagbox_xa_fp * \l__diagbox_yb_fp
+      }
+    \fp_set:Nn \l__diagbox_delta_fp
+      {
+        ( \l__diagbox_u_fp + \l__diagbox_v_fp )^2 +
+        4 * \l__diagbox_xa_fp * ( \l__diagbox_t_fp - \l__diagbox_yb_fp ) *
+          ( \l__diagbox_xm_fp * ( \l__diagbox_yb_fp - \l__diagbox_ym_fp ) -
+            \l__diagbox_xb_fp * \l__diagbox_ym_fp )
+      }
+    \fp_compare:nNnTF \l__diagbox_delta_fp < \c_zero_fp
+      { \fp_set_eq:NN \l__diagbox_sqrt_fp \c_nan_fp }
+      { \fp_set:Nn \l__diagbox_sqrt_fp { sqrt(\l__diagbox_delta_fp) } }
+  }
+\cs_new_eq:NN \diagbox at solve@equations \__diagbox_solve_equations:
+\fp_new:N \l__diagbox_xa_fp
+\fp_new:N \l__diagbox_ya_fp
+\fp_new:N \l__diagbox_xb_fp
+\fp_new:N \l__diagbox_yb_fp
+\fp_new:N \l__diagbox_xm_fp
+\fp_new:N \l__diagbox_ym_fp
+\fp_new:N \l__diagbox_x_fp
+\fp_new:N \l__diagbox_y_fp
+\fp_new:N \l__diagbox_s_fp
+\fp_new:N \l__diagbox_t_fp
+\fp_new:N \l__diagbox_u_fp
+\fp_new:N \l__diagbox_v_fp
+\fp_new:N \l__diagbox_sqrt_fp
+\fp_new:N \l__diagbox_delta_fp
+\msg_new:nnn { diagbox } { calculate-error }
+  {
+    Cannot~calculate~proper~#1~of~triple~diagbox~
+    \msg_line_context:. \\
+    Use~#2pt~instead.
+  }
+\file_input_stop:
+\fi
+\RequirePackage{fp}
+\FPmessagesfalse
+\def\diagbox at solve@equations{%
   \edef\xa{\strip at pt\wd\diagbox at boxa}%
   \edef\ya{\strip at pt\dimexpr\ht\diagbox at boxa+\dp\diagbox at boxa\relax}%
   \edef\xb{\strip at pt\wd\diagbox at boxb}%
@@ -255,30 +413,7 @@
   \fi
   \FPsub\xxm\x\xm
   \FPsub\yym\y\ym
-  $\vcenter{\hbox{\diagbox at pict}}$%
-  \endgroup}
-\newcommand\diagbox[3][]{%
-  \@ifnextchar\bgroup
-    {\diagbox at triple{#1}{#2}{#3}}{\diagbox at double{#1}{#2}{#3}}}
-\expandafter\xdef\csname ver at slashbox.\@pkgextension\endcsname{9999/99/99}
-\def\slashbox{%
-  \def\diagbox at slashbox@options{dir=SW,}%
-  \slashbox@}
-\def\backslashbox{%
-  \def\diagbox at slashbox@options{dir=NW,}%
-  \slashbox@}
-\newcommand\slashbox@[1][]{%
-  \ifx\relax#1\relax\else
-    \edef\diagbox at slashbox@options{%
-      \unexpanded\expandafter{\diagbox at slashbox@options}%
-      \unexpanded{width=#1,}}%
-  \fi
-  \slashbox@@}
-\newcommand\slashbox@@[3][]{%
-  \edef\diagbox at slashbox@options{%
-    \unexpanded\expandafter{\diagbox at slashbox@options}%
-    \unexpanded{trim=#1,}}%
-  \expandafter\diagbox\expandafter[\diagbox at slashbox@options]{#2}{#3}}
+}
 \endinput
 %%
 %% End of file `diagbox.sty'.



More information about the tex-live-commits mailing list.