%-------------------------------------------
%
% SWI Local LATEX Definitions
%
% File	:	local.sty
% Created: 	May 11, 1989 (Guus Schreiber)
% Modified:	May 29, 1989 (Jan Wielemaker)
%------------------------------------------


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  			GENERAL DECLARATIONS 			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% \sloppy prevents TEX to be too fussy about line breaks.

\sloppy

% Lowest level of section numbering is \subsubsection

\setcounter{secnumdepth}{3}

% Lowest level in table of contents is \subsubsection

\setcounter{tocdepth}{3}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 			CUSTIOMIZED LISTS 			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% The "shortlist" environment is an "itemize" with no extra 
% white space between items.

\newenvironment{shortlist}{%
	\begin{itemize}%
	    \setlength{\parsep}{0pt}
	    \setlength{\itemsep}{0pt}}{%
	\end{itemize}}

% The "enum" environemnt is an "enumerate" with no extra 
% white space between items.

\newenvironment{enum}{%
	\begin{enumerate}%
	    \setlength{\parsep}{0pt}
	    \setlength{\itemsep}{0pt}}{%
	\end{enumerate}}

% Item in description environment with newline after label.

\newcommand{\lab}[1]{\item[#1]\mbox{}\\}

%	Italic first line of item

\newcommand{\tick}[1]{\item {\em #1}\\}

% single item list with right adjusted italic tag
% ARG1  tag
% ARG2  item text

\newcommand{\tag}[2]{%
	\begin{list}{}{\leftmargin 3cm \labelwidth 2.5cm \topsep 0pt
	\labelsep 0.5cm} \item[\mbox{\em #1 \hfill}] #2 \end{list}}

% \stag is similar as \tag but with a small skip
\newcommand{\stag}[2]{%
	\begin{list}{}{\leftmargin 3cm \labelwidth 2.5cm \parsep 0pt
	\topsep 0pt \labelsep 0.5cm} 
	\item[\mbox{\em #1 \hfill}] #2 \end{list}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 			PARAGRAPH STYLES 			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Default is \indentpar: no extra white space and indented
% This command only has to be used to return to this style after 
% a \openlinepar

\newcommand{\indentpar}{% 
	\parskip 0em	% Extra vertical space between paragraphs.
	\parindent 17pt  % Width of paragraph indentation.
	\topsep 9pt plus 3pt minus 5pt     % Extra vertical space, in addition to 
                                   % \parskip, added above and below list and
                                   % paragraphing environments.
	\partopsep 3pt plus 1pt minus 2pt  % Extra vertical space, in addition to 
                                   % \parskip and \topsep, added when user
                                   % leaves blank line before environment.
	\itemsep 4.5pt plus 2pt minus 1pt  % Extra vertical space, in addition to
                                   % \parskip, added between list items.
	}

% \openlinepar redefines \par (and thus also an open line in the 
% source text) to: white space and no indent. 

\newcommand{\openlinepar}{% 
	\parskip .7em	% Extra vertical space between paragraphs.
	\parindent 0pt  % Width of paragraph indentation.
	\itemsep 0em 	% Extra vertical space, in addition to
                        % \parskip, added between list items.
	\topsep 0pt	% Extra vertical space, in addition to 
                        % \parskip, added above and below list and
                        % paragraphing environments.
	\partopsep 0pt 	% Extra vertical space, in addition to 
                        % \parskip and \topsep, added when user
                        % leaves blank line before environment.
	}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%			DEFAULT PAGE STYLE			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
			
% Dimension Of Text:

\textheight 	22cm 	%    Height of text (including footnotes and figures, 
			%    excluding running head and foot).
\textwidth	15cm	%    Width of text line.
 
% Top of page

\topmargin 	0pt	%    Nominal distance from top of page to top of
			%    box containing running head.
\headheight 	14pt	%    Height of box containing running head.
\headsep 	25pt    %    Space between running head and text.

% Bottom of page:

%\footheight 12pt	%    Height of box containing running foot.
\footskip 30pt   	%    Distance from baseline of box containing foot 
			%    to baseline of last line of text.

% For two-column mode: 

\oddsidemargin  1cm
\evensidemargin 1cm
\marginparwidth 0pt

\newcommand{\largepage}{%
	\oddsidemargin  -1.2cm
	\evensidemargin -1.2cm
	\marginparwidth 0pt
	\topmargin -1.2cm
	\headheight 12pt
	\headsep 0pt
	% \topskip = 10pt        %    '\baselineskip' for first line of page.
	\footheight 12pt
	\footskip 0pt
	\textheight 25cm
	\textwidth 19.5cm
	\columnsep 1cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  			FIGURES AND TABLES 			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%  Float placement parameters.  See LaTeX manual for their definition.

\setcounter{topnumber}{3}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{3}
\renewcommand{\topfraction}{.75}
\renewcommand{\bottomfraction}{.75}
\renewcommand{\textfraction}{.25}
\renewcommand{\floatpagefraction}{.7}

\setcounter{dbltopnumber}{2}
\renewcommand{\dbltopfraction}{.7}
\renewcommand{\dblfloatpagefraction}{.7}

% Float placement preference is : 
%
%	b(ottom of page)
% 	t(op of page)
%	h(ere), 
%	p(age of floats)

\catcode`\@=11\relax
\def\fps@figure{bthp}
\def\fps@table{bthp}
\catcode`\@=12\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%			POSTSCRIPT FIGURES			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \postscript has three arguments:
%
% 	ARG1:	the desired width of the figure (e.g. {12cm}, {4in})
%       ARG2:   the file/labelname: 
%		if the argument is {swi} then:
%		- LaTeX will search for the file "swi.ps"
%               - LaTeX will create a label "fig:swi" which you can use to
%		  refer to the figure number
%       ARG3:   the caption text (e.g.  {The SWI LoGo})
%
% The current directory will always be searched first for the figure.
% Other directories can be defined through the command \psdirectories.
% The argument of \psdirectories is a comma-separated list of full
% path names (no variables, ~, or "." allowed!) without spaces.
%
% E.g. \psdirectories{figs,/staff/guus/lib/psfig,/staff/kads/lib/psfig}
% 
% The default setting of \psdirectories is {figs}

\catcode`\@=11\relax

\def\postscript#1#2#3{\def\psfigure##1##2##3##4{%
	\begin{figure}
	    \centerline{\psfig{figure=##2/##3.ps,width=##1}}
	    \caption{##4}
	    \label{fig:##3}
	\end{figure}}
   \def\psfound{0}
   \openin15 #2.ps
   \ifeof15  \@for \psdir:=\psdirs\do
    {\closein15 \openin15 \psdir/#2.ps
     \ifeof15
       \relax
     \else
       \def\psfound{1}
       \psfigure{#1}{\psdir}{#2}{#3}
       \def\psfigure##1##2##3##4{\relax}
     \fi}
   \else
     \def\psfound{1}
     \psfigure{#1}{.}{#2}{#3}
   \fi
   \closein15
   \ifnum\psfound=0
     \begin{figure}
     \vskip 4cm
     \centerline{\em (Figure not found)}
     \vskip 4cm
     \caption{#3}
     \label{fig:#2}
     \end{figure}
     \@warning{Figure #2.ps not found}\fi}

\catcode`\@=12\relax
   
\newcommand{\psdirs}{figs}
\newcommand{\psdirectories}[1]{\renewcommand{\psdirs}{#1}}

% \spanpostscript puts double-column figures in a two-column text.

\newcommand{\spanpostscript}[3]{%
	\begin{figure*}
	    \centerline{\psfig{figure=figs/#2.ps,width=#1}}
	    \caption{#3}
	    \label{fig:#2}
	\end{figure*}
}

% \draft can be used to suppress postscript inclusion (prints a lot faster)

\newcommand{\draft}{%
\renewcommand{\postscript}[3]{\begin{figure}
	\label{fig:##2} \vspace*{8cm} \caption{##3}
	\end{figure}}}


% Standard table inclusion

\catcode`\@=11\relax
\def\tbl#1#2{\if@twocolumn
  \begin{table*}\centering\input tbl/#1\caption{#2}\label{tbl:#1}\end{table*}
  \else
  \begin{table}\centering\input tbl/#1\caption{#2}\label{tbl:#1}\end{table}\fi}
\catcode`\@=12\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%			BOXED environment			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%	Put anything in a box just as wide as the current line width

\catcode`\@=11\relax
\newbox\@curboxed
\def\boxed{\global\setbox\@curboxed\vbox\bgroup
	 \boxmaxdepth\z@
	 \addtolength{\linewidth}{-2\fboxsep}%
	 \addtolength{\linewidth}{-2\fboxrule}%
	 \addtolength{\linewidth}{-\@totalleftmargin}%
	 \hsize\linewidth\@parboxrestore}
\def\endboxed{\egroup\par\fbox{\vbox{\unvbox\@curboxed}}\par}
\catcode`\@=12\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%			CODE environment			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%	just like verbatim, but indents like quote.
%	allows also the use of leading tabs

\catcode`\@=11\relax

{\catcode`\^^I=\active
    \gdef^^I{\mbox{}\space\space\space\space\space\space\space\space}}

\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=12 \catcode `\}=12
\catcode`\\=12
|gdef|@xcode#1\end{code}[#1|end[code]]
|endgroup

\def\@code{\trivlist \item[]\if@minipage\else\vskip\parskip\fi
\leftskip\@totalleftmargin\rightskip\z@
\parindent\z@\parfillskip\@flushglue\parskip\z@
\@tempswafalse \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par}
\obeylines \catcode`\^^I=\active \tt \let\do\@makeother \dospecials}

\def\code{\quote \@code \frenchspacing\@vobeyspaces \@xcode}
\def\@endcode{\endtrivlist\mbox{}\endquote}
\let\endcode=\@endcode

\catcode`\@=12\relax

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%			SPECIAL CHARACTERS			%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Allow the use of the underscore (_) in plain text.

%\catcode`\_=\active
%\def_{\ifmmode\else\_\fi}

\newcommand{\bsl}{$\backslash$}					% \
\newcommand{\half}{\raisebox{3pt}{\tiny$\frac{1}{2}$}}		% 1/2
\newcommand{\quarter}{\raisebox{3pt}{\tiny$\frac{1}{4}$}}	% 1/4
\newcommand{\threequarter}{\raisebox{3pt}{\tiny$\frac{3}{4}$}}	% 3/4

    \def\newblock{\hskip .11em plus .33em minus -.07em}
