24.3 Packages to Load

  24.3.1 The noweb Package
  24.3.2 Colored Background—the framed Package
  24.3.3 The aldordoc Package
  24.3.4 The hyperref and rhxterm Packages
  24.3.5 The url Package
  24.3.6 The verbatim Package
  24.3.7 The makeidx Package
  24.3.8 Mathematics Related Commands
  24.3.9 The optional srcltx Package

Several LATEX packages that are used for the documentation of this project. We list here the packages together with some commands that are defined in terms of the commands from the package.

199packages 199  (192)
package noweb 200
page header/footer 218a
package framed 202
package aldordoc 204b
packages hyperref and rhxterm 207a
package url 209
package verbatim 210
package makeidx 212a
package amsmath 212b
package srcltx 215

24.3.1 The noweb Package

Since the project uses Noweb to generate its documentation, we must load the noweb package.

We want the Noweb code to appear in footnotesize, so we add an appropriate option in noweboptions.

200package noweb 200  (199)  201
\usepackage{noweb}
\noweboptions{footnotesizecode}

Defines:
noweb, used in chunks 95b and 234.

The command nwindexdefn is generated by NOWEAVEX for identifiers that appear in a chunk. One can define the identifiers of a chunk in the .nw file by writing

%def id1 id2 id3

at the end of a chunk after the closing @ sign and a blank.

We introduce rhxindexdefn here only to hold the original nwindexdefn. The defineterm command below does not print anything, see rhxterm.

If the current filename ends in .as.nw (ifAldorSource is true) then the definition is different than for other files.

