summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/diagbox/diagbox.sty
blob: fb755ab69b21bc6bcd916e23248d149ae3b57101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
%%
%% This is file `diagbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% diagbox.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2011 by Leo Liu <leoliu.pku@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{diagbox}
    [2011/11/21 v1.0 Making table heads with diagonal lines]
\RequirePackage{keyval}
\RequirePackage{pict2e}
\newbox\diagbox@boxa
\newbox\diagbox@boxb
\newdimen\diagbox@wd
\newdimen\diagbox@ht
\newdimen\diagbox@sepl
\newdimen\diagbox@sepr
\define@key{diagbox}{width}{%
  \setlength{\diagbox@wd}{#1}}
\define@key{diagbox}{height}{%
  \setlength{\diagbox@ht}{#1}}
\define@key{diagbox}{trim}{%
  \@tfor\@reserveda:=#1\do{%
    \setlength{\csname diagbox@sep\@reserveda\endcsname}{\z@}}}
\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.}%
  \fi}
\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
  \end{picture}}
\def\diagbox@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{%
  \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][]{%
  \begingroup
  \diagbox@wd=\z@
  \diagbox@ht=\z@
  \diagbox@sepl=\tabcolsep
  \diagbox@sepr=\tabcolsep
  \setkeys{diagbox}{dir=SE,#1}%
  \setbox\diagbox@boxa=\hbox{%
    \begin{tabular}{l@{}}#2\end{tabular}}%
  \setbox\diagbox@boxb=\hbox{%
    \begin{tabular}{@{}r}#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
    \else
      \diagbox@wd=\dimexpr2\wd\diagbox@boxb+\diagbox@sepl+\diagbox@sepr\relax
    \fi
  \fi
  \ifdim\diagbox@ht=\z@
    \diagbox@ht=\dimexpr\ht\diagbox@boxa+\dp\diagbox@boxa+\ht\diagbox@boxb+\dp\diagbox@boxb\relax
  \fi
  $\vcenter{\hbox{\diagbox@pict}}$%
  \endgroup}
\expandafter\xdef\csname ver@slashbox.\@pkgextension\endcsname{9999/99/99}
\def\slashbox{%
  \def\diagbox@slashbox@options{dir=NE,}%
  \slashbox@}
\def\backslashbox{%
  \def\diagbox@slashbox@options{dir=SE,}%
  \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'.