summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/seminar/doc/tvz-hax.sty
blob: f8a4798fccb15b81cfd88440dbdb0b54cb48a24a (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
%% BEGIN tvz-hax.sty
%% 93/04/01
%% Tim Van Zandt Timothy.VAN-ZANDT@insead.edu
%%
%% These are some lousy hacks for typesetting the code
%% and User's Guide  in the Seminar and PSTricks packages.
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%%


%%%%%%%%%%%%%%%%%%%%%%%%%% PAPER SIZES %%%%%%%%%%%%%%%%%%%%%%

% Default paper size is 8.5in by 11in.
% Just include the `a4' style option for A4 paper size.
% For other paper sizes, define \paperwidth and \paperheight
% before the \documentstyle command.

\@ifundefined{paperwidth}{\def\paperwidth{8.5in}}{}
\@ifundefined{paperheight}{\def\paperheight{11in}}{}
\@namedef{ds@a4}{\def\paperwidth{210mm}\def\paperheight{297mm}}


%%%%%%%%%%%%%%%%%%%% INPUTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\iftwoup
\@namedef{ds@2up}{\input 2up.tex \twouptrue}

\input article.sty
\input fancybox.sty    % Version 0.93 or later.

\iftwoup
  \if@twoside
    \targetlayout{twosided}
  \fi
\fi

\if@twoside
  \def\twosideclearpage{%
    \clearpage
    \ifodd\c@page\else
      \thispagestyle{empty}%
      \null\leavevmode
      \clearpage
    \fi}
\else
  \let\twosideclearpage\clearpage
\fi


%%%%%%%%%%%%%%%%%%%%% MISC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\arraystretch{1.2}

\hfuzz 1pt

% Just in case I'm using AmS-LaTeX.
\def\makeatother{\catcode`\@=12\relax}


%%%%%%%%%%%%%%%%%%%%%%%%%% SHORT META %%%%%%%%%%%%%%%%%%%%%%%%

% Works in verbatim environments, unless specially designed.
\begingroup
  \catcode`\<=\active
  \gdef\ShortMeta{%
    \catcode`\<=\active
    \def<##1>{{\MetaFont ##1\/}}}
