%
% This file contains all the \usepackage and whatnot definitions,
% so they can be included as a unit. This is to make it possible
% to build each chapter separately with as little fuss as possible.
%

\usepackage{ifpdf}
\ifpdf
\usepackage[pdftex]{graphicx}
\else
\usepackage{graphicx}
\fi

% \nohtml is defined by buildguide.sh
% so that the manual can be succesfully built without
% latex2html installed, even though we need \usepackage{html}
%
\usepackage{ifthen}
\ifthenelse{\isundefined{\nohtml}}{
\usepackage{html}
}{
% not latex2html
\usepackage{comment} 
\excludecomment{htmlonly}
\excludecomment{rawhtml}
}

\usepackage{url}

%\usepackage{multicol}		%?

\usepackage{ragged2e}
\usepackage{parskip}
\usepackage{sectsty}

% let's have some real fonts
\usepackage{palatino}
\usepackage{courier}

% Apparently in teTeX 3.x ``helvetic'' became ``helvet''.
%\usepackage{helvetic}
%\renewcommand{\sfdefault}{phv}  % the contents of the old helvetic.sty
\usepackage{helvet}

% without help, latex sets these characters in the wrong font inside \tt
\newcommand{\us}{{\tt\char`\_}}
\newcommand{\bra}{{\tt\char`\{}}
\newcommand{\ket}{{\tt\char`\}}}
\newcommand{\bs}{{\tt\char`\\}}

% this doesn't exist by default?
%\newcommand{\degrees}{{\char'027}}
\newcommand{\degrees}{$^{\circ}$} % fix sdh4 9/29/07


%  Unfortunately, these leave the vertical spacing attached to the
%  chapter and section headings unchanged, which leaves huge gaps
%  in everything. I've asked some people for advice. XXX.
%
%\allsectionsfont{\sffamily\FlushRight}
\chapterfont{\sffamily\FlushRight\Large}
\sectionfont{\sffamily\large}
\subsectionfont{\sffamily\normalsize}
\paragraphfont{\sffamily\normalsize}

\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}
\setlength{\paperwidth}{8.5in}
\setlength{\paperheight}{11in}
\setlength{\oddsidemargin}{-0in}
\setlength{\evensidemargin}{-0in}
\setlength{\textwidth}{6.5in}
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9.25in}
\setlength{\headheight}{0.25in}
\setlength{\headsep}{0.25in}

% While this ought, in theory, to make things work better than
% a bunch of setlengths, it's generating odd and even side margins,
% I'd rather it didn't, and I don't feel like looking up how to 
% change that right now. XXX
%\usepackage[pdftex,paperwidth=8.5in,paperheight=11in,total={6.5in,9.25in}]{geometry}

% The converted version had this, but the original manual is not set
% with ragged right, or at least the WordPerfect pdf from Stephen's
% tree isn't.
%
%\raggedright

% I don't think this is used...
%\newcommand{\bracket}[1]{$<${\bf #1}$>$}

% Heading on both sides of the page. Used in the appendices.
\newcommand{\dualheading}[2]{\vskip 1ex \textbf{\large #1} \hfill [#2]}

% You can't just do \sf \bf; that gets you roman bold.
\newcommand{\sfbf}{\sf \fontseries{b} \selectfont}

% Typographical conventions.
%
% I am mostly following the cues from the wordperfect version, but a
% few things need to change; in particular, it doesn't make sense in
% this day and age to use uppercase to set off filenames. So:
%
%    C keywords			- courier		\agcode
%    file and path names	- courier		\agfile
%    menu items and ui actions	- italic		\agmenu
%    ui options			- italic		\agoption
%    configuration parameters	- bold			\agparam
%    technical term definitions	- italic		\agterm
%    window names		- normal		\agwindow
%
% Don't forget that we can also use small caps (\textsc) for
% something.
%
% I was using helvetica bold (\sfbf above) for \agmenu and \agoption,
% but that looks like crap - the fonts don't seem to space right when
% mixed. Helvetica non-bold is not visually distinguishable enough
% from Palatino and looks like etaoin shrdlu. So, I think we can't use
% Helvetica for anything.
%
% There ought to be a section describing these. XXX.
%

% XXX should have \agparam automatically add indexing. will that work?
\newcommand{\agcode}[1]{\texttt{#1}}	% code, C keywords, etc.
\newcommand{\agfile}[1]{\texttt{#1}}	% file and path names
\newcommand{\agmenu}[1]{{\it #1}}	% menu items and ui actions
\newcommand{\agoption}[1]{{\it #1}}	% ui options
\newcommand{\agparam}[1]{\textbf{#1}}	% configuration parameters
\newcommand{\agterm}[1]{{\it #1}}	% technical term definitions
\newcommand{\agwindow}[1]{#1}		% window names

% This is like \agparam but for the list headings in Appendix A.
\newcommand{\agparamheading}[2]{\dualheading{\agparam{#1}}{#2}}


%
% Environment for the indented code examples.
%
\makeatletter

%begin{latexonly}
\newenvironment{indentingcode}[1]
{
\begin{list}{}{
  \setlength{\listparindent}{0in} 
  \setlength{\rightmargin}{0in} 
  \setlength{\leftmargin}{#1}
  \setlength{\itemindent}{0in}
  \setlength{\labelwidth}{0in}
  \setlength{\labelsep}{0in}
  \setlength{\parsep}{0in}
} \frenchspacing \@vobeyspaces \obeylines \tt \item 
} {
\end{list} 
}
%end{latexonly}

\begin{htmlonly}
\newenvironment{indentingcode}[1]{
\begin{rawhtml}
<pre>
\end{rawhtml}
}
{
\begin{rawhtml}
</pre>
\end{rawhtml}
}
\end{htmlonly}

\makeatother

% This is for metavariable names inside an indentingcode block.
\newcommand{\codemeta}[1]{{\rm \it #1}}

%
% This is for indenting certain tables.
% (Shouldn't a table be able to indent itself? You'd think...)
%
\newenvironment{indenting}[1]
{
\begin{list}{}{
  \setlength{\listparindent}{0in} 
  \setlength{\rightmargin}{0in} 
  \setlength{\leftmargin}{#1}
  \setlength{\itemindent}{0in}
  \setlength{\labelwidth}{0in}
  \setlength{\labelsep}{0in}
} \item 
} {
\end{list}
}
