summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2011-11-24 04:25:59 +0000
committerNorbert Preining <preining@logic.at>2011-11-24 04:25:59 +0000
commit1766bcbd5d57f14320a8adcbed669b358001f8fc (patch)
tree7fda4b2f4570ac14937f7f1e861a3a6a8649588a /Master/texmf-dist/tex/latex
parent213491417fe149fd2ee04205f7951abbf7c45629 (diff)
diagbox 2011/11/23 v2.0
git-svn-id: svn://tug.org/texlive/trunk@24646 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/diagbox/diagbox.sty128
1 files changed, 113 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/latex/diagbox/diagbox.sty b/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
index fb755ab69b2..d4659714070 100644
--- a/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
+++ b/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
@@ -20,11 +20,13 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{diagbox}
- [2011/11/21 v1.0 Making table heads with diagonal lines]
+ [2011/11/23 v2.0 Making table heads with diagonal lines]
\RequirePackage{keyval}
\RequirePackage{pict2e}
+\RequirePackage[nomessages]{fp}
\newbox\diagbox@boxa
\newbox\diagbox@boxb
+\newbox\diagbox@boxm
\newdimen\diagbox@wd
\newdimen\diagbox@ht
\newdimen\diagbox@sepl
@@ -35,39 +37,50 @@
\setlength{\diagbox@ht}{#1}}
\define@key{diagbox}{trim}{%
\@tfor\@reserveda:=#1\do{%
- \setlength{\csname diagbox@sep\@reserveda\endcsname}{\z@}}}
+ \ifcsname diagbox@sep\@reserveda\endcsname
+ \setlength{\csname diagbox@sep\@reserveda\endcsname}{\z@}%
+ \else
+ \PackageError{diagbox}{Unknown trim option `#1'.}{l, r, lr and rl are supported.}%
+ \fi}}
\define@key{diagbox}{dir}{%
- \ifcsname diagbox@pict@#1\endcsname
- \def\diagbox@pict@content{\@nameuse{diagbox@pict@#1}}%
- \else
- \PackageError{diagbox}{Unknown direction `#1'.}{SE and NE is supported.}%
+ \def\diagbox@dir{#1}%
+ \unless\ifcsname diagbox@dir@#1\endcsname
+ \PackageError{diagbox}{Unknown direction `#1'.}{NW, NE, SW, SE are supported.}%
+ \def\diagbox@dia{NW}%
\fi}
+\let\diagbox@dir@SE\relax
+\let\diagbox@dir@SW\relax
+\let\diagbox@dir@NE\relax
+\let\diagbox@dir@NW\relax
\def\diagbox@pict{%
\unitlength\p@
\begin{picture}
(\strip@pt\dimexpr\diagbox@wd-\diagbox@sepl-\diagbox@sepr\relax,\strip@pt\diagbox@ht)
(\strip@pt\diagbox@sepl,0)
- \diagbox@pict@content
+ \@nameuse{diagbox@\diagbox@part @pict@\diagbox@dir}
\end{picture}}
-\def\diagbox@pict@SE{%
+\def\diagbox@double@pict@SE{%
\put(0,0) {\makebox(0,0)[bl]{\box\diagbox@boxa}}
\put(\strip@pt\diagbox@wd,\strip@pt\diagbox@ht) {\makebox(0,0)[tr]{\box\diagbox@boxb}}
\Line(0,\strip@pt\diagbox@ht)(\strip@pt\diagbox@wd,0)}
-\def\diagbox@pict@NE{%
+\let\diagbox@double@pict@NW\diagbox@double@pict@SE
+\def\diagbox@double@pict@NE{%
\put(0,\strip@pt\diagbox@ht) {\makebox(0,0)[tl]{\box\diagbox@boxa}}
\put(\strip@pt\diagbox@wd,0) {\makebox(0,0)[br]{\box\diagbox@boxb}}
\Line(0,0)(\strip@pt\diagbox@wd,\strip@pt\diagbox@ht)}
-\newcommand\diagbox[3][]{%
+\let\diagbox@double@pict@SW\diagbox@double@pict@NE
+\def\diagbox@double#1#2#3{%
\begingroup
\diagbox@wd=\z@
\diagbox@ht=\z@
\diagbox@sepl=\tabcolsep
\diagbox@sepr=\tabcolsep
- \setkeys{diagbox}{dir=SE,#1}%
+ \def\diagbox@part{double}%
+ \setkeys{diagbox}{dir=NW,#1}%
\setbox\diagbox@boxa=\hbox{%
- \begin{tabular}{l@{}}#2\end{tabular}}%
+ \begin{tabular}{@{\hspace{\diagbox@sepl}}l@{}}#2\end{tabular}}%
\setbox\diagbox@boxb=\hbox{%
- \begin{tabular}{@{}r}#3\end{tabular}}%
+ \begin{tabular}{@{}r@{\hspace{\diagbox@sepr}}}#3\end{tabular}}%
\ifdim\diagbox@wd=\z@
\ifdim\wd\diagbox@boxa>\wd\diagbox@boxb
\diagbox@wd=\dimexpr2\wd\diagbox@boxa+\diagbox@sepl+\diagbox@sepr\relax
@@ -80,12 +93,97 @@
\fi
$\vcenter{\hbox{\diagbox@pict}}$%
\endgroup}
+\def\diagbox@triple@setbox@NW#1#2#3{%
+ \setbox\diagbox@boxa=\hbox{%
+ \begin{tabular}{@{\hspace{\diagbox@sepl}}l@{}}#1\end{tabular}}%
+ \setbox\diagbox@boxm=\hbox{%
+ \begin{tabular}{@{\hspace{\diagbox@sepl}}l@{}}#2\end{tabular}}%
+ \setbox\diagbox@boxb=\hbox{%
+ \begin{tabular}{@{}r@{\hspace{\diagbox@sepr}}}#3\end{tabular}}}
+\let\diagbox@triple@setbox@SW\diagbox@triple@setbox@NW
+\def\diagbox@triple@setbox@SE#1#2#3{%
+ \setbox\diagbox@boxa=\hbox{%
+ \begin{tabular}{@{\hspace{\diagbox@sepl}}l@{}}#1\end{tabular}}%
+ \setbox\diagbox@boxm=\hbox{%
+ \begin{tabular}{@{}r@{\hspace{\diagbox@sepr}}}#2\end{tabular}}%
+ \setbox\diagbox@boxb=\hbox{%
+ \begin{tabular}{@{}r@{\hspace{\diagbox@sepr}}}#3\end{tabular}}}
+\let\diagbox@triple@setbox@NE\diagbox@triple@setbox@SE
+\def\diagbox@triple@pict@NW{%
+ \put(0,0) {\makebox(0,0)[bl]{\box\diagbox@boxa}}
+ \put(0,\y) {\makebox(0,0)[tl]{\box\diagbox@boxm}}
+ \put(\x,\y) {\makebox(0,0)[tr]{\box\diagbox@boxb}}
+ \Line(0,\yym)(\x,0)
+ \Line(\xm,\y)(\x,0)}
+\def\diagbox@triple@pict@NE{%
+ \put(0,\y) {\makebox(0,0)[tl]{\box\diagbox@boxa}}
+ \put(\x,\y) {\makebox(0,0)[tr]{\box\diagbox@boxm}}
+ \put(\x,0) {\makebox(0,0)[br]{\box\diagbox@boxb}}
+ \Line(0,0)(\xxm,\y)
+ \Line(0,0)(\x,\yym)}
+\def\diagbox@triple@pict@SW{%
+ \put(0,\y) {\makebox(0,0)[tl]{\box\diagbox@boxa}}
+ \put(0,0) {\makebox(0,0)[bl]{\box\diagbox@boxm}}
+ \put(\x,0) {\makebox(0,0)[br]{\box\diagbox@boxb}}
+ \Line(0,\ym)(\x,\y)
+ \Line(\xm,0)(\x,\y)}
+\def\diagbox@triple@pict@SE{%
+ \put(0,0) {\makebox(0,0)[bl]{\box\diagbox@boxa}}
+ \put(\x,0) {\makebox(0,0)[br]{\box\diagbox@boxm}}
+ \put(\x,\y) {\makebox(0,0)[tr]{\box\diagbox@boxb}}
+ \Line(0,\y)(\xxm,0)
+ \Line(0,\y)(\x,\ym)}
+\def\diagbox@triple#1#2#3#4{%
+ \begingroup
+ \diagbox@wd=\z@
+ \diagbox@ht=\z@
+ \diagbox@sepl=\tabcolsep
+ \diagbox@sepr=\tabcolsep
+ \def\diagbox@part{triple}%
+ \setkeys{diagbox}{dir=NW,#1}%
+ \@nameuse{diagbox@triple@setbox@\diagbox@dir}{#2}{#3}{#4}%
+ \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}%
+ \edef\yb{\strip@pt\dimexpr\ht\diagbox@boxb+\dp\diagbox@boxb\relax}%
+ \edef\xm{\strip@pt\wd\diagbox@boxm}%
+ \edef\ym{\strip@pt\dimexpr\ht\diagbox@boxm+\dp\diagbox@boxm\relax}%
+ \FPneg\bi\yb
+ \FPadd\ci\xb\xm \FPneg\ci\ci
+ \FPmul\di\xm\yb
+ \FPadd\bj\ya\ym \FPneg\bj\bj
+ \FPneg\cj\xa
+ \FPmul\dj\xa\ym
+ \FPsub\u\dj\di
+ \FPupn{v}{bj ci * bi cj * -}%
+ \FPupn{delta}{bi dj * bj di * - cj ci - * 4 * %
+ v u + copy * %
+ - 2 swap root}%
+ \ifdim\diagbox@wd=\z@
+ \FPupn{x}{2 bj bi - delta v u - + / /}%
+ \diagbox@wd=\x\p@
+ \else
+ \edef\x{\strip@pt\diagbox@wd}%
+ \fi
+ \ifdim\diagbox@ht=\z@
+ \FPupn{y}{2 cj ci - delta v u + - / /}%
+ \diagbox@ht=\y\p@
+ \else
+ \edef\y{\strip@pt\diagbox@ht}%
+ \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=NE,}%
+ \def\diagbox@slashbox@options{dir=SW,}%
\slashbox@}
\def\backslashbox{%
- \def\diagbox@slashbox@options{dir=SE,}%
+ \def\diagbox@slashbox@options{dir=NW,}%
\slashbox@}
\newcommand\slashbox@[1][]{%
\ifx\relax#1\relax\else