% This is a LaTeX2e package for the UKTUG FAQ document.
%
\ProvidesPackage{faq}[1996/01/19 UK TUG package for TeX FAQ]
%
% uses production LaTeX 2e commands
\NeedsTeXFormat{LaTeX2e}[1994/06/01]% at least!
%
% version 0.1  RF  1994/09/26
%         0.2  RF  1994/10/09-15
%         0.3  RF  1994/10/16 (after suggestions from Alan Jeffrey)
%         0.4  RF  1994/10/22
%
\def\fileversion{1.0b}
\def\filedate{1996/01/19}
%
\typeout{UK TUG FAQ macros v\fileversion, \filedate}
%
% what fonts are we going to typeset in?
\InputIfFileExists{faqfont.cfg}%
      {\typeout{FAQ -- loading font configuration file faqfont.cfg}}
      {\RequirePackage{times}%
      % stretchability recommendations from psnfss2e.tex
      \tolerance800
      \emergencystretch2em
      \doublehyphendemerits5000
      \hfuzz0pt
      \leftskip0pt minus 1pt
      \rightskip0pt minus 1pt
      % use cmtt for typewriter rather than Cou-beastly-rier
      \renewcommand{\ttdefault}{cmtt}%
      \@ifundefined{Dings}{\RequirePackage{pifont}%
        \def\Dings{\nopagebreak{\footnotesize
            \dingline{167}}}}%
      {}}
%
% general support
%\RequirePackage{calc}
%
% code for handling logo font
\RequirePackage{mflogo}
%
% get texnames package (as amended)
\RequirePackage{texnames}
%
% ifthenelse for the undefined references
\RequirePackage{ifthen}
%
% we define html only stuff using Eijkhout's package
\RequirePackage{comment}
\excludecomment{htmlversion}
%
% the Baskerville and other logos and abbreviations
\providecommand\BV{\emph{Baskerville}}
\providecommand\DANTE{\acro{DANTE}\@}
\providecommand\MSDOS{\acro{MS-DOS}\@}
\providecommand\CDROM{\acro{CD-ROM}\@}
\providecommand\TeXXeT{\TeX-{}-X\lower.5ex\hbox{E}\kern-.1667emT\@}
\providecommand\MLTeX{ML-\TeX}
\def\careof{\leavevmode\hbox{\raise.75ex\hbox{c}\kern-.15em
                /\kern-.125em\smash{\lower.3ex\hbox{o}}}}
