% nick.sty
% My favourite setups for LaTeX.
% For TeX, read into preamble with \input{nick.sty}.

% $Header: F:\EMTEX\TEXINPUT\LATEX2E\NICK\RCS\nick.sty 1.6 1996/03/04 12:13:05 Nick Exp Nick $

\RequirePackage{xspace}

% Command to write C++ in a pleasing way:
% \newcommand{\Cpp}{C\raisebox{0.35 ex}{\footnotesize \(\!+\!+\)}}

\DeclareRobustCommand{\Cpp}% This still looks nicest in normalsize roman.
{C\raisebox{0.35 ex}{\footnotesize\hspace{-.2em}+\hspace{-.2em}+}\xspace}

% These two definitions look the same.
% They have rather large plus signs, which don't look nice, but at least
% they change font together, and change size consistently.
% As such, they work in headings and large fonts, whereas Cpp only works
% in normalsize rm font.

\DeclareRobustCommand{\Cppn}% C++ new
{C\raisebox{0.25 ex}{\hspace{-.2em}+\hspace{-.2em}+}\xspace}

%            .
% Therefore . .  Works both in and out of maths mode.
% But I would like to get the spacing between this and the next char better.
\def\so{\hbox{\kern.1em.\kern.145em\raise1.4ex\hbox{.}\kern.145em.\kern.5em}}

% \newcommand{\B}{{\sf Breath}}
\newcommand{\Bn}{{\sf BrAn}}
\newcommand{\Ms}{\mbox{\hspace{1ex}}} % Math space.

% The following line gets more space into the table made with the
% tabular environment:
% \renewcommand{\arraystretch}{2}

