%% This is the Linux documentation style file, designed by
%% Michael K. Johnson, 11-15-92.  It is to be
%% distributed freely under the GNU public license, version 2 or any
%% later version, obtainable as ftp.gnu.ai.mit.edu:/pub/gnu/COPYING
%% If there are bugs in this style sheet, please report them to
%% me: johnsonm@sunsite.unc.edu
%%
%% Copyright (c) 1992, 1993 Michael K. Johnson
%%
%% Converted to LaTeX-2e package by Peter Williams 4MAY94
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tlk2e}[1996]
\typeout{Linux Documentation Style Modified for The Linux Kernel}
\RequirePackage{ifthen}
\RequirePackage{latexsym}
\AtBeginDocument{\fixpagelayout\pagestyle{headings}}

% PAGE LAYOUT
\newcommand{\fixpagelayout}{
% Make textheight dependent on actual paper size (preserve margins)
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-2in}
\addtolength{\textheight}{-2\voffset}
\addtolength{\textheight}{-2\topmargin}
\addtolength{\textheight}{-2\headheight}
\addtolength{\textheight}{-2\headsep}
%\addtolength{\textheight}{-\footskip}
% Make textheight dependent on actual paper size (preserve margins)
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-1in}
\addtolength{\textwidth}{-2\hoffset}
\addtolength{\textwidth}{-\evensidemargin}
\addtolength{\textwidth}{-\oddsidemargin}
\addtolength{\textwidth}{-\marginparwidth}
\addtolength{\textwidth}{-2\marginparsep}
% Make text look lighter
\renewcommand{\baselinestretch}{1.14}
% \parskip is increased once more right after the TOC
\addtolength{\parskip}{0.2ex}
}
% Set up default margins
% Set up the page layout (top to bottom)
\setlength{\topmargin}{-0.5in}
\setlength{\headheight}{12pt}
\setlength{\headsep}{35pt}
\setlength{\footskip}{30pt}
% Set up the page layout (left to right)
\setlength{\oddsidemargin}{0.5in}
\setlength{\evensidemargin}{0.5in}
\setlength{\marginparwidth}{1in}
\setlength{\marginparsep}{0.1in}
\fixpagelayout

%% Titlepage macros:

% To use the maketitle{} macro, you need to first do the following:
%  \title{Title of your masterpiece}
%  \years{1992, 1993} %or whatever year(s) hold for the copyright
%  \author{Your N. Here\\Other Name Here, if any}
%  \version{$\Alpha$ DRAFT, Version 0.02}
%  \abstract{This should be an abstract-like thing for the front of
%   your masterpiece.  It will be set in \sf font, so be aware of
%   that.  In it you may include any information that ought to be on
%   the title page.  It is, in a sense, a mini-introduction.  For
%   drafts, I include instructions here for my proofreaders, but it
%   will be a real abstract when publically available versions of my
%   docs come out.}

% Find out if the logo can be created
\newboolean{LinuxLogoOK}
\IfFileExists{epsf.sty}{
\IfFileExists{LinuxLogo.epsf}{\setboolean{LinuxLogoOK}{true}
\RequirePackage{epsf}}
{\setboolean{LinuxLogoOK}{false}}}
{\setboolean{LinuxLogoOK}{false}}

