summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/diagbox
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 /Master/texmf-dist/tex/latex/diagbox
parent6621c7373d21b810573f289d58e6111d7c77bdf2 (diff)
diagbox (1mar20)
git-svn-id: svn://tug.org/texlive/trunk@54050 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/diagbox')
-rw-r--r--Master/texmf-dist/tex/latex/diagbox/diagbox.sty187
1 files changed, 161 insertions, 26 deletions
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'.