% nameList genarates a list with an item width of my choice.
% Syntax: \begin{nameList}{longestLabel}
% From p. 28 of David J. Buerger, "LaTeX for Scientists and Engineers", 
% McGraw-Hill, 1990
% \newcommand{\nameListLabel}[1]{\mbox{#1}\hfil}
\newcommand{\nameListLabel}[1]{\mbox{{\bf #1}}\hfil}
\newenvironment{nameList}[1]{%
\begin{list}{}
  {
    \let\makelabel\nameListLabel
    \settowidth{\labelwidth}{#1}
    \setlength{\leftmargin}{1.1\labelwidth}
  }
}{%
\end{list}}

% Note the original needed \bf or whatever in the item, like this:
% \item[{\bf Fox}] Principal character in the story,
% \item[{\bf Dog}] Secondary character in the story,
% \item[{\bf Food Dish}] Used daily by the dog.  Underwent

% Now have modified nameListLabel to incorporate {\bf ...}.

% Use like this example:
% \begin{nameList}{Food Dishxx}
% \item[Fox] Principal character in the story,
%     {\it The Quick Brown Fox}. \ldots
% 
% \item[Dog] Secondary character in the story,
%     {\it The Quick Brown Fox}. \ldots
% 
% \item[Food Dish] Used daily by the dog.  Underwent
%     possible damage when the dog landed in it.
% \end{nameList}

% I prefer my enumerations to have bold item numbers.
% Adapted from article.sty.

\def\labelenumi{{\bf\theenumi.}}
\def\labelenumii{{\bf(\theenumii)}}
\def\labelenumiii{{\bf\theenumiii.}}
\def\labelenumiv{{\bf\theenumiv.}}

% An attempt to make a list environment with less space between the 
% items.  It doesn't seem to have achieved that, though.

% \setlength{\topsep}{4pt plus2pt minus2pt}

\newenvironment{thinItemise}%
{\begin{itemize}\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}%
\setlength{\topsep}{0pt plus1pt minus0pt}}%
{\end{itemize}}

\newenvironment{thinEnumerate}%
{\begin{enumerate}\setlength{\itemsep}{0pt}\setlength{\parsep}{0pt}%
\setlength{\topsep}{0pt plus1pt minus0pt}}%
{\end{enumerate}}

% Have paragraphs separated by space rather than indented:

%\setlength{\parskip}{0.6em plus 0.1em minus 0.1em}
%\setlength{\parindent}{0ex}

\providecommand*{\bs}{\texttt{\char '134}\allowbreak} % Backslash `\'
\providecommand*{\bsnb}{\texttt{\char '134}} % Backslash, no break `\'
\newcommand{\lb}{\char '133} % left bracket `]'
\newcommand{\rb}{\char '135} % right bracket `]'
\newcommand{\hash}{\char '043} % hash `#', to use in \item[\hash]
                               % or in item description text.
\newcommand*{\vb}{{\tt\char '174}} % vertical bar `|'
%\newcommand*{\Ht}{\char '136} % hat `^'
\newcommand*{\wHt}{{\usefont{OMX}{cmex}{m}{n}\char '142}} % hat `^'
\newcommand*{\Lt}{{\tt\char '074}} % Less than `<'
\newcommand*{\Gt}{{\tt\char '076}} % Greater than `>'
\newcommand*{\Tld}{\char '176} % tilde `~' Cannot use \Tilde with AMS-LaTeX.

% From p. 92 of David J. Buerger
\newcommand{\ix}[1]{#1\index{#1}}

% Fraction with a slash, p. 311 of the TeXbook.
% \newcommand{\fracSl}[2]{\mbox{\kern.1em
% \raise.5ex\hbox{\small #1}\kern-.1em
% /\kern-.15em\lower.25ex\hbox{\small #2}}}

% This works better.
\newcommand{\fracSl}[2]{\mbox{$\,{}^{#1}\kern-.15em/\kern-.1em{}_{#2}$}}

% From lgrind.sty, changed to suit me.
\def\LGfsize{\small} %Size to use in \lgrindfile
%\def\LGfsize{\footnotesize} %Size to use in \lgrindfile
\def\LGsize{\small} %Size to use in displayed code, i.e, lagrind.

% If don't want a sans serif fontstyle, then uncomment these.

%\def\KWfont{\rm\bf} %Keyword font
%\def\VRfont{\rm\it} %Variable name font

\DeclareMathAlphabet{\mathvf}{OT1}{cmss}{m}{sl}

\def\Vf#1{\ensuremath{\mathvf{#1}}} % Variables, as produced by lgrind.
\def\Kf#1{\textsf{\textbf{\textup{#1}}}} % Keywords, as produced by lgrind.
\def\Of#1{\textsf{\textmd{\textup{#1}}}} % Operators, as produced by lgrind.

% Modifying behaviour of lgrind:
% \LGindent=0pt  %Indentation for displayed lines
% \global\LGleftnumtrue %Put line numbers on the left
% \LGnuminterval=10 %Line numbering interval

% Modified from article.doc
\def\emDescripLabel#1{\hspace\labelsep \emph{#1}}
\def\emDescrip{\list{}{\labelwidth\z@ \itemindent-\leftmargin
       \let\makelabel\emDescripLabel}}

\let\endemDescrip\endlist

% Typeset each item in the font for variables as ouput from lgrind:

\def\varDescripLabel#1{\hspace\labelsep \Vf{#1}}
\def\varDescrip{\list{}{\labelwidth\z@ \itemindent-\leftmargin
       \let\makelabel\varDescripLabel}}

\let\endvarDescrip\endlist

% This environment makes a figure look like a normal figure, while
% lground figures have the ruled floatstyle.  Nead use float.sty.
% See c:/mpi/alg/search/alg7.tex for an example of use.
% These lines need appear in the document:
% \floatstyle{ruled}
% \newfloat{Figure}{htbp}{lop}

\newenvironment{fig}{\floatstyle{plain}\restylefloat{Figure}\begin{Figure}}%
{\end{Figure}\floatstyle{ruled}\restylefloat{Figure}}

% This environment is intended to indent the left margin only,
% in the same way that the quote environment indents both the left and right
% margins.
\newenvironment{indentLeft}
  {\list{}{}\item[]}
{\endlist}

\newcommand{\initfamily}{\usefont{U}{yinit}{m}{n}}

% From p. 108 of \emph{The \LaTeX{} Companion}, for tabular.
\newcommand{\PreserveBackslash}[1]{\let\temp=\\#1\let\\=\temp}

% This definition for \meta is copied and pasted directly from doc.sty.
\DeclareRobustCommand\meta[1]{%
     \ensuremath\langle
     \ifmmode \expandafter \nfss@text \fi
     {%
      \meta@font@select
      \edef\meta@hyphen@restore
        {\hyphenchar\the\font\the\hyphenchar\font}%
      \hyphenchar\font\m@ne
      \language\l@nohyphenation
      #1\/%
      \meta@hyphen@restore
     }\ensuremath\rangle
}
\def\meta@font@select{\normalfont\itshape}

% This broken definition for \meta is copied and pasted directly from
% an ancient doc.sty:
%% \begingroup
%% \obeyspaces%
%% \catcode`\^^M\active%
%% \gdef\meta{\begingroup\obeyspaces\catcode`\^^M\active%
%% \let^^M\do@space\let \do@space%
%% \def\-{\egroup\discretionary{-}{}{}\hbox\bgroup\itshape}%
%% \m@ta}%
%% \endgroup
%% \def\m@ta#1{\leavevmode\hbox\bgroup$\langle$\normalfont\itshape#1\/$\rangle$\egroup
%%     \endgroup}
%% \def\do@space{\egroup\space
%%     \hbox\bgroup\normalfont\itshape\futurelet\next\sp@ce}
%% \def\sp@ce{\ifx\next\do@space\expandafter\sp@@ce\fi}
%% \def\sp@@ce#1{\futurelet\next\sp@ce}

% Basically taken from j:\texinput\oumath.sty:

\newcommand{\dint}{\displaystyle\int}
\newcommand{\tint}{\textstyle\int}
\newcommand{\dsum}{\displaystyle\sum}
\newcommand{\tsum}{\textstyle\sum}
% Note that AMS-LaTeX provides these already, so use \providecommand:
% \providecommand{\dfrac}{\displaystyle\frac}
% \providecommand{\tfrac}{\textstyle\frac}

% From page 100 of \emph{The \LaTeX{} Companion}:
\newcommand{\longpage}{\enlargethispage{\baselinestretch}}
\newcommand{\shortpage}{\enlargethispage{-\baselinestretch}}

% Multicols look no good with the default---too narrow.
\setlength{\columnsep}{1.5pc}

% Extra emphasis.
% Use \providecommand or \DeclareRobustCommand
% so still works if defined elsewhere.
\providecommand{\eemph}[1]{\emph{\textbf{#1}}}

% This is based on stuff from The LaTeX Companion, around p. 65.
% Provides numbered paragraphs.  Written for the MicroMouse Championships
% rules.

\newcounter{paraNumber}
\newenvironment{numpara}%
{% 
   \begin{list}{\textbf{\thesection.\arabic{paraNumber}\hspace{1em}}}%
   {%
         \usecounter{paraNumber}%
         \setlength{\labelsep}{0pt}%
         \setlength{\leftmargin}{0pt}%
         \setlength{\labelwidth}{0pt}%
         \setlength{\listparindent}{0pt}%
   }%
}%
{\end{list}}

% From ltspace.dtx:
%\def\@{\spacefactor\@m}
% The value 3000 was selected after a quick look at The TeX book.
\newcommand{\e}{\spacefactor3000}

\providecommand{\ie}{i.e.,\xspace}
\providecommand{\eg}{e.g.,\xspace}
\providecommand{\hex}{\ensuremath{_{16}}\xspace}
\providecommand{\oct}{\ensuremath{_{8}}\xspace}
\providecommand{\dec}{\ensuremath{_{10}}\xspace}
\providecommand{\bin}{\ensuremath{_{2}}\xspace}

% This environment is intended to indent the left margin only from the
% second line of a paragraph onwards.  The first line of each paragraph
% is flush with the left margin of the preceding text.
% There is no vertical space between the paragraphs.

\newenvironment{outdentLeft}%
  {\list{}%
  {%
         \setlength{\itemindent}{-2em}%
         \setlength{\itemsep}{0pt}%
         \setlength{\partopsep}{0pt}% remove vertical space above start of list
         \setlength{\parsep}{0pt}%    remove vertical space between paragraphs
         \setlength{\topsep}{0pt}%    remove vertical space above and below list
         \setlength{\leftmargin}{2em}%
         \setlength{\listparindent}{-2em}%
  }%
  \item[]}%
{\endlist}

% Change the defaults for the itemize environment markers:
\renewcommand{\labelitemii}{$\circ$}
\renewcommand{\labelitemiii}{\normalfont\bfseries--}
% \renewcommand{\labelitemiv}{$\cdots$}

% Want non-USA dates:
\renewcommand\today{\number\day\space \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
  \space \number\year}

% \newcounter{temp}
% 
% \newcommand{\enumSection}[1]%
% {%
%   \setcounter{temp}{enumi}%
%   \end{enumerate}%
%   \section*{#1}%
%   \begin{enumerate}%
%   \addtocounter{temp}{1}%
%   \setcounter{enumi}{temp}%
% }

% Silly problem with lgrind: get confusion with @ symbols being converted
% into long sequences of syntax errors.  Here's a fix.
% Can also turn off behaviour of @ with
%@-

\newcommand{\at}{\symbol{64}}

% A command to access the sans serif semibold condensed font:
% Adapted from fonttext.ltx:
\newcommand\sbcdefault{sbc}

% Adapted from latex.ltx:
\DeclareRobustCommand\sbcshape
        {\not@math@alphabet\sbcshape\relax
         \fontshape\sbcdefault\selectfont}
\DeclareTextFontCommand{\textsbc}{\sbcshape}