201package noweb 200+   (199)  200
\let\rhxindexdefn\nwindexdefn
\def\nwindexdefn#1#2#3{%
  \ifAldorSource
  \else%
    \defineterm[]{#2}
  \fi
  \rhxindexdefn{#1}{#2}{#3}}

24.3.2 Colored Background—the framed Package

Although completely optional, we want to allow colored backgrounds for certain environments. The LATEX package framed provides support for colored backgrounds and is used if it can be found. If it cannot be found, the background color settings will be ignored.

Note that we require at least a version from 0.8a on. Version 0.5 does not work.

Note also that we wrap everything into a trivlist in order to get the spacing correct after the environment. We did not want an indentation of the line following immediately after the environment.

202package framed 202  (199)  204a
% We must define the following two commands for the case that framed.sty
% is not available in the right version.
\def\MakeFramed{\begingroup}
\def\endMakeFramed{\endgroup}%
\IfFileExists{framed.sty}{%
  \usepackage{framed}[2003/07/21 v 0.8a]%
}{%
  \PackageWarning{allprose}{framed.sty not found}%
}
\newenvironment{ColoredBackground}[1]%
  {\@ifundefined{background#1}%
     {\def\FrameCommand{}}%
     {\def\FrameCommand{\csname background#1\endcsname}}%
   \trivlist\item\MakeFramed{}}%
  {\endMakeFramed\endtrivlist}

Defines:
ColoredBackground, used in chunks 206, 210, 229, 230, 237, 271, and 331.

We provide here a command backgroundColor to set the background color. It is flexible enough after a redefinition in allprose.4ht.nw to set the background color for the html output, too.

The command takes as the first argument the name of an environment and as the second argument a color description. The color description can be given in a format that is accepted by the colorbox command from the LATEX color package.

For example, both of the following commands set the color red for the environment ToDo.

\backgroundColor{ToDo}{red}  
\backgroundColor{ToDo}[rgb]{1.0,0,0}

204apackage framed 202+   (199)  202
\def\backgroundColor#1#2#{\background@Color{#1}{#2}}
\def\background@Color#1#2#3{%
  \expandafter\gdef\csname background#1\endcsname{\@backgroundColor{#1}#2{#3}}}
\def\@backgroundColor#1{\colorbox}%

24.3.3 The aldordoc Package

We do not use the package aldoc (by Niklaus Mannhart) at the moment, because we see no real advantage. Instead we use another package aldordoc which is described in Section 25.1.

204bpackage aldordoc 204b  (199)  205a
\usepackage{aldordoc}

Note that for the rest of this section we assume that the page style allprose is active when the command rhead is used, see Section 24.4.

We like to put the name of the currently defined object into the right header of the compiled documentation. Therefore, we redefine the appropriate commands addefinetype and adinternaldefinename accordingly.

For addefinetype this is easy.

205apackage aldordoc 204b+   (199)  204b  205b
\let\ALLPROSEaddefinetype\addefinetype
\renewcommand{\addefinetype}[1]{%
  \rhead{\adcodefont{#1}}\ALLPROSEaddefinetype{#1}}

Uses rhead 216b.
For adinternaldefinename it does not work as above, so we introduce an auxiliary command ALLPROSEnewadinternaldefinename.
205bpackage aldordoc 204b+   (199)  205a  206
\let\ALLPROSEadinternaldefinename\adinternaldefinename
\newcommand{\ALLPROSEnewadinternaldefinename}[6][\adthistypename]{%
  \ALLPROSEadinternaldefinename[#1]{#2}{#3}{#4}{#5}{#6}%
  \rhead{\adcodefont{#6}}%
}
\let\adinternaldefinename\ALLPROSEnewadinternaldefinename

Uses rhead 216b.

All API (application programming interface) documentation comments that are meant to correspond to Aldor +++ descriptions should be written into the +++ environment

\begin{+++}  
...  
\end{+++}

At the moment this environment does nothing spectacular, but is necessary for the script tools/aldordoc2codechunk.pl.nw that takes this environment and embeds it as +++ descriptions to the <<exports: ...>> code chunk immediately following the +++ environment.

The background color of the +++ environment can be configured via the command backgroundColor{aldordoc}{...} at a local customization (see Section 24.12).

206package aldordoc 204b+   (199)  205b
\newenvironment{+++}%
  {\clearpage\begin{ColoredBackground}{aldordoc}}%
  {\end{ColoredBackground}}

Uses ColoredBackground 202.

24.3.4 The hyperref and rhxterm Packages

The documentation should become a hyperlinked document. The hyperref package supports links inside the whole document.

The package rhxterm takes advantage of hyperref and provides the commands defineterm and useterm. In fact, it is an extra package by Ralf Hemmecke (ralf@hemmecke.de).

We decided to take this package instead of the noweb way with double brackets in order to have more flexibility. In fact, the index indicates where defineterm is used.

For the special purpose of defining and using LATEX commands, we define definetexcommand and usetexcommand as special versions of defineterm and useterm. They should be used in the documentation like

\definetexcommand{SOMECOMMAND}  
\usetexcommand{SOMECOMMAND}

to refer to the LATEX command \SOMECOMMAND.

In order to refer to Makefile targets in the text, we provide the command usemaketarget. Targets should be defined via the %def mechanism of Noweb.

207apackages hyperref and rhxterm 207a  (199)  207b
\usepackage{hyperref}
\hypersetup{pdfborder={0 0 0},backref=true}
%\usepackage[hypertex]{hyperref} or \documentclass[hypertex]{article}
%--no color in \defineTermPage{} with hypertex option
\usepackage{rhxterm}[2005/10/12 v1.10]
{\makeatother
\gdef\usetexcommand#1{%
  \useterm[\textbackslash#1]{#1TEX@\protect\textbackslash#1}}
\gdef\definetexcommand#1{%
  \defineterm[\textbackslash#1]{#1TEX@\protect\textbackslash#1}}
}
\def\useMakeTargetStyle{\texttt}
\def\usemaketarget#1{{\def\useTermStyle{\useMakeTargetStyle}\useterm{#1}}}

Defines:
hyperref, used in chunk 247.
useMakeTargetStyle, used in chunk 390.

The hyperref package usually loads the standard packages keyval and url.

The command email is used to put a hyperlink to an email address.

207bpackages hyperref and rhxterm 207a+   (199)  207a  219
\def\email{\begingroup\catcode‘\_=12 \rhxemail}
\def\rhxemail#1{\href{mailto:#1}{\texttt{#1}}\endgroup}

24.3.5 The url Package

The url package provides some simple commands to enter verbatim like text. We use

url.sty  ver 1.4    02-Mar-1999   Donald Arseneau   asnd@triumf.ca

but version 1.5 should also work.

It defines (among others) the command path. The command directory builds on this package.

209package url 209  (199)
\usepackage{url}
\newcommand\directory{\begingroup \urlstyle{sf}\Url}

24.3.6 The verbatim Package

Code in the documentation that is not part of a chunk should be typeset by using the verbatim environment. One could change the fontsize by redefining the \verbatim@font command from the verbatim package, but we decided to redefine the whole verbatim environment in order to enable background colors.

The command verbatiminput is used to include the generated file src/Makefile.dep.

We highlight verbatim environments via the ColoredBackground environment, see Section 24.3.2.

The background color of the verbatim environment and the verbatiminput command can be configured via the commands backgroundColor{verbatim}{...} and backgroundColor{verbatiminput}{...} at a local customization (see Section 24.12).

210package verbatim 210  (199)
\usepackage{verbatim}
\let\allproseverbatiminput\verbatiminput
\let\allproseverbatim\verbatim
\let\allproseendverbatim\endverbatim
\renewenvironment{verbatim}%
{\ColoredBackground{verbatim}\footnotesize\allproseverbatim}%
{\allproseendverbatim\endColoredBackground}
\def\verbatiminput{\begingroup%
  \begin{ColoredBackground}{verbatiminput}\footnotesize\rhxverbatiminput}
\def\rhxverbatiminput#1{\allproseverbatiminput{#1}%
  \end{ColoredBackground}\endgroup}

Defines:
verbatim, used in chunks 295b and 390.

Uses ColoredBackground 202.

Some remark to the seemingly strange definition of verbatiminput. Our original definition was

\renewcommand{\verbatiminput}[1]{{%  
    \def\FrameCommand{\backgroundverbatiminput}\MakeFramed{}%  
    \footnotesize\allproseverbatiminput{#1}\endMakeFramed}}

but TEX4ht stopped with the following error message.

(/usr/share/texmf/tex/generic/tex4ht/verbatim.4ht  
! Argument of \verbatiminput has an extra }.  
<inserted text>  
                \par  
l.32    \:gobble}

After careful analysis, it became obvious that verbatim.4ht very much relied on the original definition of verbatiminput as defined in verbatim.sty which begins with begingroup. So we have to mimic that definition.

24.3.7 The makeidx Package

The makeidx package is mainly used in connection with the rhxterm package. The command makeindex is defined in the makeidx package.

212apackage makeidx 212a  (199)
\usepackage{makeidx}
\makeindex

Defines:
makeidx, never used.

24.3.8 Mathematics Related Commands

For mathematical environments and other nice features we load the amsmath and amssymb packages.

212bpackage amsmath 212b  (199)
\usepackage{amsmath}
\usepackage{amssymb}

Defines:
amsmath, never used.
amssymb, never used.

24.3.9 The optional srcltx Package

The program kdvi as well as newer versions of xdvi (see DVIVIEWER) are able to inverse search14 a dvi file, i. e., by clicking on some place in the .dvi file, the corresponding .tex file is opened in an editor of your choice. It is middle mouse click for kdvi and holding the control key and pressing the left mouse button for xdvi15 .

Inverse search is not possible by default. Certain versions of TEX support the generation of special commands that have to be put into the .dvi file. For example, teTeX 2.0 offers a -src switch.

Since, however, our source files do not have the extension .tex but rather .nw, we use the package srcltx. After having contacted Stefan Ulrich, the current maintainer of that package, it is now released as

\ProvidesPackage{srcltx}[2006/11/12 v1.6]

and contains a hook srcInputHook, which allows to control the name of the source file that is written into the .dvi file.

Since version 1.6 is probably not yet widely distributed, we still provide our old ad-hoc patch for versions 1.4 and 1.5.

Through the command SOURCEROOT, we even offer to specify a relative or absolute path to the source tree. This path is written into the .dvi file. See also Section 28.9.2.

Note that the command SOURCEROOT is defined only later in project.def.tex and so we must delay the test whether it is defined or not until we actually need it.

214srcltx patch 214  (215)
\def\rhx@SOURCEROOT{%
  \@ifundefined{SOURCEROOT}{}{\SOURCEROOT/}%relative or absolute path
}
\newcommand{\rhxSrcInputHook}[1]{\protected@xdef\CurrentInput{%
    \rhx@SOURCEROOT #1}}% hook for srcltx 1.6
\def\patched@src@@@input#1#2{% patch for srcltx 1.4 and 1.5
  \src@before@file@hook{\rhx@SOURCEROOT #2}%
    %--rhx: NO ’.tex’ extension in the line above.
  \src@input{#2}%
  \src@after@file@hook{#1}%
}

That the modification is so simple comes from our design of how to generate the .tex files and the fact that LATEX automatically appends the extension .tex for the argument to input. (Note that we never use include in ALLPROSE.)

Convention 11 For each .nw file, the corresponding .tex file will have just the extension .tex added, i. e., it will have the extension .nw.tex, see target texfiles.

The package srcltx is not really necessary (although strongly suggested), so we include it only, if it exists.

Note also that we cannot simply put the reference to the patch inside the IfFileExists command, since this leads to some strange LATEX error.

215package srcltx 215  (199)
srcltx patch 214
\IfFileExists{srcltx.sty}%
  {\usepackage{srcltx}[2004/05/15 v1.4]%
    \@ifundefined{srcInputHook}% only available from v1.6 on
      {\let\src@@@input\patched@src@@@input\PackageInfo{allprose}%
        {Patched \string\src@@@input\space of srcltx v1.4.}}%
      {\let\srcInputHook\rhxSrcInputHook\PackageInfo{allprose}%
        {Patched \string\srcInputHook\space of srcltx v1.6.}}%
  }{\PackageWarning{allprose}{Cannot find srcltx.sty.}}