-
Notifications
You must be signed in to change notification settings - Fork 6
/
trfrac.sty
193 lines (193 loc) · 5.46 KB
/
trfrac.sty
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
%%
%% This is file `trfrac.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% trfrac.dtx (with options: `file')
%%
%% This is a generated file.
%%
%% Copyright (C) 2009 by Kevin W. Hamlen
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3a 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.3a or later is part of all distributions of LaTeX version
%% 2004/10/01 or later.
%%
\newdimen\trtopgap\trtopgap\z@
\newdimen\trbotgap\trbotgap\z@
\newcommand\TRF@startp{31415926}
\newcommand\TRF@endp{27182818}
\newif\ifTRF@first
\newif\ifTRF@outer\TRF@outertrue
\newif\ifTRF@derivok\TRF@derivoktrue
\newdimen\TRF@lhang\TRF@lhang\z@
\newdimen\TRF@rhang\TRF@rhang\z@
\newdimen\TRF@lsave
\newdimen\TRF@ni
\newdimen\TRF@bi
\newdimen\TRF@bw
\newbox\TRF@numbox
\newbox\TRF@denombox
\newbox\TRF@eqbox
\newcommand\TRF@trfrac[3]{%
\begingroup%
\ifnum\lastpenalty=\TRF@startp\relax%
\TRF@firsttrue%
\else%
\TRF@firstfalse%
\fi%
\TRF@lsave\TRF@lhang%
\setbox\TRF@eqbox\hbox{\TRF@derivokfalse#1}%
\ifdim\wd\TRF@eqbox>\z@%
\setbox\TRF@eqbox\hbox{\kern\p@\unhbox\TRF@eqbox}%
\fi%
\TRF@lhang\z@%
\setbox\TRF@numbox\hbox{%
\TRF@outerfalse%
\m@th$\strut%
\penalty\TRF@startp\relax%
#2%
\ifnum\lastpenalty=\TRF@endp\relax\else%
\global\TRF@rhang\z@%
\fi%
$%
}%
\setbox\TRF@denombox\hbox{%
\TRF@derivokfalse%
\m@th$\strut#3$%
}%
\dimen@\wd\TRF@numbox%
\advance\dimen@-\TRF@rhang%
\TRF@bw\dimen@%
\advance\TRF@bw-\TRF@lhang%
\ifdim\wd\TRF@denombox>\TRF@bw\TRF@bw\wd\TRF@denombox\fi%
\advance\dimen@\TRF@lhang%
\advance\dimen@-\wd\TRF@denombox%
\TRF@ni\ifdim\dimen@>\z@\z@\else-.5\dimen@\fi%
\TRF@bi\TRF@ni%
\advance\TRF@bi\TRF@lhang%
\TRF@lhang\ifdim\dimen@<\z@\z@\else.5\dimen@\fi%
\ifdim\TRF@bi>\TRF@lhang\TRF@bi\TRF@lhang\fi%
\TRF@rhang\TRF@ni%
\advance\TRF@rhang\wd\TRF@numbox%
\dimen@\TRF@bi%
\advance\dimen@\TRF@bw%
\advance\dimen@\wd\TRF@eqbox%
\ifdim\dimen@>\TRF@rhang\TRF@rhang\dimen@\fi%
\advance\TRF@rhang-\TRF@lhang%
\advance\TRF@rhang-\wd\TRF@denombox%
\global\TRF@rhang\TRF@rhang%
\mathinner{%
\ifTRF@outer%
\raise\fontdimen22\textfont\tw@\vtop%
\else%
\vbox%
\fi%
{%
\offinterlineskip%
\hbox{%
\vbox{%
\dimen@\fontdimen8\textfont\tw@%
\advance\dimen@-\fontdimen22\textfont\tw@%
\advance\[email protected]\fontdimen8\textfont\thr@@%
\advance\dimen@-\dp\TRF@numbox%
\ifdim\dimen@<3\fontdimen8\textfont\thr@@%
\dimen@3\fontdimen8\textfont\thr@@%
\fi%
\advance\dimen@\trtopgap%
\hbox{\kern\TRF@ni\unhbox\TRF@numbox}%
\kern\dimen@%
\hbox{%
\kern\TRF@bi%
\vrule\@width\TRF@bw%
\@height.5\fontdimen8\textfont\thr@@%
\@depth.5\fontdimen8\textfont\thr@@%
\vbox{%
\[email protected]\ht\TRF@eqbox%
\advance\[email protected]\dp\TRF@eqbox%
\kern-\dimen@%
\box\TRF@eqbox%
\kern-\dimen@%
}%
}%
}%
}%
\dimen@\fontdimen11\textfont\tw@%
\advance\dimen@\fontdimen22\textfont\tw@%
\advance\[email protected]\fontdimen8\textfont\thr@@%
\advance\dimen@-\ht\TRF@denombox%
\ifdim\dimen@<3\fontdimen8\textfont\thr@@%
\dimen@3\fontdimen8\textfont\thr@@%
\fi%
\advance\dimen@\trbotgap%
\kern\dimen@%
\hbox{\kern\TRF@lhang\box\TRF@denombox}%
}%
}%
\ifTRF@outer\else%
\penalty\TRF@endp\relax%
\fi%
\global\TRF@lhang\ifTRF@first\TRF@lhang\else\TRF@lsave\fi%
\endgroup%
}
\newcommand\trfrac[3][]{%
\ifTRF@derivok%
\ifmmode%
\TRF@trfrac{#1}{#2}{#3}%
\else%
\TRF@mmerr%
\fi%
\else%
\TRF@derr%
\fi%
}
\newcommand\TRF@mmerr{%
\PackageError{trfrac}{\protect\trfrac\space%
only allowed in math mode}%
{I encountered a \protect\trfrac\space%
macro without first encountering a begin-math token.}%
}
\newcommand\TRF@derr{%
\PackageError{trfrac}{\protect\trfrac\space%
not allowed in the consequent of another \protect\trfrac}%
{\protect\trfrac\space can only appear in the premise (numerator%
) of another \protect\trfrac, not in the consequent (denominator%
) of a \protect\trfrac.}%
}
\newcommand\TRF@next{}
\newcommand\TRF@sep{\futurelet\TRF@next\TRF@@sep}
\newcommand\TRF@@sep{%
\ifx[\TRF@next%
\let\TRF@next\TRF@separg%
\else%
\let\TRF@next\TRF@sepnoarg%
\fi%
\TRF@next%
}
\newcommand\TRF@separg{}
\def\TRF@separg[#1]{\cr\noalign{\kern#1}}
\newcommand\TRF@sepnoarg{\cr}
\newenvironment{trgather}{%
\vbox\bgroup%
\let\\\TRF@sep%
\ialign\bgroup\hfil{\m@th$##$}\hfil\cr%
}{%
\crcr\egroup\egroup%
}
\newenvironment{tralign}{%
\vbox\bgroup%
\let\\\TRF@sep%
\ialign\bgroup\hfil{\m@th$##\null$}&{\m@th$\null##$}\hfil\cr%
}{%
\crcr\egroup\egroup%
}
\endinput
%%
%% End of file `trfrac.sty'.