\renewcommand{\@title}{}
\renewcommand{\title}[1]{\renewcommand{\@title}{#1}}
\newcommand{\@years}{}
\newcommand{\years}[1]{\renewcommand{\@years}{#1}}
\renewcommand{\@author}{}
\renewcommand{\author}[1]{\renewcommand{\@author}{#1}}
\newcommand{\@version}{}
\newcommand{\version}[1]{\renewcommand{\@version}{#1}}
\newcommand{\@abstract}{}
\newcommand{\abstract}[1]{\renewcommand{\@abstract}{#1}}

\renewcommand{\maketitle}{\fixpagelayout\begin{titlepage}
\let\footnotesize\small
\let\footnoterule\relax
\setcounter{page}{0}
\null
\ifthenelse{\boolean{LinuxLogoOK}}
%  {\mbox{}\hfill\setlength{\epsfysize}{3in}\epsfbox{LinuxLogo.epsf}}
  {\setlength{\epsfysize}{3in}\epsfbox{LinuxLogo.epsf}}
  {\vskip 3 in}

\noindent
{\Large\sf \@title}\\
\rule{\textwidth}{1mm}\\
\mbox{} \hfill Copyright \copyright\ \@years\ \begin{tabular}[t]{r}
                                              \@author\end{tabular}\\
\mbox{} \hfill \@version

\vspace{.75in}\noindent
{\sf \@abstract}
\end{titlepage}%
\setcounter{footnote}{0}%
\renewcommand{\@author}{}\renewcommand{\@title}{}\renewcommand{\@years}{}
\renewcommand{\@abstract}{}\renewcommand{\@version}{}
\let\maketitle\relax}


%%% ONE-SIDED/TWO-SIDED DEPENDENCIES
%\newcommand{\@define@headers}{%
\if@twoside % ``book'' style was chosen.  We use @twoside becase there
% are no differences between documentstyles that make much sense, and
% no defines like @book@, @report@, etc. are defined.  Therefore, we use
% the difference that at least means something in the current context.
% We *really* want to be able to do seperate things for book:oneside,
% book:twoside, report:oneside, report:twoside, but it's not possible
% because of \LaTeX's architechture.  Such is life.
 \def\ps@headings{\let\@mkboth\markboth
\fixpagelayout
  \def\@oddfoot{}\def\@evenfoot{}%       No feet.
  \def\@evenhead{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth
                 \rm \thepage\hfil \sl \leftmark}     % Left heading.
  \def\@oddhead{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth
                {\sl \rightmark}\hfil \rm\thepage}    % Right heading.
  \def\chaptermark##1{\markboth {{\bf\ifnum \c@secnumdepth >\m@ne
      \@chapapp\ \thechapter. \ \fi ##1}}{}}%
  \def\sectionmark##1{\markright {{\bf\ifnum \c@secnumdepth >\z@
   \thesection. \ \fi ##1}}}}

\else % if not book style, then
 \def\ps@headings{\let\@mkboth\markboth
\fixpagelayout
  \def\@oddfoot{}\def\@evenfoot{}%       No feet.
  \def\@oddhead{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth
                {\sl \rightmark}\hfil \rm\thepage}    % Right heading.
  \def\@evenhead\@oddhead
  \def\chaptermark##1{\markboth {{\bf\ifnum \c@secnumdepth >\m@ne
       \@chapapp\ \thechapter. \ \fi ##1}}{}}%
  \def\sectionmark##1{\markright {{\bf\ifnum \c@secnumdepth >\z@
   \thesection. \ \fi ##1}}}}

\fi
%}

\iffalse
% SECTIONING
%% Redefining subsubsection, paragraph, and subparagraph to be more
%% like their parents.  We are doing this because we don't need
%% normal "paragraphs" as typographers usually think of them, but
%% we {\em do} need more levels of normal sectioning, and it is least
%% traumatic to reuse the paragraph and subparagraph names.
\renewcommand{\paragraph}{\@startsection{paragraph}{4}{\z@}
               {-3.25ex plus -1ex minus -.2ex}% neg => supress para indent
               {1.5ex plus .2ex}% pos => heading not in paragraph
               {\reset@font\normalsize\bf}}
\renewcommand{\subparagraph}{\@startsection{subparagraph}{5}{\z@}
               {-3.25ex plus -1ex minus -.2ex}% neg => supress para indent
               {1.5ex plus .2ex}% pos => heading not in paragraph
               {\reset@font\normalsize\bf}}
\renewcommand{\thesubsubsection}{\thesubsection .\arabic{subsubsection}}
\renewcommand{\theparagraph}{\thesubsubsection .\arabic{paragraph}}
\renewcommand{\thesubparagraph}{\theparagraph .\arabic{subparagraph}}
\setcounter{secnumdepth}{5}
\fi

% USEFUL MACROS

%\newcommand{\linux}{{\rm\sc Linux}}
\newcommand{\linux}{Linux}              % Always use this when
				        % refering to the \linux\
				        % operating system, like that.
%\newcommand{\Linux}{{\rm\sc Linux}}    % Or \Linux, if you insist...
\newcommand{\Linux}{Linux}              % Or \Linux, if you insist...
\newcommand{\key}[1]{{\fbox{\sf #1}}}   % Use this to mark keys, like
				        % \key{del} for the delete key.
\newcommand{\ret}{\fbox{\sf return}}    % Special case for the return key.
\newcommand{\st}{\small\tt}             % Small typewriter -- comes in handy.
\newcommand{\lb}{{\tt\char '173}}       % Left Brace '{'
\newcommand{\rb}{{\tt\char '175}}       % Right Brace '}'
\newcommand{\lbr}{$\langle$}		% Left Bracket '<'
\newcommand{\rbr}{$\rangle$}		% Right Bracket '>'
\newcommand{\bs}{{\tt\char '134}}       % BackSlash '\'
\newcommand{\tm}{${}^{\mbox{\tiny\sf TM}}$}
\newcommand{\TM}{\tm}                   % TM trademark symbol in
				        % either case
\newcommand{\unix}{{\sc un$\star$x}}  % Unix is a trademark of USL,
				        % mention that if you use it...
\newcommand{\cparam}[1]{{\rm \lbr{\sl #1}\rbr}}
					% Metavariables.

% The following is for the \blackdiamond command.  \blackdiamond is
%  used before paragraphs that are intended to be more difficult than
%  others, or that readers should pay more attention to.  Use more
%  sparingly than Knuth uses the curvy road, preferably\dots
\newcommand{\strutdepth}{\dp\strutbox}
\newcommand{\specialdi}{\vtop to \strutdepth{
    \baselineskip\strutdepth
    \vss\llap{$\Diamond$\hspace{.2 in}}\null}}
\newcommand{\blackdiamond}{\strut\vadjust{\kern-\strutdepth\specialdi}}

%% By kind permission of Matt Welsh:
%% The following is for the \namedlabel command. This command inserts a
%% ``named'' label in the .aux file (whereas normal ``label'' command
%% uses only the current section number). This allows you to do named
%% cross-references.
%%
%% Usage: \namedlabel{label-name}{the-label-string}
%% Ex:
%%     \chapter{Installing Linux}
%%     \namedlabel{chap-install}{Installing Linux}
%%     ...
%%     Please refer to section ``\ref{chap-install}'' on page
%%     \pageref{chap-install}.
%%
%% It is completely compatible with \ref, \pageref, and other label commands.
%% This is here primarily because the Nutshell books do not use section
%% numbers.

\def\namedlabel#1#2{\@bsphack\if@filesw {\let\thepage\relax
   \def\protect{\noexpand\noexpand\noexpand}%
   \edef\@tempa{\write\@auxout{\string
      \newlabel{#1}{{#2}{\thepage}}}}%
   \expandafter}\@tempa
   \if@nobreak \ifvmode\nobreak\fi\fi\fi\@esphack}

%%% ENVIRONMENTS

%% The screen environment is a convenience environment.  There is
%%  little agreement on what it should do, so I have stuck with the
%%  current definition.  Some want it to do more, but different people
%%  want different things, and for the sake of later conversion, I am
%%  reluctant to add 20 versions of this that do similar things.  When
%%  opinion on this type of thing coalesces, perhaps there will be two
%%  or three different versions.  I myself prefer to do
%%    \begin{screen}\begin{verbatim}
%%    blah blah blah blah
%%    blah blah blah blah
%%    \end{verbatim}\end{screen}

\newenvironment{screen}%
 {\begin{quote}\bgroup\small}%
 {\egroup\end{quote}}


%% the tscreen environment automatically goes into typewriter type,
%%  but is otherwise like the screen environment

\newenvironment{tscreen}%
 {\begin{quote}\bgroup\small\tt}%
 {\egroup\end{quote}}


%% The dispitems environment was created for cases where you want the
%%  output to look something like the following:
%%    xxxx      jjjjjjjjjjjjjjj
%%              jjjjjjjjjjjjjjj
%%              jjjjjjjjjj
%%
%%              jjjjjjjjjjjjjjj
%%              jjjjjjj
%%
%%    xxxxxxx   jjjjjjjjjj
%%
%%    xx        jjjjjjjjjjjjjjj
%%              jjjjjjjjjjjjj
%%
%%    xxxxxxxxxxxxxxxxx
%%              jjjjjjjjjjjjjjj
%%              jjjjjjj
%%  No such environment is given in LaTeX, but I think it is
%%  convenient for some things.

%% Re-designed \@item from latex.tex for the dispitems environment.
%%  If the box is larger than the spot alloted for it, a new line
%%  should be started instead of pushing the contents over.  Thanks to
%%  Ulrich Drepper <drepper@karlsruhe.gmd.de> for his help with this.

%\def\@makelbl#1{\mbox{#1}}

%\def\@itm[#1]{
%\if@noparitem
% \@donoparitem
%\else \if@inlabel \indent \par \fi \ifhmode \unskip\unskip \par \fi
% \if@newlist \if@nobreak \@nbitem \else \addpenalty\@beginparpenalty
% \addvspace\@topsep \addvspace{-\parskip}\fi \else
% \addpenalty\@itempenalty \addvspace\itemsep \fi \global\@inlabeltrue
%\fi
%\everypar{\global\@minipagefalse\global\@newlistfalse
%         \@tempdima\hsize \advance\@tempdima -\leftmargin
%          \if@inlabel\global\@inlabelfalse \hskip -\parindent
%             \ifdim\wd\@labels>0 pt
%                \hbox to\@tempdima{\unhbox\@labels\hfill}
%             \else
%                \box\@labels \penalty\z@
%             \fi \fi
%          \everypar{}}\global\@nobreakfalse
%\if@noitemarg
% \@latexerr{Items must have labels in the dispitems environment}\@ehc
%\fi
%\setbox\@tempboxa\hbox{\makelabel{#1}}%
%\global\setbox\@labels
% \hbox{\unhbox\@labels \hskip \itemindent
%       \hskip -\labelwidth \hskip -\labelsep
%       \ifdim \wd\@tempboxa >\labelwidth
%                \box\@tempboxa
%          \else \hbox to\labelwidth {\unhbox\@tempboxa\hfill}\fi
%       \hskip \labelsep}\ignorespaces}

% The above code fails under LaTeX2e
% Modification based on pp63-64 of the Latex Companion by Goossens,
% Mittelbach and Samarin 1993.  ISBN0-201-54199-8
\newlength{\@this@label}
\newcommand{\@dispitem@label}[1]{%
  \settowidth{\@this@label}{\mbox{#1}}%
  \ifthenelse{\lengthtest{\@this@label > \labelwidth}}%
    {\parbox[b]{\labelwidth}{\makebox[0pt][l]{#1}\\}}%
    {\mbox{#1}}%
  \hfil\relax
}

\newenvironment{dispitems}%
 {\begin{list}%
  {}% no text if no optional argument to \item
  {\renewcommand{\makelabel}{\@dispitem@label}%
   \setlength{\topsep}{1.5 ex}%
   \setlength{\itemsep}{1 ex}%
   \setlength{\labelwidth}{.9 in}%
   \setlength{\labelsep}{0.1 in}%
   \setlength{\leftmargin}{1 in}%
   \setlength{\rightmargin}{0 in}%
   \setlength{\parsep}{1 ex}%
   \setlength{\listparindent}{0 in}%
%   \renewcommand{\makelabel}{\@makelbl}%
%   \renewcommand{\@item}{\@itm}%
   }%
  }%
 {\end{list}}

% I used \ditem in some earlier version of the NAG, so here we go
\let\ditem\item

%% abib is an environment for a do-it-yourself annotated bibliography.
%%  You are under no obligation to use this, but I found it helpful.
%%  To use it, do this:
%%    \begin{abib}
%%     {<title>}
%%     {<author>}
%%     {<publisher>, <year>}
%%     {<ISBN>}
%%     {\$<price>}
%%     <abstract>
%%    \end{abib}
%%  You much include some text in the abstract, or LaTeX will complain
%%  about a possible missing \item.  If you aren't going to to an
%%  annotated bibliography, you might as well just use BibTeX or
%%  build your own citation list.  I just didn't need the citation
%%  list, but wanted the annotated bibliography.  It would be OK for
%%  this annotated bibliography to itself cite a normal bibliography.

\newcommand{\parlabel}[1]{\leavevmode{\parbox[t]{\labelwidth}{#1}}}
\newenvironment{abib}[5]%
 {\begin{list}%
  {}% no text if no optional argument to \item
  {\setlength{\topsep}{4 ex}
   \setlength{\itemsep}{.1 ex}
   \setlength{\labelwidth}{1 in}
   \setlength{\labelsep}{0.2 in}
   \setlength{\leftmargin}{1.2 in}
   \setlength{\rightmargin}{0 in}
   \setlength{\parsep}{.5 ex}
   \setlength{\listparindent}{0 in}
   \renewcommand{\makelabel}{\parlabel}}
   \item [{\bf Title:}] #1
   \item [{\bf Author:}] #2
   \item [{\bf Publisher:}] #3
   \item [{\bf ISBN:}] #4
   \item [{\bf Appr.~Price:}] #5
  \end{list}\begin{quotation}}%
 {\end{quotation}}

