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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
%%
%% 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/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
\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{%
\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}{%
\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)
\@nameuse{diagbox@\diagbox@part @pict@\diagbox@dir}
\end{picture}}
\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)}
\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)}
\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
\def\diagbox@part{double}%
\setkeys{diagbox}{dir=NW,#1}%
\setbox\diagbox@boxa=\hbox{%
\begin{tabular}{@{\hspace{\diagbox@sepl}}l@{}}#2\end{tabular}}%
\setbox\diagbox@boxb=\hbox{%
\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
\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}
\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=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'.
|