\endgroup
\def\DeleteShortMeta{\catcode`\<=12\relax}
\def\MetaFont{\sl}            % For meta arguments.

%%%%%%%%%%%%%%%%%%%%%%%%%% FILE VERSIONS %%%%%%%%%%%%%%%%%%%%%

% \GetVersion{file} scans first ten lines of <file> for
% \filedate and \fileversion definitions.
%
% \CheckVersion{file} scans <scans> file for \filedate and \fileversion
% and then compares these witha \FileDate and \FileVersion.
%
\def\GetVersion#1{%
  \immediate\openin1=#1
  \count@=0
  \let\fileversion\relax
  \let\filedate\relax
  \@testtrue
  \loop
  \if@test
    \advance\count@1
    \immediate\read1 to \@tempa
    \@tempa
    \ifnum\count@=10
      \@latexerr{Couldn't find fileversion}\@eha
      \@testfalse
    \else
      \ifx\fileversion\relax
        \@testtrue
      \else
        \ifx\filedate\relax
          \@testtrue
        \else
          \@testfalse
        \fi
      \fi
    \fi
  \repeat}

\def\CheckVersion#1{%
  \GetVersion{#1}
  \ifx\FileVersion\fileversion
    \ifx\FileDate\filedate\else
      \@latexerr{Doc date (\FileDate) and file date (\filedate)
         do not match}\@eha
    \fi
  \else
    \@latexerr{Doc version (\FileVersion) and file version (\fileversion)
      do not match}\@eha
  \fi}

% This expands the date, as defined in \filedate.

\def\expanddate#1/#2/#3/{%
  \number#3{}
  \month=#2
  \ifcase\month\or
    January \or February \or March \or April \or May \or June \or
    July \or August \or September \or October \or November \or December
  \fi
  19#1}
\def\thefiledate{\expandafter\expanddate\filedate/}
\date{\thefiledate}


%%%%%%%%%%%%%%%%% LOGOS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\AmS{{\protect\the\textfont\tw@
  A\kern-.1667em\lower.5ex\hbox{M}\kern-.125em S}}

\def\b@LaTeX{%
  \begingroup
    \csname reset@font\endcsname
    \rm\bf
    L\kern-.32em
    \raise.36ex\hbox{%
      \ifx\@currsize\Huge\LARGE\else
      \ifx\@currsize\huge\Large\else
      \ifx\@currsize\LARGE\large\else
      \ifx\@currsize\Large\normalsize\else
      \ifx\@currsize\large\small\else
      \ifx\@currsize\normalsize\footnotesize\else
      \ifx\@currsize\small\scriptsize\else
      \ifx\@currsize\footnotesize\scriptscriptsize
      \fi\fi\fi\fi\fi\fi\fi\fi
      \bf A}%
    \kern-.15em
    T\kern-.1667em
    \lower.7ex\hbox{E}\kern-.125em
    X%
  \endgroup}
\def\bLaTeX{\b@LaTeX}


%%%%%%%%%%%%%%% PAGE STYLE  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% The `docheadings' page style uses footers rather than headers.

\def\ps@docheadings{%
  \let\@mkboth\markboth
  \def\@oddhead{}%
  \let\@evenhead\@oddhead%
  \def\@oddfoot{%
    \small\sf
    \rightmark
    \hfil
    \thepage}%
  \def\@evenfoot{%
    \small\sf
    \thepage
    \hfil
    \theheadertitle}%
  \def\sectionmark##1{\markright {##1}}}%
\pagestyle{docheadings}


%%%%%%%%%%%%%%%%%%%%%%%% Table of Contents %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Tighten up spacing in TOC:

\newskip\tempskip
\def\TOCshrink{.5}
\def\TableOfContents{%
  \begin{quote}
    \begin{center} \Large\bf Contents \end{center}
    \def\numberline##1{\hbox to 0pt{\hss##1\hskip 1em}}%
    \let\oldaddvspace\addvspace
    \def\addvspace##1{%
      \tempskip##1\relax
      \oldaddvspace{\TOCshrink\tempskip}}
    \@starttoc{toc}%
  \end{quote}}
\def\tableofcontents{%
  \clearpage
  \markright{Table of contents}%
  \TableOfContents
  \clearpage}


%%%%%%%%%%%%%%%%%%%%%%%% code and examples %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% `Ex' is an environment for putting samples of code.
% It is a variant of
%   \begin{quote}\tt ... \end{quote}.
% It is NOT verbatim.

\def\NotNested{%
  \def\begin##1{%
    \@latexerr{Bad nesting of environments.
      Perhaps missing \end{\@currenvir}}\@eha
    \end{\@currenvir}%
    \begin{##1}}}

\def\Ex{%
  \NotNested
  \list{}{}\item[]%
  \if@minipage\else\vskip\parskip\fi
  \leftskip\@totalleftmargin
  \rightskip\z@
  \parindent\z@
  \parskip\z@
  \parfillskip\@flushglue
  \hfuzz 1pt
  \@@par
  \global\@inlabelfalse}
\def\endEx{\endlist}

% Various things to make it easier to write code and examples:

\begingroup
  \catcode`\{=12 \catcode`\}=12
  \catcode`\(=1 \catcode`\)=2
  \catcode`\+=0 \catcode`\\=12
  +gdef+|(\)          % \| = character \
  +gdef+{({)          % \{ = character {
  +gdef+}(})          % \} = character }
+endgroup
\def\Backslash{\protect\|}

% Define some functional font commands:

\def\MainFont{\tt}            % For macro definitions.
\def\UsageFont{\tt}           % For in-line macro names.
\def\InlineFont{\tt}          % For other in-line snipets of code.
\def\DisplayFont{\tt}         % For displayed code.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\endinput
%% END tvz-hax.sty