%
% \cs{SMC} \emph{isn't} small caps~--- Barbara Beeton says she thinks
% of it as ``big small caps''.  She says (modulo capitalisation of
% things\dots):
% \begin{quote}
%   For the things it's used for, regular small caps are not
%   appropriate~--- they're too small.  Real small caps are
%   appropriate for author names (and are so used in continental
%   bibliographies), section headings, running heads, and, on
%   occasion, words to which some emphasis is to be given.  \cs{SMC}
%   was designed to be used for acronyms and all-caps abbreviations,
%   which look terrible in small caps, but nearly as bad in all caps
%   in the regular text size.  The principle of using ``one size
%   smaller'' than the text size is similar to the design of caps in
%   German~--- where they are smaller relative to lowercase than are
%   caps in fonts intended for English, to improve the appearance of
%   regular text in which caps are used at the heads of all nouns, not
%   just at the beginnings of sentences.
% \end{quote}
%
% We define this in terms of the memory of the size currently selected
% that's maintained in \cs{@currsize}: if the user does something
% silly re.~selecting fonts, we'll get the wrong results.  The
% following code is adapted from |relsize.sty| by Donald Arseneau and
% Matt Swift, from a 2.09 original by Bernie Cosell.  (Note that the
% order of examination of \cs{@currsize} is to get the commonest cases
% out of the way first.)
%    \begin{macrocode}
%<!latex2e>\def\SMC{\small}
%<*latex2e>
\DeclareRobustCommand\SMC{%
  \ifx\@currsize\normalsize\small\else
   \ifx\@currsize\small\footnotesize\else
    \ifx\@currsize\footnotesize\scriptsize\else
     \ifx\@currsize\large\normalsize\else
      \ifx\@currsize\Large\large\else
       \ifx\@currsize\LARGE\Large\else
        \ifx\@currsize\scriptsize\tiny\else
         \ifx\@currsize\tiny\tiny\else
          \ifx\@currsize\huge\LARGE\else
           \ifx\@currsize\Huge\huge\else
            \small\SMC@unknown@warning
 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}
\newcommand\SMC@unknown@warning{\PackageWarning{faq}{Unknown text font
                                   size command -- using \string\small}}
\DeclareRobustCommand\textSMC[1]{{\SMC #1}}
%    \end{macrocode}
%
% The \cs{acro} command uses \cs{SMC} as it was originally intended.
% Note that, since most of these things are uppercase-only names, it
% fiddles with the spacefactor after inserting its text.
%
%    \begin{macrocode}
\DeclareRobustCommand\acro[1]{\textSMC{#1}\@}
%</latex2e>
%<!latex>\def\acro#1{{\SMC #1}\spacefactor\@m}
%<!latex2e>\def\acro#1{{\SMC #1}\@}
%    \end{macrocode}
%
%\TUGboat (effectively) takes arguments {<empty>}vol(issue)
\DeclareRobustCommand\TUGboat[1]{\expandafter\@TUGboat\ignorespaces}
\def\@TUGboat#1(#2){\textsl{TUGboat} \textbf{#1}(#2)}
%
% The NTS and eTeX (and for consistency Eplain) logos
\DeclareRobustCommand\NTS{$\mathcal{N}$\lower.5ex\hbox
    {$\mathcal{T}$}$\mathcal{S}$\@}
\DeclareRobustCommand\eTeX{{$\varepsilon$}-\TeX}
\DeclareRobustCommand\Eplain{Eplain}
%
% Other odds and ends (appear differently in TeX and http or plain
% text
\DeclareRobustCommand\WYSIWYG{\textsc{wysiwyg}}
%
% Command for doing `square one' :-}
\newcommand\sqfbox[1]{\framebox{\makebox[\totalheight]{#1\/}}}
%
% Here's a \fullline macro that works in lists and so on
\newcommand\fullline[1]{\@tempdima\hsize\relax
  \advance\@tempdima-\leftmargin\relax
  \advance\@tempdima-\rightmargin\relax
  \hb@xt@\@tempdima{#1}}
%
% 2e's LaTeX logo sets the A in scripstyle jammed up to the top of the T; it
% also has the advantage that it's set in the same font as the
% surrounding text.  However, the esteemed bbeeton says the logo looks
% "squidge awful" in italic text (I agree; and the same is true of its
% behaviour in slanted text)
%
% So here's a version that allows for the slant of the leading L
\DeclareRobustCommand{\LaTeX}{L%
        {\setbox0\hbox{T}%
         \setbox\@tempboxa\hbox{$\m@th$%
                                \csname S@\f@size\endcsname
                                \fontsize\sf@size\z@
                                \math@fontsfalse\selectfont
                                A}%
         \@tempdima\ht0
         \advance\@tempdima-\ht\@tempboxa
         \@tempdima\strip@pt\fontdimen1\font\@tempdima
         \advance\@tempdima-.36em
         \kern\@tempdima
         \vbox to\ht0{\box\@tempboxa
                      \vss}%
        }%
        \kern-.15em
        \TeX}
%
% Ditto for \AllTeX (as used in TUGboat)
\DeclareRobustCommand{\AllTeX}{(L%
        {\setbox0\hbox{T}%
         \setbox\@tempboxa\hbox{$\m@th$%
                                \csname S@\f@size\endcsname
                                \fontsize\sf@size\z@
                                \math@fontsfalse\selectfont
                                A}%
         \@tempdima\ht0
         \advance\@tempdima-\ht\@tempboxa
         \@tempdima\strip@pt\fontdimen1\font\@tempdima
         \advance\@tempdima-.36em
         \kern\@tempdima
         \vbox to\ht0{\box\@tempboxa
                      \vss}%
        }\kern-.075em)%
        \kern-.075em\TeX}
%
% A similar game is used in defining an `all LaTeX' sort of thing:
\DeclareRobustCommand\twee{2$_{\textstyle\varepsilon}$}
%
% it proves that, for Alan's stuff, the following needs to have been
% done _before_ we define the macros
\RequirePackage{shortvrb}
\MakeShortVerb{\|}
%
% A command which sets some text in typewriter, with the hyphenchar 
% temporarily set to its first argument \FAQverb\HYPHEN{TEXT}.
% NB: This requires no catcode hackery, so should work inside moving 
% arguments.  It will, however, produce spurious spaces after CSs, and 
% won't allow brace-unmatched input.  It also won't survive going into a 
% moving argument if \HYPHEN won't.
%
\let\FAQverbFamily\ttfamily
\DeclareRobustCommand{\FAQverb}[2]{{%
    \ifvmode\leavevmode\fi
    \lefthyphenmin=256\setlanguage\language
    \FAQverbFamily\hyphenchar\the\font`#1\relax
    \def\@tempa{#2}%
    \expandafter\@faq@strip\meaning\@tempa\@faq@strip
    \hyphenchar\the\font\m@ne
}\setlanguage\language}
\def\@faq@strip#1->#2\@faq@strip{#2}
%
% Document markup:
%
\makeatother   % because @ is a delimiter here, it had better have the
               % same catcode as it will when the macro's invoked
\def\Email|#1@#2|{\FAQverb\-{#1@}\penalty10\FAQverb\.{#2}} % email
\def\Emaildot|#1@#2|{\FAQverb\.{#1@}\penalty10\FAQverb\.{#2}}
\makeatletter
\def\FTP|#1|{\FAQverb\.{#1}}                               % FTP site
\def\File|#1|{\FAQverb\/{#1}}                              % file name
\def\CTAN{\FAQverb\/}                                      % CTAN path
\def\Newsgroup|#1|{\FAQverb\.{#1}}                         % newsgroup
\def\URL|#1://#2/#3|{\FAQverb\.{#1://#2/}\penalty10\FAQverb\/{#3}}
\def\path|#1|{\FAQverb\/{#1}}                              % generic path
%
% same game, slightly different style
\def\ProgName|#1|{%                                        % program name
                  {%
                   \def\FAQverbFamily{\rmfamily\mdseries\itshape}%
                   \FAQverb\_{#1}\/%
                  }%
                 }
\let\Package\ProgName                                      % pro tem
%
% ISBN references
\def\ISBN#1{\mbox{\acro{ISBN}}~#1}
%
% have we read the CTAN references?
\newif\ifnotreadCTAN        \notreadCTANtrue
%
% Alan's code for CTAN references:
%
% define a location for a package on CTAN
% #1 is the package name
% #2 is the CTAN path to the thing
% a package in a directory
\newcommand{\CTANdirectory}[2]{\@ifundefined{ctan-#1}{%
   \expandafter\gdef\csname ctan-#1\endcsname{#2}%
}{%
   \PackageWarning{faq}{Repeated definition of label: #1}%
}}
%
% a package in a single file (the same appearance, but the WWW version is  
% different).
\let\CTANfile\CTANdirectory
%
% Make reference to a CTAN package
%
% counter for the undefined references
\newcounter{CTAN@unrefs}
%
% the command itself
\DeclareRobustCommand{\CTANref}[1]{\@ifundefined{ctan-#1}{%
    \PackageWarning{CTAN}{Undefined reference: #1}%
    \stepcounter{CTAN@unrefs}%
}{%
    \edef\@tempa{\noexpand\CTAN{\csname ctan-#1\endcsname}}\@tempa
}}
%
% hook for diagnosing undefined references at the end
\AtEndDocument{\ifthenelse{\theCTAN@unrefs > 0}{%
    \PackageWarning{CTAN}{There were \arabic{CTAN@unrefs} undefined
      references to CTAN}%
    }%
    {}%
  }
%
% a slight variation of description for lists of book titles
\newcommand{\booklabel}[1]{\hspace\labelsep\normalfont\itshape #1}
\newenvironment{booklist}{\begin{list}{}%
   {\labelwidth\z@ \itemindent-\leftmargin \let\makelabel\booklabel}}%
   {\end{list}}
%
% proglist is the same as booklist if we're using italics for program
% names, but will need hacking otherwise
\newenvironment{proglist}{\begin{booklist}}{\end{booklist}}
%
% \raggedwithindent is useful when we've got an URL or something
% overrunning the end of the line (and this line is terminated with
% \\)
%
% Typical usage is within the argument of a \nothtml command
\newcommand\raggedwithindent{%
  \rightskip=\z@\@plus5em\relax
  \spaceskip=.3333em\relax
  \xspaceskip=.5em\relax
  \hangindent=1pc\relax}
%
% the little bit(s) of code that's(re) going to be ignored when the
% html is generated are enclosed by the following two commands
\let\htmlignore\relax
\let\endhtmlignore\relax
%
% or it's the argument to \nothtml
\newcommand\nothtml[1]{#1}
%
% A Donald Arseneau marvel:
% \@removefromreset{FOO}{BAR} : removes counter FOO from the list of
%                               counters \cl@BAR to be reset when
%                               counter BAR is stepped.
%                               The opposite of \@addtoreset
\def\@removefromreset#1#2{\let\@tempb\@elt
   \def\@tempa#1{@&#1}\expandafter\let\csname @*#1*\endcsname\@tempa
   \def\@elt##1{\expandafter\ifx\csname @*##1*\endcsname\@tempa\else
         \noexpand\@elt{##1}\fi}%
   \expandafter\edef\csname cl@#2\endcsname{\csname cl@#2\endcsname}%
   \let\@elt\@tempb
   \expandafter\let\csname @*#1*\endcsname\@undefined}
%
% the question structure
% \Question[label name]{question asked}
% if [label name] present, the named label is assigned with \Qlabel
\newcommand\Question[2][]{\subsection{\protect\raggedright#2}%
  \def\reserved@a{#1}%
  \ifx\reserved@a\@empty\else\Qlabel{#1}\fi}
%
% now let's hack around a bit in order to make things slightly
% prettier
%
% first: numbering of subsections -- doesn't include section nos, not
% reset for each section
\renewcommand{\thesubsection}{\arabic{subsection}}
\@removefromreset{subsection}{section}
%
% second: sections `numbered' alphabetically
\renewcommand{\thesection}{\Alph{section}}
%
% third: subquestions (added in between issues ...) are
% subsubsections, and they're lettered as appendages to the questions
% (and reset on them)
\renewcommand\thesubsubsection{\thesubsection\alph{subsubsection}}
\newcommand\subQ[2]{\def\reserved@a{#1}\def\reserved@b{\endhtmlignore}
  \ifx\reserved@a\reserved@b
    \def\reserved@a{#2}\def\reserved@b{\Question}
    \ifx\reserved@a\reserved@b
      \else\subQwarning\fi
  \else\subQwarning\fi
  \SubQuestion}
\newcommand\SubQuestion[2][]{\subsubsection{\protect\raggedright#2}%
  \def\reserved@a{#1}%
  \ifx\reserved@a\@empty\else\Qlabel{#1}\fi}
\newcommand\subQwarning{\PackageWarning{faq}{\string\subQ must be
    followed by \string\endhtmlignore,\MessageBreak
    and then by \string\Question}}
%
% tedious farting around to get \subsubsection looking almost like
% \subsection (I have my doubts about this, y'know ;-):
\renewcommand\subsubsection{\@startsection{subsubsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}
\renewcommand*\l@subsubsection{\@dottedtocline{2}{1.5em}{2.3em}}
% The discerning will detect my awful cheek, above, of sticking a
% subsubsection head onto a subsection body...
%
% \Qlabel and \Qref: define and refer to labels
\let\Qlabel\label
\newcommand\Qref[3][see question]{#1~\ref{#3}}
%
% from doc package, then hacked about by yours truly
\DeclareRobustCommand\csx[1]{\def\@tempa{#1}{\FAQverbFamily\char`\\%
    \expandafter\@faq@strip\meaning\@tempa\@faq@strip}}
\def\cs|#1|{\csx{#1}}
%
% for comments during maintenance
\def\Q#1{\footnote{{\ttfamily QUERY: #1}}}
%\def\Q#1{\marginpar{{\ttfamily QUERY: #1}}}
%
% Checking structure (null for now)
\newcommand\checked[2]{}
%
% for Alan's benefit
\newbox\@footnoteenvbox
\newenvironment{footnoteenv}
  {\begin{lrbox}\@footnoteenvbox\reset@font\footnotesize\ignorespaces}
  {\end{lrbox}%
   \footnote{\unhbox\@footnoteenvbox}}
%
% end of package
\endinput
