summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-03-03 23:05:10 +0000
committerKarl Berry <karl@freefriends.org>2020-03-03 23:05:10 +0000
commitec062badfe285c6d7e7a07b263bbe2be5b59106c (patch)
treebae63c93014d7245c896a629dbde70a4df5f5e3a
parent6621c7373d21b810573f289d58e6111d7c77bdf2 (diff)
diagbox (1mar20)
git-svn-id: svn://tug.org/texlive/trunk@54050 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/diagbox/diagbox.pdfbin233171 -> 244804 bytes
-rw-r--r--Master/texmf-dist/source/latex/diagbox/diagbox.dtx337
-rw-r--r--Master/texmf-dist/source/latex/diagbox/diagbox.ins2
-rw-r--r--Master/texmf-dist/tex/latex/diagbox/diagbox.sty187
4 files changed, 416 insertions, 110 deletions
diff --git a/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf b/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf
index b891b8926a2..51592660f8c 100644
--- a/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf
+++ b/Master/texmf-dist/doc/latex/diagbox/diagbox.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/diagbox/diagbox.dtx b/Master/texmf-dist/source/latex/diagbox/diagbox.dtx
index 0fa92deec6a..341a3cdccf0 100644
--- a/Master/texmf-dist/source/latex/diagbox/diagbox.dtx
+++ b/Master/texmf-dist/source/latex/diagbox/diagbox.dtx
@@ -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@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,6 +1001,88 @@
% \changes{v2.3}{2020/02/09}{检测二次方程无解、异常解的情形}
% 分成三部分的盒子。四个参数,分别为 key-value 格式的可选项、左半边内容、中间
% 内容、右半边内容。
+% \begin{macrocode}
+\def\diagbox@triple#1#2#3#4{%
+ \begingroup
+ \diagbox@clear
+ \def\diagbox@part{triple}%
+ \setkeys{diagbox}{dir=NW,#1}%
+ \@nameuse{diagbox@triple@setbox@\diagbox@dir}{#2}{#3}{#4}%
+% \end{macrocode}
+% 在宏包最后定义,需要返回 "\x", "\xm", "\xxm", "\y", "\ym" 和 "\yym"。
+% \begin{macrocode}
+ \diagbox@solve@equations
+ $\vcenter{\hbox{\diagbox@pict}}$%
+ \endgroup}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{用户命令}
+%
+% \begin{macro}{\diagbox}
+% \changes{v2.0}{2011/11/22}{判断参数个数,选择两部分或三部分盒子。}
+% 主要的用户命令。判断使用两部分还是三部分的盒子。
+% \begin{macrocode}
+\newcommand\diagbox[3][]{%
+ \@ifnextchar\bgroup
+ {\diagbox@triple{#1}{#2}{#3}}{\diagbox@double{#1}{#2}{#3}}}
+% \end{macrocode}
+% \end{macro}
+%
+% 以下代码用来模拟 \pkg{slashbox} 宏包的功能。
+%
+% 禁止读入 \pkg{slashbox}。
+% \begin{macrocode}
+\expandafter\xdef\csname ver@slashbox.\@pkgextension\endcsname{9999/99/99}
+% \end{macrocode}
+%
+%
+% \begin{macro}{\slashbox}
+% 模拟 "\slashbox"。
+% \begin{macrocode}
+\def\slashbox{%
+ \def\diagbox@slashbox@options{dir=SW,}%
+ \slashbox@}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\backslashbox}
+% 模拟 "\backslashbox"。
+% \begin{macrocode}
+\def\backslashbox{%
+ \def\diagbox@slashbox@options{dir=NW,}%
+ \slashbox@}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\slashbox@}
+% \begin{macrocode}
+\newcommand\slashbox@[1][]{%
+ \ifx\relax#1\relax\else
+ \edef\diagbox@slashbox@options{%
+ \unexpanded\expandafter{\diagbox@slashbox@options}%
+ \unexpanded{width=#1,}}%
+ \fi
+ \slashbox@@}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\slashbox@@}
+% \begin{macrocode}
+\newcommand\slashbox@@[3][]{%
+ \edef\diagbox@slashbox@options{%
+ \unexpanded\expandafter{\diagbox@slashbox@options}%
+ \unexpanded{trim=#1,}}%
+ \expandafter\diagbox\expandafter[\diagbox@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,13 +1119,164 @@
% y_b &< y_m + y_a.
% \end{align*}
% 该条件需要在计算中予以检查。
+%
+% \begin{macro}{\diagbox@solve@equations}
+% 如果 \pkg{expl3} 环境可用,就使用 \pkg{l3fp} 计算,否则使用 \pkg{fp} 包。
% \begin{macrocode}
-\def\diagbox@triple#1#2#3#4{%
- \begingroup
- \diagbox@clear
- \def\diagbox@part{triple}%
- \setkeys{diagbox}{dir=NW,#1}%
- \@nameuse{diagbox@triple@setbox@\diagbox@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@boxa } }
+ \fp_set:Nn \l_@@_ya_fp
+ { \dim_to_fp:n { \ht \diagbox@boxa + \dp \diagbox@boxa } }
+ \fp_set:Nn \l_@@_xb_fp
+ { \dim_to_fp:n { \wd \diagbox@boxb } }
+ \fp_set:Nn \l_@@_yb_fp
+ { \dim_to_fp:n { \ht \diagbox@boxb + \dp \diagbox@boxb } }
+ \fp_set:Nn \l_@@_xm_fp
+ { \dim_to_fp:n { \wd \diagbox@boxm } }
+ \fp_set:Nn \l_@@_ym_fp
+ { \dim_to_fp:n { \ht \diagbox@boxm + \dp \diagbox@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@wd = \c_zero_dim
+ { \@@_calculate_width: }
+ { \fp_set:Nn \l_@@_x_fp { \dim_to_fp:n { \diagbox@wd } } }
+ \dim_compare:nNnTF \diagbox@ht = \c_zero_dim
+ { \@@_calculate_height: }
+ { \fp_set:Nn \l_@@_y_fp { \dim_to_fp:n { \diagbox@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@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@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@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@solve@equations{%
% \end{macrocode}
% 取长宽
% \begin{macrocode}
@@ -1096,81 +1336,12 @@
\else
\edef\y{\strip@pt\diagbox@ht}%
\fi
-% \end{macrocode}
-% 画盒子
-% \begin{macrocode}
\FPsub\xxm\x\xm
\FPsub\yym\y\ym
- $\vcenter{\hbox{\diagbox@pict}}$%
- \endgroup}
-% \end{macrocode}
-% \end{macro}
-%
-% \subsection{用户命令}
-%
-% \begin{macro}{\diagbox}
-% \changes{v2.0}{2011/11/22}{判断参数个数,选择两部分或三部分盒子。}
-% 主要的用户命令。判断使用两部分还是三部分的盒子。
-% \begin{macrocode}
-\newcommand\diagbox[3][]{%
- \@ifnextchar\bgroup
- {\diagbox@triple{#1}{#2}{#3}}{\diagbox@double{#1}{#2}{#3}}}
-% \end{macrocode}
-% \end{macro}
-%
-% 以下代码用来模拟 \pkg{slashbox} 宏包的功能。
-%
-% 禁止读入 \pkg{slashbox}。
-% \begin{macrocode}
-\expandafter\xdef\csname ver@slashbox.\@pkgextension\endcsname{9999/99/99}
-% \end{macrocode}
-%
-%
-% \begin{macro}{\slashbox}
-% 模拟 "\slashbox"。
-% \begin{macrocode}
-\def\slashbox{%
- \def\diagbox@slashbox@options{dir=SW,}%
- \slashbox@}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\backslashbox}
-% 模拟 "\backslashbox"。
-% \begin{macrocode}
-\def\backslashbox{%
- \def\diagbox@slashbox@options{dir=NW,}%
- \slashbox@}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\slashbox@}
-% \begin{macrocode}
-\newcommand\slashbox@[1][]{%
- \ifx\relax#1\relax\else
- \edef\diagbox@slashbox@options{%
- \unexpanded\expandafter{\diagbox@slashbox@options}%
- \unexpanded{width=#1,}}%
- \fi
- \slashbox@@}
-% \end{macrocode}
-% \end{macro}
-%
-%
-% \begin{macro}{\slashbox@@}
-% \begin{macrocode}
-\newcommand\slashbox@@[3][]{%
- \edef\diagbox@slashbox@options{%
- \unexpanded\expandafter{\diagbox@slashbox@options}%
- \unexpanded{trim=#1,}}%
- \expandafter\diagbox\expandafter[\diagbox@slashbox@options]{#2}{#3}}
-\endinput
+}
% \end{macrocode}
% \end{macro}
%
-%
% \iffalse
%</package>
% \fi
diff --git a/Master/texmf-dist/source/latex/diagbox/diagbox.ins b/Master/texmf-dist/source/latex/diagbox/diagbox.ins
index 196e5eb08be..2011c3321cd 100644
--- a/Master/texmf-dist/source/latex/diagbox/diagbox.ins
+++ b/Master/texmf-dist/source/latex/diagbox/diagbox.ins
@@ -16,7 +16,7 @@
%% and the derived filebase diagbox.sty.
%%
-\input docstrip.tex
+\input l3docstrip.tex
\keepsilent
\usedir{tex/latex/diagbox}
diff --git a/Master/texmf-dist/tex/latex/diagbox/diagbox.sty b/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
index d7f0fe1bfba..583251ef585 100644
--- a/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
+++ b/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
@@ -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@boxa
@@ -208,6 +206,166 @@
\def\diagbox@part{triple}%
\setkeys{diagbox}{dir=NW,#1}%
\@nameuse{diagbox@triple@setbox@\diagbox@dir}{#2}{#3}{#4}%
+ \diagbox@solve@equations
+ $\vcenter{\hbox{\diagbox@pict}}$%
+ \endgroup}
+\newcommand\diagbox[3][]{%
+ \@ifnextchar\bgroup
+ {\diagbox@triple{#1}{#2}{#3}}{\diagbox@double{#1}{#2}{#3}}}
+\expandafter\xdef\csname ver@slashbox.\@pkgextension\endcsname{9999/99/99}
+\def\slashbox{%
+ \def\diagbox@slashbox@options{dir=SW,}%
+ \slashbox@}
+\def\backslashbox{%
+ \def\diagbox@slashbox@options{dir=NW,}%
+ \slashbox@}
+\newcommand\slashbox@[1][]{%
+ \ifx\relax#1\relax\else
+ \edef\diagbox@slashbox@options{%
+ \unexpanded\expandafter{\diagbox@slashbox@options}%
+ \unexpanded{width=#1,}}%
+ \fi
+ \slashbox@@}
+\newcommand\slashbox@@[3][]{%
+ \edef\diagbox@slashbox@options{%
+ \unexpanded\expandafter{\diagbox@slashbox@options}%
+ \unexpanded{trim=#1,}}%
+ \expandafter\diagbox\expandafter[\diagbox@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@boxa } }
+ \fp_set:Nn \l__diagbox_ya_fp
+ { \dim_to_fp:n { \ht \diagbox@boxa + \dp \diagbox@boxa } }
+ \fp_set:Nn \l__diagbox_xb_fp
+ { \dim_to_fp:n { \wd \diagbox@boxb } }
+ \fp_set:Nn \l__diagbox_yb_fp
+ { \dim_to_fp:n { \ht \diagbox@boxb + \dp \diagbox@boxb } }
+ \fp_set:Nn \l__diagbox_xm_fp
+ { \dim_to_fp:n { \wd \diagbox@boxm } }
+ \fp_set:Nn \l__diagbox_ym_fp
+ { \dim_to_fp:n { \ht \diagbox@boxm + \dp \diagbox@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@wd = \c_zero_dim
+ { \__diagbox_calculate_width: }
+ { \fp_set:Nn \l__diagbox_x_fp { \dim_to_fp:n { \diagbox@wd } } }
+ \dim_compare:nNnTF \diagbox@ht = \c_zero_dim
+ { \__diagbox_calculate_height: }
+ { \fp_set:Nn \l__diagbox_y_fp { \dim_to_fp:n { \diagbox@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@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@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@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@solve@equations{%
\edef\xa{\strip@pt\wd\diagbox@boxa}%
\edef\ya{\strip@pt\dimexpr\ht\diagbox@boxa+\dp\diagbox@boxa\relax}%
\edef\xb{\strip@pt\wd\diagbox@boxb}%
@@ -255,30 +413,7 @@
\fi
\FPsub\xxm\x\xm
\FPsub\yym\y\ym
- $\vcenter{\hbox{\diagbox@pict}}$%
- \endgroup}
-\newcommand\diagbox[3][]{%
- \@ifnextchar\bgroup
- {\diagbox@triple{#1}{#2}{#3}}{\diagbox@double{#1}{#2}{#3}}}
-\expandafter\xdef\csname ver@slashbox.\@pkgextension\endcsname{9999/99/99}
-\def\slashbox{%
- \def\diagbox@slashbox@options{dir=SW,}%
- \slashbox@}
-\def\backslashbox{%
- \def\diagbox@slashbox@options{dir=NW,}%
- \slashbox@}
-\newcommand\slashbox@[1][]{%
- \ifx\relax#1\relax\else
- \edef\diagbox@slashbox@options{%
- \unexpanded\expandafter{\diagbox@slashbox@options}%
- \unexpanded{width=#1,}}%
- \fi
- \slashbox@@}
-\newcommand\slashbox@@[3][]{%
- \edef\diagbox@slashbox@options{%
- \unexpanded\expandafter{\diagbox@slashbox@options}%
- \unexpanded{trim=#1,}}%
- \expandafter\diagbox\expandafter[\diagbox@slashbox@options]{#2}{#3}}
+}
\endinput
%%
%% End of file `diagbox.sty'.