summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/begriff/begriff.sty
blob: 24360d50314bee5fe9ebe18c47d61c9c0277362e (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
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
203
% begriffHeck.sty - a LaTeX2e package for typesetting begriffsschrift

% Copyright (C) 2003 by Josh Parsons <josh@coombs.anu.edu.au>
% 
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
% USA.

% Changes made in October 2004 by Richard Heck <heck@fas.harvard.edu>
% Purpose of changes: To make the format of the formulae closer to how
% they are set in Frege's published works.
%
% Minor changes by Josh Parsons to fix problem with linespacing (May 2005)

%%% identification
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{begriff}

%%% initial code

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% thickness of lines
\newlength{\BGthickness}
\setlength{\BGthickness}{0.4pt}

% additional length after a quantifier, conditional, negation, or assertion
\newlength{\BGafterlen}
\setlength{\BGafterlen}{2pt}

% additional length before a quantifier, conditional, or negation
\newlength{\BGbeforelen}
\setlength{\BGbeforelen}{2pt}

% space inserted before a formula
\newlength{\BGspace}
\setlength{\BGspace}{3pt}

% total width of diagram
% Heck (10/2004): Due to changes below, this is the total width of the DIAGRAM
% and does not include the width of the terminal formulae. In previous versions,
% it did include them.
\newlength{\BGlinewidth}
\setlength{\BGlinewidth}{\linewidth}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% options
%\DeclareOption{nothanks}{
%	\renewcommand{\mythanks}[1]{}
%	\let\@mythanks\relax
%}
\ProcessOptions

%%% package dependencies

%%% main code
\typeout{Begriffsschrift: 20 May 2005}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% variable-sized parenthesis
\newcommand{\BGbracket}[1]{%
\setbox0=\hbox{\ensuremath{#1}}%
\dimen0=\dp0%
\addtolength{\dimen0}{.5\baselineskip}%
\left(\vbox to \dp0 {\vskip.5\baselineskip\box0\vss}\right)%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate a terminal node with fill-line to the left
\newcommand{\BGterm}[1]{\unskip%
\setbox0=\hbox{%
\setlength{\BGlinewidth}{0pt}%
\vrule height \baselineskip depth 0pt width 0pt% strut
\vrule height \BGthickness width \BGafterlen depth 0pt%
\ensuremath{\hskip\BGspace #1}%
}%
% Heck (10/2004): Removed the following line, so that the terminal formulae will
% be left-aligned, as in Frege's published works.
%\addtolength{\BGlinewidth}{-\wd0}%
\vrule height \BGthickness width \BGlinewidth depth 0pt%
\box0%
\setlength{\BGlinewidth}{0pt}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% box up some maths and subtract its width from linewidth
% Heck (10/2004): Because of the changes above, this should no longer be needed.
% It remains for compatibility with previous versions.
\newcommand{\BGstem}[1]{\unskip%
\setbox0=\hbox{%
\setlength{\BGlinewidth}{0pt}%
\ensuremath{\hskip\BGspace #1}%
}%
\addtolength{\BGlinewidth}{-\wd0}%
\box0%
\hskip\BGspace%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate a conditional \BGconditional{antecedent}{consequent}
\newcommand{\BGconditional}[2]{\unskip%
\addtolength{\BGlinewidth}{-\BGbeforelen}%
\setbox0=\hbox{%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\vrule height \baselineskip depth 3pt width 0pt% strut
\vrule height \BGthickness width \BGafterlen depth 0pt%
\ensuremath{\hskip\BGspace #1}%
}%
\setbox1=\hbox{%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\vrule height 0pt depth .3\baselineskip width 0pt% strut
\vrule height \BGthickness width \BGafterlen depth 0pt%
\ensuremath{\hskip\BGspace #2}%
}%
\dimen0=0pt%
\addtolength{\dimen0}{\dp1}%
\addtolength{\dimen0}{\ht0}%
\addtolength{\dimen0}{\lineskip}%
\hbox{%
\vrule width \BGbeforelen height \BGthickness depth 0pt%
\kern-\BGthickness%
\vrule width \BGthickness height \BGthickness depth \dimen0%
\vtop{\box1\box0}%
}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate an assertion sign
\newcommand{\BGassert}[0]{%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\addtolength{\BGlinewidth}{-\BGthickness}%
\vrule width \BGthickness height 5pt depth 5pt%
\vrule depth 0pt height \BGthickness width \BGafterlen%
\hskip \BGspace%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate a content stroke
\newcommand{\BGcontent}[0]{%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\vrule depth 0pt height \BGthickness width \BGafterlen%
\hskip \BGspace%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate a negation
\newcommand{\BGnot}[0]{\unskip%
\addtolength{\BGlinewidth}{-\BGbeforelen}%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\vrule width \BGbeforelen height \BGthickness depth 0pt%
\kern-\BGthickness%
\vrule width \BGthickness height \BGthickness depth 3pt%
\vrule depth 0pt height \BGthickness width \BGafterlen%
\hskip \BGspace%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate a universal quantifier
\newcommand{\BGquant}[1]{\unskip%
\addtolength{\BGlinewidth}{-\BGbeforelen}%
\addtolength{\BGlinewidth}{-8pt}%
\addtolength{\BGlinewidth}{-\BGafterlen}%
\hbox{%
\vrule width \BGbeforelen height \BGthickness depth 0pt%
\setlength{\unitlength}{1pt}%
\kern-\BGthickness%
\begin{picture}(8,0)(0,0)%
\linethickness{\BGthickness}%
\qbezier(0,0)(4,-4)(8,0)%
\end{picture}%
\kern-8pt%
% Heck (10/2004): Added "\mathfrak", since variables are always fraktur over quantifiers
\vbox{\hbox to 8pt {\hskip1pt\hskip\BGthickness\hss$_{\mathfrak{#1}}$\hss}\vskip1pt}%
\vrule width \BGafterlen height \BGthickness depth 0pt%
}%
\hskip\BGspace%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Heck (10/2004): Convenience functions
% Heck: What I'd like to do is add another (optional) argument to 
% \BGif, so that if it is p, the premise is treated as \BGterm;
% if it is c, the conculsion is; if it is d, both are. But this will
% do for now.
\newcommand{\BGif}[2]{\BGconditional{#1}{#2}}
% Treat premise as a terminal node
\newcommand{\BGifp}[2]{\BGconditional{\BGterm{#1}}{#2}}
% Treat conclusion as a terminal node
\newcommand{\BGifc}[2]{\BGconditional{#1}{\BGterm{#2}}}
% Treat both as terminal nodes
\newcommand{\BGifb}[2]{\BGconditional{\BGterm{#1}}{\BGterm{#2}}}
\newcommand{\BGneg}[0]{\BGnot}
\newcommand{\BGall}[1]{\BGquant{#1}}