Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346% generated by GAPDoc2LaTeX from XML source (Frank Luebeck)1\documentclass[a4paper,11pt]{report}23\usepackage{a4wide}4\sloppy5\pagestyle{myheadings}6\usepackage{amssymb}7\usepackage[latin1]{inputenc}8\usepackage{makeidx}9\makeindex10\usepackage{color}11\definecolor{FireBrick}{rgb}{0.5812,0.0074,0.0083}12\definecolor{RoyalBlue}{rgb}{0.0236,0.0894,0.6179}13\definecolor{RoyalGreen}{rgb}{0.0236,0.6179,0.0894}14\definecolor{RoyalRed}{rgb}{0.6179,0.0236,0.0894}15\definecolor{LightBlue}{rgb}{0.8544,0.9511,1.0000}16\definecolor{Black}{rgb}{0.0,0.0,0.0}1718\definecolor{linkColor}{rgb}{0.0,0.0,0.554}19\definecolor{citeColor}{rgb}{0.0,0.0,0.554}20\definecolor{fileColor}{rgb}{0.0,0.0,0.554}21\definecolor{urlColor}{rgb}{0.0,0.0,0.554}22\definecolor{promptColor}{rgb}{0.0,0.0,0.589}23\definecolor{brkpromptColor}{rgb}{0.589,0.0,0.0}24\definecolor{gapinputColor}{rgb}{0.589,0.0,0.0}25\definecolor{gapoutputColor}{rgb}{0.0,0.0,0.0}2627%% for a long time these were red and blue by default,28%% now black, but keep variables to overwrite29\definecolor{FuncColor}{rgb}{0.0,0.0,0.0}30%% strange name because of pdflatex bug:31\definecolor{Chapter }{rgb}{0.0,0.0,0.0}32\definecolor{DarkOlive}{rgb}{0.1047,0.2412,0.0064}333435\usepackage{fancyvrb}3637\usepackage{mathptmx,helvet}38\usepackage[T1]{fontenc}39\usepackage{textcomp}404142\usepackage[43pdftex=true,44bookmarks=true,45a4paper=true,46pdftitle={Written with GAPDoc},47pdfcreator={LaTeX with hyperref package / GAPDoc},48colorlinks=true,49backref=page,50breaklinks=true,51linkcolor=linkColor,52citecolor=citeColor,53filecolor=fileColor,54urlcolor=urlColor,55pdfpagemode={UseNone},56]{hyperref}5758\newcommand{\maintitlesize}{\fontsize{50}{55}\selectfont}5960% write page numbers to a .pnr log file for online help61\newwrite\pagenrlog62\immediate\openout\pagenrlog =\jobname.pnr63\immediate\write\pagenrlog{PAGENRS := [}64\newcommand{\logpage}[1]{\protect\write\pagenrlog{#1, \thepage,}}65%% were never documented, give conflicts with some additional packages6667\newcommand{\GAP}{\textsf{GAP}}6869%% nicer description environments, allows long labels70\usepackage{enumitem}71\setdescription{style=nextline}7273%% depth of toc74\setcounter{tocdepth}{1}757677787980%% command for ColorPrompt style examples81\newcommand{\gapprompt}[1]{\color{promptColor}{\bfseries #1}}82\newcommand{\gapbrkprompt}[1]{\color{brkpromptColor}{\bfseries #1}}83\newcommand{\gapinput}[1]{\color{gapinputColor}{#1}}848586\begin{document}8788\logpage{[ 0, 0, 0 ]}89\begin{titlepage}90\mbox{}\vfill9192\begin{center}{\maintitlesize \textbf{\textsf{GAPDoc}\mbox{}}}\\93\vfill9495\hypersetup{pdftitle=\textsf{GAPDoc}}96\markright{\scriptsize \mbox{}\hfill \textsf{GAPDoc} \hfill\mbox{}}97{\Huge ( Version 1.6.1 ) \mbox{}}\\[1cm]98{November 2017\mbox{}}\\[1cm]99\mbox{}\\[2cm]100{\Large \textbf{ Frank L{\"u}beck \mbox{}}}\\101{\Large \textbf{ Max Neunh{\"o}ffer \mbox{}}}\\102\hypersetup{pdfauthor= Frank L{\"u}beck ; Max Neunh{\"o}ffer }103\end{center}\vfill104105\mbox{}\\106{\mbox{}\\107\small \noindent \textbf{ Frank L{\"u}beck } Email: \href{mailto://Frank.Luebeck@Math.RWTH-Aachen.De} {\texttt{Frank.Luebeck@Math.RWTH-Aachen.De}}\\108Homepage: \href{http://www.math.rwth-aachen.de/~Frank.Luebeck} {\texttt{http://www.math.rwth-aachen.de/\texttt{\symbol{126}}Frank.Luebeck}}}\\109{\mbox{}\\110\small \noindent \textbf{ Max Neunh{\"o}ffer } Email: \href{mailto://neunhoef at mcs.st-and.ac.uk} {\texttt{neunhoef at mcs.st-and.ac.uk}}\\111Homepage: \href{http://www-groups.mcs.st-and.ac.uk/~neunhoef/} {\texttt{http://www-groups.mcs.st-and.ac.uk/\texttt{\symbol{126}}neunhoef/}}}\\112\end{titlepage}113114\newpage\setcounter{page}{2}115{\small116\section*{Copyright}117\logpage{[ 0, 0, 1 ]}118\index{License} {\copyright} 2000-2017 by Frank L{\"u}beck and Max Neunh{\"o}ffer119120\textsf{GAPDoc} is free software; you can redistribute it and/or modify it under the terms of121the \href{http://www.fsf.org/licenses/gpl.html} {GNU General Public License} as published by the Free Software Foundation; either version 2 of the License,122or (at your option) any later version. \mbox{}}\\[1cm]123\newpage124125\def\contentsname{Contents\logpage{[ 0, 0, 2 ]}}126127\tableofcontents128\newpage129130131\chapter{\textcolor{Chapter }{Introduction and Example}}\label{ch:intro}132\logpage{[ 1, 0, 0 ]}133\hyperdef{L}{X7D4EE663818DA109}{}134{135The main purpose of the \textsf{GAPDoc} package is to define a file format for documentation of \textsf{GAP}-programs and -packages (see \cite{GAP4}). The problem is that such documentation should be readable in several output136formats. For example it should be possible to read the documentation inside137the terminal in which \textsf{GAP} is running (a text mode) and there should be a printable version in high138typesetting quality (produced by some version of {\TeX}). It is also popular to view \textsf{GAP}'s online help with a Web-browser via an HTML-version of the documentation.139Nowadays one can use {\LaTeX} and standard viewer programs to produce and view on the screen \texttt{dvi}- or \texttt{pdf}-files with full support of internal and external hyperlinks. Certainly there140will be other interesting document formats and tools in this direction in the141future.142143Our aim is to find a \emph{format for writing} the documentation which allows a relatively easy translation into the output144formats just mentioned and which hopefully makes it easy to translate to145future output formats as well.146147To make documentation written in the \textsf{GAPDoc} format directly usable, we also provide a set of programs, called converters,148which produce text-, hyperlinked {\LaTeX}- and HTML-output versions of a \textsf{GAPDoc} document. These programs are developed by the first named author. They run149completely inside \textsf{GAP}, i.e., no external programs are needed. You only need \texttt{latex} and \texttt{pdflatex} to process the {\LaTeX} output. These programs are described in Chapter{\nobreakspace}\ref{ch:conv}.150\section{\textcolor{Chapter }{XML}}\label{sec:XML}151\logpage{[ 1, 1, 0 ]}152\hyperdef{L}{X8590236E858F7E93}{}153{154\index{XML} The definition of the \textsf{GAPDoc} format uses XML, the ``eXtendible Markup Language''. This is a standard (defined by the W3C consortium, see \href{http://www.w3c.org} {\texttt{http://www.w3c.org}}) which lays down a syntax for adding markup to a document or to some data. It155allows to define document structures via introducing markup \emph{elements} and certain relations between them. This is done in a \emph{document type definition}. The file \texttt{gapdoc.dtd} contains such a document type definition and is the central part of the \textsf{GAPDoc} package.156157The easiest way for getting a good idea about this is probably to look at an158example. The Appendix{\nobreakspace}\ref{app:3k+1} contains a short but complete \textsf{GAPDoc} document for a fictitious share package. In the next section we will go159through this document, explain basic facts about XML and the \textsf{GAPDoc} document type, and give pointers to more details in later parts of this160documentation.161162In the last Section{\nobreakspace}\ref{sec:faq} of this introductory chapter we try to answer some general questions about the163decisions which lead to the \textsf{GAPDoc} package. }164165166\section{\textcolor{Chapter }{A complete example}}\label{sec:3k+1expl}167\logpage{[ 1, 2, 0 ]}168\hyperdef{L}{X7B47AFA881BFC9DC}{}169{170In this section we recall the lines from the example document in171Appendix{\nobreakspace}\ref{app:3k+1} and give some explanations.172\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]173<?xml version="1.0" encoding="UTF-8"?>174\end{Verbatim}175This line just tells a human reader and computer programs that the file is a176document with XML markup and that the text is encoded in the UTF-8 character177set (other common encodings are ASCII or ISO-8895-X encodings).178\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]179<!-- A complete "fake package" documentation180-->181\end{Verbatim}182Everything in a XML file between ``\texttt{{\textless}!--}'' and ``\texttt{--{\textgreater}}'' is a comment and not part of the document content.183\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]184<!DOCTYPE Book SYSTEM "gapdoc.dtd">185\end{Verbatim}186This line says that the document contains markup which is defined in the187system file \texttt{gapdoc.dtd} and that the markup obeys certain rules defined in that file (the ending \texttt{dtd} means ``document type definition''). It further says that the actual content of the document consists of an188element with name ``Book''. And we can really see that the remaining part of the file is enclosed as189follows:190\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]191<Book Name="3k+1">192[...] (content omitted)193</Book>194\end{Verbatim}195This demonstrates the basics of the markup in XML. This part of the document196is an ``element''. It consists of the ``start tag'' \texttt{{\textless}Book Name="3k+1"{\textgreater}}, the ``element content'' and the ``end tag'' \texttt{{\textless}/Book{\textgreater}} (end tags always start with \texttt{{\textless}/}). This element also has an ``attribute'' \texttt{Name} whose ``value'' is \texttt{3k+1}.197198If you know HTML, this will look familiar to you. But there are some important199differences: The element name \texttt{Book} and attribute name \texttt{Name} are \emph{case sensitive}. The value of an attribute must \emph{always} be enclosed in quotes. In XML \emph{every} element has a start and end tag (which can be combined for elements defined as ``empty'', see for example \texttt{{\textless}TableOfContents/{\textgreater}} below).200201If you know {\LaTeX}, you are familiar with quite different types of markup, for example: The202equivalent of the \texttt{Book} element in {\LaTeX} is \texttt{\texttt{\symbol{92}}begin\texttt{\symbol{123}}document\texttt{\symbol{125}}203... \texttt{\symbol{92}}end\texttt{\symbol{123}}document\texttt{\symbol{125}}}. The sectioning in {\LaTeX} is not done by explicit start and end markup, but implicitly via heading204commands like \texttt{\texttt{\symbol{92}}section}. Other markup is done by using braces \texttt{\texttt{\symbol{123}}\texttt{\symbol{125}}} and putting some commands inside. And for mathematical formulae one can use205the \texttt{\$} for the start \emph{and} the end of the markup. In XML \emph{all} markup looks similar to that of the \texttt{Book} element.206207The content of the book starts with a title page.208\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]209<TitlePage>210<Title>The <Package>ThreeKPlusOne</Package> Package</Title>211<Version>Version 42</Version>212<Author>Dummy Auth�r213<Email>3kplusone@dev.null</Email>214</Author>215216<Copyright>©right; 2000 The Author. <P/>217You can do with this package what you want.<P/> Really.218</Copyright>219</TitlePage>220\end{Verbatim}221The content of the \texttt{TitlePage} element consists again of elements. In Chapter{\nobreakspace}\ref{DTD} we describe which elements are allowed within a \texttt{TitlePage} and that their ordering is prescribed in this case. In the (stupid) name of222the author you see that a German umlaut is used directly (in ISO-latin1223encoding).224225Contrary to {\LaTeX}- or HTML-files this markup does not say anything about the actual layout of226the title page in any output version of the document. It just adds information227about the \emph{meaning} of pieces of text.228229Within the \texttt{Copyright} element there are two more things to learn about XML markup. The \texttt{{\textless}P/{\textgreater}} is a complete element. It is a combined start and end tag. This shortcut is230allowed for elements which are defined to be always ``empty'', i.e., to have no content. You may have already guessed that \texttt{{\textless}P/{\textgreater}} is used as a paragraph separator. Note that empty lines do not separate231paragraphs (contrary to {\LaTeX}).232233The other construct we see here is \texttt{\©right;}. This is an example of an ``entity'' in XML and is a macro for some substitution text. Here we use an entity as a234shortcut for a complicated expression which makes it possible that the term \emph{copyright} is printed as some text like \texttt{(C)} in text terminal output and as a copyright character in other output formats.235In \textsf{GAPDoc} we predefine some entities. Certain ``special characters'' must be typed via entities, for example ``{\textless}'', ``{\textgreater}'' and ``\&'' to avoid a misinterpretation as XML markup. It is possible to define236additional entities for your document inside the \texttt{{\textless}!DOCTYPE ...{\textgreater}} declaration, see{\nobreakspace}\ref{GDent}.237238Note that elements in XML must always be properly nested, as in this example.239A construct like \texttt{{\textless}a{\textgreater}{\textless}b{\textgreater}...{\textless}/a{\textgreater}{\textless}/b{\textgreater}} is \emph{not} allowed.240\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]241<TableOfContents/>242\end{Verbatim}243This is another example of an ``empty element''. It just means that a table of contents for the whole document should be244included into any output version of the document.245246After this the main text of the document follows inside certain sectioning247elements:248\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]249<Body>250<Chapter> <Heading>The <M>3k+1</M> Problem</Heading>251<Section Label="sec:theory"> <Heading>Theory</Heading>252[...] (content omitted)253</Section>254<Section> <Heading>Program</Heading>255[...] (content omitted)256</Section>257</Chapter>258</Body>259\end{Verbatim}260These elements are used similarly to ``\texttt{\symbol{92}}chapter'' and ``\texttt{\symbol{92}}section'' in {\LaTeX}. But note that the explicit end tags are necessary here.261262The sectioning commands allow to assign an optional attribute ``Label''. This can be used for referring to a section inside the document.263264The text of the first section starts as follows. The whitespace in the text is265unimportant and the indenting is not necessary.266\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]267268Let <M>k \in &NN;</M> be a natural number. We consider the269sequence <M>n(i, k), i \in &NN;,</M> with <M>n(1, k) = k</M> and270else271\end{Verbatim}272Here we come to the interesting question how to type mathematical formulae in273a \textsf{GAPDoc} document. We did not find any alternative for writing formulae in {\TeX} syntax. (There is MATHML, but even simple formulae contain a lot of markup,274become quite unreadable and they are cumbersome to type. Furthermore there275seem to be no tools available which translate such formulae in a nice way into {\TeX} and text.) So, formulae are essentially typed as in {\LaTeX}. (Actually, it is also possible to type unicode characters of some276mathematical symbols directly, or via an entity like the \texttt{\&NN;} above.) There are three types of elements containing formulae: ``M'', ``Math'' and ``Display''. The first two are for in-text formulae and the third is for displayed277formulae. Here ``M'' and ``Math'' are equivalent, when translating a \textsf{GAPDoc} document into {\LaTeX}. But they are handled differently for terminal text (and HTML) output. For278the content of an ``M''-element there are defined rules for a translation into well readable terminal279text. More complicated formulae are in ``Math'' or ``Display'' elements and they are just printed as they are typed in text output. So, to280make a section well readable inside a terminal window you should try to put as281many formulae as possible into ``M''-elements. In our example text we used the notation \texttt{n(i, k)} instead of \texttt{n{\textunderscore}i(k)} because it is easier to read in text mode. See Sections{\nobreakspace}\ref{GDformulae} and{\nobreakspace}\ref{sec:misc} for more details.282283A few lines further on we find two non-internal references.284\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]285problem, see <Cite Key="Wi98"/> or286<URL>http://mathsrv.ku-eichstaett.de/MGF/homes/wirsching/</URL>287\end{Verbatim}288The first within the ``Cite''-element is the citation of a book. In \textsf{GAPDoc} we use the widely used Bib{\TeX} database format for reference lists. This does not use XML but has a well289documented structure which is easy to parse. And many people have collections290of references readily available in this format. The reference list in an291output version of the document is produced with the empty element292\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]293<Bibliography Databases="3k+1" />294\end{Verbatim}295close to the end of our example file. The attribute ``Databases'' give the name(s) of the database (\texttt{.bib}) files which contain the references.296297Putting a Web-address into an ``URL''-element allows one to create a hyperlink in output formats which allow this.298299The second section of our example contains a special kind of subsection300defined in \textsf{GAPDoc}.301\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]302<ManSection>303<Func Name="ThreeKPlusOneSequence" Arg="k[, max]"/>304<Description>305This function computes for a natural number <A>k</A> the306beginning of the sequence <M>n(i, k)</M> defined in section307<Ref Sect="sec:theory"/>. The sequence stops at the first308<M>1</M> or at <M>n(<A>max</A>, k)</M>, if <A>max</A> is309given.310<Example>311gap> ThreeKPlusOneSequence(101);312"Sorry, not yet implemented. Wait for Version 84 of the package"313</Example>314</Description>315</ManSection>316\end{Verbatim}317A ``ManSection'' contains the description of some function, operation, method, filter and so318on. The ``Func''-element describes the name of a \emph{function} (there are also similar elements ``Oper'', ``Meth'', ``Filt'' and so on) and names for its arguments, optional arguments enclosed in square319brackets. See Section{\nobreakspace}\ref{sec:mansect} for more details.320321In the ``Description'' we write the argument names as ``A''-elements. A good description of a function should usually contain an example322of its use. For this there are some verbatim-like elements in \textsf{GAPDoc}, like ``Example'' above (here, clearly, whitespace matters which causes a slightly strange323indenting).324325The text contains an internal reference to the first section via the326explicitly defined label \texttt{sec:theory}.327328The first section also contains a ``Ref''-element which refers to the function described here. Note that there is no329explicit label for such a reference. The pair \texttt{{\textless}Func Name="ThreeKPlusOneSequence" Arg="k[, max]"/{\textgreater}} and \texttt{{\textless}Ref Func="ThreeKPlusOneSequence"/{\textgreater}} does the cross referencing (and hyperlinking if possible) implicitly via the330name of the function.331332Here is one further element from our example document which we want to333explain.334\begin{Verbatim}[fontsize=\small,frame=single,label=from 3k+1.xml]335<TheIndex/>336\end{Verbatim}337This is again an empty element which just says that an output version of the338document should contain an index. Many entries for the index are generated339automatically because the ``Func'' and similar elements implicitly produce such entries. It is also possible to340include explicit additional entries in the index. }341342343\section{\textcolor{Chapter }{Some questions}}\label{sec:faq}344\logpage{[ 1, 3, 0 ]}345\hyperdef{L}{X79A97B867F45E5C7}{}346{347348\begin{description}349\item[{Are those XML files too ugly to read and edit?}] Just have a look and decide yourself. The markup needs more characters than350most {\TeX} or {\LaTeX} markup. But the structure of the document is easier to see. If you configure351your favorite editor well, you do not need more key strokes for typing the352markup than in {\LaTeX}.353\item[{Why do we not use {\LaTeX} alone?}] {\LaTeX} is good for writing books. But {\LaTeX} files are generally difficult to parse and to process to other output formats354like text for browsing in a terminal window or HTML (or new formats which may355become popular in the future). \textsf{GAPDoc} markup is one step more abstract than {\LaTeX} insofar as it describes meaning instead of appearance of text. The inner356workings of {\LaTeX} are too complicated to learn without pain, which makes it difficult to357overcome problems that occur occasionally.358\item[{Why XML and not a newly defined markup language?}] XML is a well defined standard that is more and more widely used. Lots of359people have thought about it. Years of experience with SGML went into the360design. It is easy to explain, easy to parse and lots of tools are available,361there will be more in the future.362\end{description}363}364365}366367368\chapter{\textcolor{Chapter }{How To Type a \textsf{GAPDoc} Document}}\label{HowEnter}369\logpage{[ 2, 0, 0 ]}370\hyperdef{L}{X7890CF967F3E2FED}{}371{372In this chapter we give a more formal description of what you need to start to373type documentation in \textsf{GAPDoc} XML format. Many details were already explained by example in374Section{\nobreakspace}\ref{sec:3k+1expl} of the introduction.375376We do \emph{not} answer the question ``How to \emph{write} a \textsf{GAPDoc} document?'' in this chapter. You can (hopefully) find an answer to this question by377studying the example in the introduction, see{\nobreakspace}\ref{sec:3k+1expl}, and learning about more details in the reference Chapter{\nobreakspace}\ref{DTD}.378379The definite source for all details of the official XML standard with useful380annotations is:381382\href{http://www.xml.com/axml/axml.html} {\texttt{http://www.xml.com/axml/axml.html}}383384Although this document must be quite technical, it is surprisingly well385readable.386387388\section{\textcolor{Chapter }{General XML Syntax}}\label{EnterXML}389\logpage{[ 2, 1, 0 ]}390\hyperdef{L}{X7B3A544986A1A9EA}{}391{392We will now discuss the pieces of text which can occur in a general XML393document. We start with those pieces which do not contribute to the actual394content of the document.395\subsection{\textcolor{Chapter }{Head of XML Document}}\label{XMLhead}396\logpage{[ 2, 1, 1 ]}397\hyperdef{L}{X84E8D39687638CF0}{}398{399Each XML document should have a head which states that it is an XML document400in some encoding and which XML-defined language is used. In case of a \textsf{GAPDoc} document this should always look as in the following example.401\begin{Verbatim}[commandchars=@|A,fontsize=\small,frame=single,label=Example]402<?xml version="1.0" encoding="UTF-8"?>403<!DOCTYPE Book SYSTEM "gapdoc.dtd">404\end{Verbatim}405See{\nobreakspace}\ref{XMLenc} for a remark on the ``encoding'' statement.406407(There may be local entity definitions inside the \texttt{DOCTYPE} statement, see Subsection{\nobreakspace}\ref{GDent} below.) }408409410\subsection{\textcolor{Chapter }{Comments}}\label{XMLcomment}411\logpage{[ 2, 1, 2 ]}412\hyperdef{L}{X780C79EB85C32138}{}413{414A ``comment'' in XML starts with the character sequence ``\texttt{{\textless}!--}'' and ends with the sequence ``\texttt{--{\textgreater}}''. Between these sequences there must not be two adjacent dashes ``\texttt{--}''. }415416417\subsection{\textcolor{Chapter }{Processing Instructions}}\label{XMLprocinstr}418\logpage{[ 2, 1, 3 ]}419\hyperdef{L}{X82DBCCAD8358BB63}{}420{421A ``processing instruction'' in XML starts with the character sequence ``\texttt{{\textless}?}'' followed by a name (``\texttt{xml}'' is only allowed at the very beginning of the document to declare it being an422XML document, see \ref{XMLhead}). After that any characters may follow, except that the ending sequence ``\texttt{?{\textgreater}}'' must not occur within the processing instruction. }423424{\nobreakspace}425426And now we turn to those parts of the document which contribute to its actual427content.428\subsection{\textcolor{Chapter }{Names in XML and Whitespace}}\label{XMLnames}429\logpage{[ 2, 1, 4 ]}430\hyperdef{L}{X7A0FB16C7FEC0B53}{}431{432A ``name'' in XML (used for element and attribute identifiers, see below) must start with433a letter (in the encoding of the document) or with a colon ``\texttt{:}'' or underscore ``\texttt{{\textunderscore}}'' character. The following characters may also be digits, dots ``\texttt{.}'' or dashes ``\texttt{-}''.434435This is a simplified description of the rules in the standard, which are436concerned with lots of unicode ranges to specify what a ``letter'' is.437438Sequences only consisting of the following characters are considered as \emph{whitespace}: blanks, tabs, carriage return characters and new line characters. }439440441\subsection{\textcolor{Chapter }{Elements}}\label{XMLel}442\logpage{[ 2, 1, 5 ]}443\hyperdef{L}{X79B130FC7906FB4C}{}444{445The actual content of an XML document consists of ``elements''. An element has some ``content'' with a leading ``start tag'' (\ref{XMLstarttag}) and a trailing ``end tag'' (\ref{XMLendtag}). The content can contain further elements but they must be properly nested.446One can define elements whose content is always empty, those elements can also447be entered with a single combined tag (\ref{XMLcombtag}). }448449450\subsection{\textcolor{Chapter }{Start Tags}}\label{XMLstarttag}451\logpage{[ 2, 1, 6 ]}452\hyperdef{L}{X7DD1DCB783588BD5}{}453{454A ``start-tag'' consists of a less-than-character ``\texttt{{\textless}}'' directly followed (without whitespace) by an element name (see{\nobreakspace}\ref{XMLnames}), optional attributes, optional whitespace, and a greater-than-character ``\texttt{{\textgreater}}''.455456An ``attribute'' consists of some whitespace and then its name followed by an equal sign ``\texttt{=}'' which is optionally enclosed by whitespace, and the attribute value, which is457enclosed either in single or double quotes. The attribute value may not458contain the type of quote used as a delimiter or the character ``\texttt{{\textless}}'', the character ``\texttt{\&}'' may only appear to start an entity, see{\nobreakspace}\ref{XMLent}. We describe in{\nobreakspace}\ref{AttrValRules} how to enter special characters in attribute values.459460Note especially that no whitespace is allowed between the starting ``\texttt{{\textless}}'' character and the element name. The quotes around an attribute value cannot be461omitted. The names of elements and attributes are \emph{case sensitive}. }462463464\subsection{\textcolor{Chapter }{End Tags}}\label{XMLendtag}465\logpage{[ 2, 1, 7 ]}466\hyperdef{L}{X7E5A567E83005B62}{}467{468An ``end tag'' consists of the two characters ``\texttt{{\textless}/}'' directly followed by the element name, optional whitespace and a469greater-than-character ``\texttt{{\textgreater}}''. }470471472\subsection{\textcolor{Chapter }{Combined Tags for Empty Elements}}\label{XMLcombtag}473\logpage{[ 2, 1, 8 ]}474\hyperdef{L}{X843A02A88514D919}{}475{476Elements which always have empty content can be written with a single tag.477This looks like a start tag (see{\nobreakspace}\ref{XMLstarttag}) \emph{except} that the trailing greater-than-character ``\texttt{{\textgreater}}'' is substituted by the two character sequence ``\texttt{/{\textgreater}}''. }478479480\subsection{\textcolor{Chapter }{Entities}}\label{XMLent}481\logpage{[ 2, 1, 9 ]}482\hyperdef{L}{X78FB56C77B1F391A}{}483{484An ``entity'' in XML is a macro for some substitution text. There are two types of entities.485486A ``character entity'' can be used to specify characters in the encoding of the document (can be487useful for entering non-ASCII characters which you cannot manage to type in488directly). They are entered with a sequence ``\texttt{\&\#}'', directly followed by either some decimal digits or an ``\texttt{x}'' and some hexadecimal digits, directly followed by a semicolon ``\texttt{;}''. Using such a character entity is just equivalent to typing the corresponding489character directly.490491Then there are references to ``named entities''. They are entered with an ampersand character ``\texttt{\&}'' directly followed by a name which is directly followed by a semicolon ``\texttt{;}''. Such entities must be declared somewhere by giving a substitution text. This492text is included in the document and the document is parsed again afterwards.493The exact rules are a bit subtle but you probably want to use this only in494simple cases. Predefined entities for \textsf{GAPDoc} are described in \ref{XMLspchar} and \ref{GDent}.495496}497498499\subsection{\textcolor{Chapter }{Special Characters in XML}}\label{XMLspchar}500\logpage{[ 2, 1, 10 ]}501\hyperdef{L}{X84A95A19801EDE76}{}502{503We have seen that the less-than-character ``\texttt{{\textless}}'' and the ampersand character ``\texttt{\&}'' start a tag or entity reference in XML. To get these characters into the504document text one has to use entity references, namely ``\texttt{\<}'' to get ``\texttt{{\textless}}'' and ``\texttt{\&}'' to get ``\texttt{\&}''. Furthermore ``\texttt{\>}'' must be used to get ``\texttt{{\textgreater}}'' when the string ``\texttt{]]{\textgreater}}'' appears in element content (and not as delimiter of a \texttt{CDATA} section explained below).505506Another possibility is to use a \texttt{CDATA} statement explained in{\nobreakspace}\ref{XMLcdata}. }507508509\subsection{\textcolor{Chapter }{Rules for Attribute Values}}\label{AttrValRules}510\logpage{[ 2, 1, 11 ]}511\hyperdef{L}{X7F49E7AD785AED22}{}512{513Attribute values can contain entities which are substituted recursively. But514except for the entities \< or a character entity it is not allowed that a515{\textless} character is introduced by the substitution (there is no XML516parsing for evaluating the attribute value, just entity substitutions). }517518519\subsection{\textcolor{Chapter }{\texttt{CDATA}}}\label{XMLcdata}520\logpage{[ 2, 1, 12 ]}521\hyperdef{L}{X82E77E707A062908}{}522{523Pieces of text which contain many characters which can be misinterpreted as524markup can be enclosed by the character sequences ``\texttt{{\textless}![CDATA[}'' and ``\texttt{]]{\textgreater}}''. Everything between these sequences is considered as content of the document525and is not further interpreted as XML text. All the rules explained so far in526this section do \emph{not apply} to such a part of the document. The only document content which cannot be527entered directly inside a \texttt{CDATA} statement is the sequence ``\texttt{]]{\textgreater}}''. This can be entered as ``\texttt{]]\>}'' outside the \texttt{CDATA} statement.528\begin{Verbatim}[fontsize=\small,frame=single,label=Example]529A nesting of tags like <a> <b> </a> </b> is not allowed.530\end{Verbatim}531}532533534\subsection{\textcolor{Chapter }{Encoding of an XML Document}}\label{XMLenc}535\logpage{[ 2, 1, 13 ]}536\hyperdef{L}{X8709BD337DA09ED5}{}537{538We suggest to use the UTF-8 encoding for writing \textsf{GAPDoc} XML documents. But the tools described in Chapter \ref{ch:conv} also work with ASCII or the various ISO-8859-X encodings (ISO-8859-1 is also539called latin1 and covers most special characters for western European540languages). }541542543\subsection{\textcolor{Chapter }{Well Formed and Valid XML Documents}}\label{XMLvalid}544\logpage{[ 2, 1, 14 ]}545\hyperdef{L}{X8561F07A81CABDD6}{}546{547We want to mention two further important words which are often used in the548context of XML documents. A piece of text becomes a ``well formed'' XML document if all the formal rules described in this section are fulfilled.549550But this says nothing about the content of the document. To give this content551a meaning one needs a declaration of the element and corresponding attribute552names as well as of named entities which are allowed. Furthermore there may be553restrictions how such elements can be nested. This \emph{definition of an XML based markup language} is done in a ``document type definition''. An XML document which contains only elements and entities declared in such a554document type definition and obeys the rules given there is called ``valid (with respect to this document type definition)''.555556The main file of the \textsf{GAPDoc} package is \texttt{gapdoc.dtd}. This contains such a definition of a markup language. We are not going to557explain the formal syntax rules for document type definitions in this section.558But in Chapter{\nobreakspace}\ref{DTD} we will explain enough about it to understand the file \texttt{gapdoc.dtd} and so the markup language defined there. }559560}561562563\section{\textcolor{Chapter }{Entering \textsf{GAPDoc} Documents}}\label{EnterGD}564\logpage{[ 2, 2, 0 ]}565\hyperdef{L}{X7BDE59B17CF1D5D2}{}566{567Here are some additional rules for writing \textsf{GAPDoc} XML documents.568\subsection{\textcolor{Chapter }{Other special characters}}\label{otherspecchar}569\logpage{[ 2, 2, 1 ]}570\hyperdef{L}{X79171E047B069F94}{}571{572As \textsf{GAPDoc} documents are used to produce {\LaTeX} and HTML documents, the question arises how to deal with characters with a573special meaning for other applications (for example ``\texttt{\&}'', ``\texttt{\#}'', ``\texttt{\$}'', ``\texttt{\%}'', ``\texttt{\texttt{\symbol{126}}}'', ``\texttt{\texttt{\symbol{92}}}'', ``\texttt{\texttt{\symbol{123}}}'', ``\texttt{\texttt{\symbol{125}}}'', ``\texttt{{\textunderscore}}'', ``\texttt{\texttt{\symbol{94}}}'', ``\texttt{{\nobreakspace}}'' (this is a non-breakable space, ``\texttt{\texttt{\symbol{126}}}'' in {\LaTeX}) have a special meaning for {\LaTeX} and ``\texttt{\&}'', ``\texttt{{\textless}}'', ``\texttt{{\textgreater}}'' have a special meaning for HTML (and XML). In \textsf{GAPDoc} you can usually just type these characters directly, it is the task of the574converter programs which translate to some output format to take care of such575special characters. The exceptions to this simple rule are:576\begin{itemize}577\item \& and {\textless} must be entered as \texttt{\&} and \texttt{\<} as explained in \ref{XMLspchar}.578\item The content of the \textsf{GAPDoc} elements \texttt{{\textless}M{\textgreater}}, \texttt{{\textless}Math{\textgreater}} and \texttt{{\textless}Display{\textgreater}} is {\LaTeX} code, see \ref{MathForm}.579\item The content of an \texttt{{\textless}Alt{\textgreater}} element with \texttt{Only} attribute contains code for the specified output type, see \ref{Alt}.580\end{itemize}581Remark: In former versions of \textsf{GAPDoc} one had to use particular entities for all the special characters mentioned582above (\texttt{\&tamp;}, \texttt{\&hash;}, \texttt{\$}, \texttt{\&percent;}, \texttt{\˜}, \texttt{\&bslash;}, \texttt{\&obrace;}, \texttt{\&cbrace;}, \texttt{\&uscore;}, \texttt{\&circum;}, \texttt{\&tlt;}, \texttt{\&tgt;}). These are no longer needed, but they are still defined for backwards583compatibility with older \textsf{GAPDoc} documents. }584585586\subsection{\textcolor{Chapter }{Mathematical Formulae}}\label{GDformulae}587\logpage{[ 2, 2, 2 ]}588\hyperdef{L}{X7EAE0C5A835F126F}{}589{590Mathematical formulae in \textsf{GAPDoc} are typed as in {\LaTeX}. They must be the content of one of three types of \textsf{GAPDoc} elements concerned with mathematical formulae: ``\texttt{Math}'', ``\texttt{Display}'', and ``\texttt{M}'' (see Sections{\nobreakspace}\ref{Math} and{\nobreakspace}\ref{M} for more details). The first two correspond to {\LaTeX}'s math mode and display math mode. The last one is a special form of the ``\texttt{Math}'' element type, that imposes certain restrictions on the content. On the other591hand the content of an ``\texttt{M}'' element is processed in a well defined way for text terminal or HTML output.592The ``\texttt{Display}'' element also has an attribute such that its content is processed as in ``\texttt{M}'' elements.593594Note that the content of these element is {\LaTeX} code, but the special characters ``\texttt{{\textless}}'' and ``\texttt{\&}'' for XML must be entered via the entities described in{\nobreakspace}\ref{XMLspchar} or by using a \texttt{CDATA} statement, see{\nobreakspace}\ref{XMLcdata}.595596}597598599\subsection{\textcolor{Chapter }{More Entities}}\label{GDent}600\logpage{[ 2, 2, 3 ]}601\hyperdef{L}{X7BDFF6D37FBED400}{}602{603In \textsf{GAPDoc} there are some more predefined entities: \begin{center}604\begin{tabular}{|l|l|}\hline605\texttt{\&GAP;}&606\textsf{GAP}\\607\hline608\texttt{\&GAPDoc;}&609\textsf{GAPDoc}\\610\hline611\texttt{\&TeX;}&612{\TeX}\\613\hline614\texttt{\&LaTeX;}&615{\LaTeX}\\616\hline617\texttt{\&BibTeX;}&618Bib{\TeX}\\619\hline620\texttt{\&MeatAxe;}&621\textsf{MeatAxe}\\622\hline623\texttt{\&XGAP;}&624\textsf{XGAP}\\625\hline626\texttt{\©right;}&627{\copyright}\\628\hline629\texttt{\ }&630``{\nobreakspace}''\\631\hline632\texttt{\–}&633{\textendash}\\634\hline635\end{tabular}\\[2mm]636\textbf{Table: }Predefined Entities in the \textsf{GAPDoc} system\end{center}637638Here \texttt{\ } is a non-breakable space character.639640Additional entities are defined for some mathematical symbols, see \ref{MathForm} for more details.641642One can define further local entities right inside the head643(see{\nobreakspace}\ref{XMLhead}) of a \textsf{GAPDoc} XML document as in the following example.644\begin{Verbatim}[fontsize=\small,frame=single,label=Example]645<?xml version="1.0" encoding="UTF-8"?>646647<!DOCTYPE Book SYSTEM "gapdoc.dtd"648[ <!ENTITY MyEntity "some longish <E>text</E> possibly with markup">649]>650\end{Verbatim}651These additional definitions go into the \texttt{{\textless}!DOCTYPE} tag in square brackets. Such new entities are used like this: \texttt{\&MyEntity;}652653}654655}656657}658659660\chapter{\textcolor{Chapter }{The Document Type Definition}}\label{DTD}661\logpage{[ 3, 0, 0 ]}662\hyperdef{L}{X7859CFF180D52D49}{}663{664In this chapter we first explain what a ``document type definition'' is and then describe \texttt{gapdoc.dtd} in detail. That file together with the current chapter define how a \textsf{GAPDoc} document has to look like. It can be found in the main directory of the \textsf{GAPDoc} package and it is reproduced in Appendix{\nobreakspace}\ref{GAPDocdtd}.665666We do not give many examples in this chapter which is more intended as a667formal reference for all \textsf{GAPDoc} elements. Instead, we provide a separate help book, see{\nobreakspace} ??? . This uses all the constructs introduced in this chapter and you can easily668compare the source code and how it looks like in the different output formats.669Furthermore recall that many basic things about XML markup were already670explained by example in the introductory chapter{\nobreakspace}\ref{ch:intro}.671\section{\textcolor{Chapter }{What is a DTD?}}\logpage{[ 3, 1, 0 ]}672\hyperdef{L}{X7B76F6F786521F6B}{}673{674A document type definition (DTD) is a formal declaration of how an XML675document has to be structured. It is itself structured such that programs that676handle documents can read it and treat the documents accordingly. There are677for example parsers and validity checkers that use the DTD to validate an XML678document, see{\nobreakspace}\ref{XMLvalid}.679680The main thing a DTD does is to specify which elements may occur in documents681of a certain document type, how they can be nested, and what attributes they682can or must have. So, for each element there is a rule.683684Note that a DTD can \emph{not} ensure that a document which is ``valid'' also makes sense to the converters! It only says something about the formal685structure of the document.686687For the remaining part of this chapter we have divided the elements of \textsf{GAPDoc} documents into several subsets, each of which will be discussed in one of the688next sections.689690See the following three subsections to learn by example, how a DTD works. We691do not want to be too formal here, but just enable the reader to understand692the declarations in \texttt{gapdoc.dtd}. For precise descriptions of the syntax of DTD's see again the official693standard in:694695{\nobreakspace}{\nobreakspace}\href{http://www.xml.com/axml/axml.html} {\texttt{http://www.xml.com/axml/axml.html}}696697}698699700\section{\textcolor{Chapter }{Overall Document Structure}}\logpage{[ 3, 2, 0 ]}701\hyperdef{L}{X7DB0F9E57879CC76}{}702{703A \textsf{GAPDoc} document contains on its top level exactly one element with name \texttt{Book}. This element is declared in the DTD as follows:704\subsection{\textcolor{Chapter }{\texttt{{\textless}Book{\textgreater}}}}\logpage{[ 3, 2, 1 ]}705\hyperdef{L}{X7C7258A57B831934}{}706{707\index{Book@\texttt{Book}}708\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]709<!ELEMENT Book (TitlePage,710TableOfContents?,711Body,712Appendix*,713Bibliography?,714TheIndex?)>715<!ATTLIST Book Name CDATA #REQUIRED>716\end{Verbatim}717After the keyword \texttt{ELEMENT} and the name \texttt{Book} there is a list in parentheses. This is a comma separated list of names of718elements which can occur (in the given order) in the content of a \texttt{Book} element. Each name in such a list can be followed by one of the characters ``\texttt{?}'', ``\texttt{*}'' or ``\texttt{+}'', meaning that the corresponding element can occur zero or one time, an719arbitrary number of times, or at least once, respectively. Without such an720extra character the corresponding element must occur exactly once. Instead of721one name in this list there can also be a list of elements names separated by ``\texttt{|}'' characters, this denotes any element with one of the names (i.e., ``\texttt{|}'' means ``or'').722723So, the \texttt{Book} element must contain first a \texttt{TitlePage} element, then an optional \texttt{TableOfContents} element, then a \texttt{Body} element, then zero or more elements of type \texttt{Appendix}, then an optional \texttt{Bibliography} element, and finally an optional element of type \texttt{TheIndex}.724725Note that \emph{only} these elements are allowed in the content of the \texttt{Book} element. No other elements or text is allowed in between. An exception of this726is that there may be whitespace between the end tag of one and the start tag727of the next element - this should be ignored when the document is processed to728some output format. An element like this is called an element with ``element content''.729730The second declaration starts with the keyword \texttt{ATTLIST} and the element name \texttt{Book}. After that there is a triple of whitespace separated parameters (in general731an arbitrary number of such triples, one for each allowed attribute name). The732first (\texttt{Name}) is the name of an attribute for a \texttt{Book} element. The second (\texttt{CDATA}) is always the same for all of our declarations, it means that the value of733the attribute consists of ``character data''. The third parameter \texttt{\#REQUIRED} means that this attribute must be specified with any \texttt{Book} element. Later we will also see optional attributes which are declared as \texttt{\#IMPLIED}. }734735736\subsection{\textcolor{Chapter }{\texttt{{\textless}TitlePage{\textgreater}}}}\logpage{[ 3, 2, 2 ]}737\hyperdef{L}{X842B421A7FBCDD2C}{}738{739\index{TitlePage@\texttt{TitlePage}}740\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]741<!ELEMENT TitlePage (Title, Subtitle?, Version?, TitleComment?,742Author+, Date?, Address?, Abstract?, Copyright?,743Acknowledgements? , Colophon? )>744\end{Verbatim}745Within this element information for the title page is collected. Note that746more than one author can be specified. The elements must appear in this order747because there is no sensible way to specify in a DTD something like ``the following elements may occur in any order but each exactly once''.748749Before going on with the other elements inside the \texttt{Book} element we explain the elements for the title page. }750751752\subsection{\textcolor{Chapter }{\texttt{{\textless}Title{\textgreater}}}}\label{Title}753\logpage{[ 3, 2, 3 ]}754\hyperdef{L}{X7BCC8E6F79021294}{}755{756\index{Title@\texttt{Title}} \label{Text}757\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]758<!ELEMENT Title (%Text;)*>759\end{Verbatim}760Here is the last construct you need to understand for reading \texttt{gapdoc.dtd}. The expression ``\texttt{\%Text;}'' is a so-called ``parameter entity''. It is something like a macro within the DTD. It is defined as follows: \label{InnerText}761\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]762<!ENTITY % Text "%InnerText; | List | Enum | Table">763\end{Verbatim}764This means, that every occurrence of ``\texttt{\%Text;}'' in the DTD is replaced by the expression \label{Innertext}765\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]766%InnerText; | List | Enum | Table767\end{Verbatim}768which is then expanded further because of the following definition:769\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]770<!ENTITY % InnerText "#PCDATA |771Alt |772Emph | E |773Par | P | Br |774Keyword | K | Arg | A | Quoted | Q | Code | C |775File | F | Button | B | Package |776M | Math | Display |777Example | Listing | Log | Verb |778URL | Email | Homepage | Address | Cite | Label |779Ref | Index" >780\end{Verbatim}781These are the only two parameter entities we are using. They expand to lists782of element names which are explained in the sequel \emph{and} the keyword \texttt{\#PCDATA} (concatenated with the ``or'' character ``\texttt{|}'').783784So, the element (\texttt{Title}) is of so-called ``mixed content'': It can contain \emph{parsed character data} which does not contain further markup (\texttt{\#PCDATA}) or any of the other above mentioned elements. Mixed content must always have785the asterisk qualifier (like in \texttt{Title}) such that any sequence of elements (of the above list) and character data786can be contained in a \texttt{Title} element.787788The \texttt{\%Text;} parameter entity is used in all places in the DTD, where ``normal text'' should be allowed, including lists, enumerations, and tables, but \emph{no} sectioning elements.789790The \texttt{\%InnerText;} parameter entity is used in all places in the DTD, where ``inner text'' should be allowed. This means, that no structures like lists, enumerations,791and tables are allowed. This is used for example in headings.792793}794795796\subsection{\textcolor{Chapter }{\texttt{{\textless}Subtitle{\textgreater}}}}\logpage{[ 3, 2, 4 ]}797\hyperdef{L}{X82E82AF48217CC14}{}798{799\index{Subtitle@\texttt{Subtitle}}800\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]801<!ELEMENT Subtitle (%Text;)*>802\end{Verbatim}803Contains the subtitle of the document. }804805806\subsection{\textcolor{Chapter }{\texttt{{\textless}Version{\textgreater}}}}\label{Version}807\logpage{[ 3, 2, 5 ]}808\hyperdef{L}{X876962807DCC52B3}{}809{810\index{Version@\texttt{Version}}811\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]812<!ELEMENT Version (#PCDATA|Alt)*>813\end{Verbatim}814Note that the version can only contain character data and no further markup815elements (except for \texttt{Alt}, which is necessary to resolve the entities described in \ref{GDent}). The converters will \emph{not} put the word ``Version'' in front of the text in this element. }816817818\subsection{\textcolor{Chapter }{\texttt{{\textless}TitleComment{\textgreater}}}}\logpage{[ 3, 2, 6 ]}819\hyperdef{L}{X87E7CD5B79230B90}{}820{821\index{TitleComment@\texttt{TitleComment}}822\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]823<!ELEMENT TitleComment (%Text;)*>824\end{Verbatim}825Sometimes a title and subtitle are not sufficient to give a rough idea about826the content of a package. In this case use this optional element to specify an827additional text for the front page of the book. This text should be short, use828the \texttt{Abstract} element (see{\nobreakspace}\ref{elAbstract}) for longer explanations. }829830831\subsection{\textcolor{Chapter }{\texttt{{\textless}Author{\textgreater}}}}\logpage{[ 3, 2, 7 ]}832\hyperdef{L}{X8731459C7E4C56DA}{}833{834\index{Author@\texttt{Author}}835\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]836<!ELEMENT Author (%Text;)*> <!-- There may be more than one Author! -->837\end{Verbatim}838As noted in the comment there may be more than one element of this type. This839element should contain the name of an author and probably an \texttt{Email}-address and/or WWW-\texttt{Homepage} element for this author, see{\nobreakspace}\ref{elEmail} and{\nobreakspace}\ref{elHomepage}. You can also specify an individual postal address here, instead of using the \texttt{Address} element described below, see{\nobreakspace}\ref{elAddress}. }840841842\subsection{\textcolor{Chapter }{\texttt{{\textless}Date{\textgreater}}}}\logpage{[ 3, 2, 8 ]}843\hyperdef{L}{X8264A69D7DCDD773}{}844{845\index{Date@\texttt{Date}}846\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]847<!ELEMENT Date (#PCDATA)>848\end{Verbatim}849Only character data is allowed in this element which gives a date for the850document. No automatic formatting is done. }851852853\subsection{\textcolor{Chapter }{\texttt{{\textless}Address{\textgreater}}}}\label{elAddress}854\logpage{[ 3, 2, 9 ]}855\hyperdef{L}{X7EEF65A07A094F65}{}856{857\index{Date@\texttt{Address}}858\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]859<!ELEMENT Address (#PCDATA|Alt|Br)*>860\end{Verbatim}861This optional element can be used to specify a postal address of the author or862the authors. If there are several authors with different addresses then put863the \texttt{Address} elements inside the \texttt{Author} elements.864865Use the \texttt{Br} element (see{\nobreakspace}\ref{Br}) to mark the line breaks in the usual formatting of the address on a letter.866867Note that often it is not necessary to use this element because a postal868address is easy to find via a link to a personal web page. }869870871\subsection{\textcolor{Chapter }{\texttt{{\textless}Abstract{\textgreater}}}}\label{elAbstract}872\logpage{[ 3, 2, 10 ]}873\hyperdef{L}{X833110FE79628313}{}874{875\index{Abstract@\texttt{Abstract}}876\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]877<!ELEMENT Abstract (%Text;)*>878\end{Verbatim}879This element contains an abstract of the whole book. }880881882\subsection{\textcolor{Chapter }{\texttt{{\textless}Copyright{\textgreater}}}}\logpage{[ 3, 2, 11 ]}883\hyperdef{L}{X84BBD8307E08E62F}{}884{885\index{Copyright@\texttt{Copyright}}886\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]887<!ELEMENT Copyright (%Text;)*>888\end{Verbatim}889This element is used for the copyright notice. Note the \texttt{\©right;} entity as described in section \ref{GDent}. }890891892\subsection{\textcolor{Chapter }{\texttt{{\textless}Acknowledgements{\textgreater}}}}\logpage{[ 3, 2, 12 ]}893\hyperdef{L}{X8143972D7C17838E}{}894{895\index{Acknowledgements@\texttt{Acknowledgements}}896\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]897<!ELEMENT Acknowledgements (%Text;)*>898\end{Verbatim}899This element contains the acknowledgements. }900901902\subsection{\textcolor{Chapter }{\texttt{{\textless}Colophon{\textgreater}}}}\logpage{[ 3, 2, 13 ]}903\hyperdef{L}{X7C09A3398059D18C}{}904{905\index{Colophon@\texttt{Colophon}}906\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]907<!ELEMENT Colophon (%Text;)*>908\end{Verbatim}909The ``colophon'' page is used to say something about the history of a document. }910911912\subsection{\textcolor{Chapter }{\texttt{{\textless}TableOfContents{\textgreater}}}}\logpage{[ 3, 2, 14 ]}913\hyperdef{L}{X7E97263A83DC26E9}{}914{915\index{TableOfContents@\texttt{TableOfContents}}916\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]917<!ELEMENT TableOfContents EMPTY>918\end{Verbatim}919This element may occur in the \texttt{Book} element after the \texttt{TitlePage} element. If it is present, a table of contents is generated and inserted into920the document. Note that because this element is declared to be \texttt{EMPTY} one can use the abbreviation921\begin{Verbatim}[fontsize=\small,frame=single,label=Example]922<TableOfContents/>923\end{Verbatim}924to denote this empty element. }925926927\subsection{\textcolor{Chapter }{\texttt{{\textless}Bibliography{\textgreater}} }}\label{Bibliography}928\logpage{[ 3, 2, 15 ]}929\hyperdef{L}{X84F3DF21786A8751}{}930{931\index{Bibliography@\texttt{Bibliography}}932\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]933<!ELEMENT Bibliography EMPTY>934<!ATTLIST Bibliography Databases CDATA #REQUIRED935Style CDATA #IMPLIED>936\end{Verbatim}937This element may occur in the \texttt{Book} element after the last \texttt{Appendix} element. If it is present, a bibliography section is generated and inserted938into the document. The attribute \texttt{Databases} must be specified, the names of several data files can be specified, separated939by commas.940941Two kinds of files can be specified in \texttt{Databases}: The first are Bib{\TeX} files as defined in{\nobreakspace}\cite[Appendix B]{La85}. Such files must have a name with extension \texttt{.bib}, and in \texttt{Databases} the name must be given \emph{without} this extension. Note that such \texttt{.bib}-files should be in latin1-encoding (or ASCII-encoding). The second are files942in BibXMLext format as defined in Section{\nobreakspace}\ref{BibXMLformat}. These files must have an extension \texttt{.xml} and in \texttt{Databases} the \emph{full} name must be specified.943944We suggest to use the BibXMLext format because it allows to produce945potentially nicer bibliography entries in text and HTML documents.946947A bibliography style may be specified with the \texttt{Style} attribute. The optional \texttt{Style} attribute (for {\LaTeX} output of the document) must also be specified without the \texttt{.bst} extension (the default is \texttt{alpha}). See also section \ref{Cite} for a description of the \texttt{Cite} element which is used to include bibliography references into the text.948949}950951952\subsection{\textcolor{Chapter }{\texttt{{\textless}TheIndex{\textgreater}}}}\label{TheIndex}953\logpage{[ 3, 2, 16 ]}954\hyperdef{L}{X7C53615A8477F1E5}{}955{956\index{TheIndex@\texttt{TheIndex}}957\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]958<!ELEMENT TheIndex EMPTY>959\end{Verbatim}960This element may occur in the \texttt{Book} element after the \texttt{Bibliography} element. If it is present, an index is generated and inserted into the961document. There are elements in \textsf{GAPDoc} which implicitly generate index entries (e.g., \texttt{Func} (\ref{Func})) and there is an element \texttt{Index} (\ref{Index}) for explicitly adding index entries. }962963}964965966\section{\textcolor{Chapter }{Sectioning Elements}}\logpage{[ 3, 3, 0 ]}967\hyperdef{L}{X80E2AD7481DD69D9}{}968{969A \textsf{GAPDoc} book is divided into \emph{chapters}, \emph{sections}, and \emph{subsections}. The idea is of course, that a chapter consists of sections, which in turn970consist of subsections. However for the sake of flexibility, the rules are not971too restrictive. Firstly, text is allowed everywhere in the body of the972document (and not only within sections). Secondly, the chapter level may be973omitted. The exact rules are described below.974975\emph{Appendices} are a flavor of chapters, occurring after all regular chapters. There is a976special type of subsection called ``\texttt{ManSection}''. This is a subsection devoted to the description of a function, operation or977variable. It is analogous to a manpage in the UNIX environment. Usually each978function, operation, method, and so on should have its own \texttt{ManSection}.979980Cross referencing is done on the level of \texttt{Subsection}s, respectively \texttt{ManSection}s. The topics in \textsf{GAP}'s online help are also pointing to subsections. So, they should not be too981long.982983We start our description of the sectioning elements ``top-down'':984\subsection{\textcolor{Chapter }{\texttt{{\textless}Body{\textgreater}}}}\logpage{[ 3, 3, 1 ]}985\hyperdef{L}{X7B38415687510D0A}{}986{987\index{Body@\texttt{Body}} The \texttt{Body} element marks the main part of the document. It must occur after the \texttt{TableOfContents} element. There is a big difference between \emph{inside} and \emph{outside} of this element: Whereas regular text is allowed nearly everywhere in the \texttt{Body} element and its subelements, this is not true for the \emph{outside}. This has also implications on the handling of whitespace. \emph{Outside} superfluous whitespace is usually ignored when it occurs between elements. \emph{Inside} of the \texttt{Body} element whitespace matters because character data is allowed nearly988everywhere. Here is the definition in the DTD:989\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]990<!ELEMENT Body ( %Text;| Chapter | Section )*>991\end{Verbatim}992The fact that \texttt{Chapter} and \texttt{Section} elements are allowed here leads to the possibility to omit the chapter level993entirely in the document. For a description of \texttt{\%Text;} see \ref{Text}.994995(Remark: The purpose of this element is to make sure that a \emph{valid} \textsf{GAPDoc} document has a correct overall structure, which is only possible when the top996element \texttt{Book} has element content.) }997998999\subsection{\textcolor{Chapter }{\texttt{{\textless}Chapter{\textgreater}}}}\label{Chapter}1000\logpage{[ 3, 3, 2 ]}1001\hyperdef{L}{X7A86B2BA7D688B6B}{}1002{1003\index{Chapter@\texttt{Chapter}}1004\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1005<!ELEMENT Chapter (%Text;| Heading | Section)*>1006<!ATTLIST Chapter Label CDATA #IMPLIED> <!-- For reference purposes -->1007\end{Verbatim}1008A \texttt{Chapter} element can have a \texttt{Label} attribute, such that this chapter can be referenced later on with a \texttt{Ref} element (see section \ref{Ref}). Note that you have to specify a label to reference the chapter as there is1009no automatic labelling!10101011\texttt{Chapter} elements can contain text (for a description of \texttt{\%Text;} see \ref{Text}), \texttt{Section} elements, and \texttt{Heading} elements.10121013The following \emph{additional} rule cannot be stated in the DTD because we want a \texttt{Chapter} element to have mixed content. There must be \emph{exactly one} \texttt{Heading} element in the \texttt{Chapter} element, containing the heading of the chapter. Here is its definition: }101410151016\subsection{\textcolor{Chapter }{\texttt{{\textless}Heading{\textgreater}}}}\label{Heading}1017\logpage{[ 3, 3, 3 ]}1018\hyperdef{L}{X79825E1C821D0B79}{}1019{1020\index{Heading@\texttt{Heading}}1021\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1022<!ELEMENT Heading (%InnerText;)*>1023\end{Verbatim}1024This element is used for headings in \texttt{Chapter}, \texttt{Section}, \texttt{Subsection}, and \texttt{Appendix} elements. It may only contain \texttt{\%InnerText;} (for a description see \ref{InnerText}).10251026Each of the mentioned sectioning elements must contain exactly one direct \texttt{Heading} element (i.e., one which is not contained in another sectioning element). }102710281029\subsection{\textcolor{Chapter }{\texttt{{\textless}Appendix{\textgreater}}}}\logpage{[ 3, 3, 4 ]}1030\hyperdef{L}{X7C701B2779767556}{}1031{1032\index{Appendix@\texttt{Appendix}}1033\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1034<!ELEMENT Appendix (%Text;| Heading | Section)*>1035<!ATTLIST Appendix Label CDATA #IMPLIED> <!-- For reference purposes -->1036\end{Verbatim}1037The \texttt{Appendix} element behaves exactly like a \texttt{Chapter} element (see \ref{Chapter}) except for the position within the document and the numbering. While1038chapters are counted with numbers (1., 2., 3., ...) the appendices are counted1039with capital letters (A., B., ...).10401041Again there is an optional \texttt{Label} attribute used for references. }104210431044\subsection{\textcolor{Chapter }{\texttt{{\textless}Section{\textgreater}}}}\logpage{[ 3, 3, 5 ]}1045\hyperdef{L}{X844DC2B47FB37339}{}1046{1047\index{Section@\texttt{Section}}1048\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1049<!ELEMENT Section (%Text;| Heading | Subsection | ManSection)*>1050<!ATTLIST Section Label CDATA #IMPLIED> <!-- For reference purposes -->1051\end{Verbatim}1052A \texttt{Section} element can have a \texttt{Label} attribute, such that this section can be referenced later on with a \texttt{Ref} element (see section \ref{Ref}). Note that you have to specify a label to reference the section as there is1053no automatic labelling!10541055\texttt{Section} elements can contain text (for a description of \texttt{\%Text;} see \ref{Text}), \texttt{Heading} elements, and subsections.10561057There must be exactly one direct \texttt{Heading} element in a \texttt{Section} element, containing the heading of the section.10581059Note that a subsection is either a \texttt{Subsection} element or a \texttt{ManSection} element. }106010611062\subsection{\textcolor{Chapter }{\texttt{{\textless}Subsection{\textgreater}}}}\logpage{[ 3, 3, 6 ]}1063\hyperdef{L}{X803ACA187E292969}{}1064{1065\index{Subsection@\texttt{Subsection}}1066\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1067<!ELEMENT Subsection (%Text;| Heading)*>1068<!ATTLIST Subsection Label CDATA #IMPLIED> <!-- For reference purposes -->1069\end{Verbatim}1070The \texttt{Subsection} element can have a \texttt{Label} attribute, such that this subsection can be referenced later on with a \texttt{Ref} element (see section \ref{Ref}). Note that you have to specify a label to reference the subsection as there1071is no automatic labelling!10721073\texttt{Subsection} elements can contain text (for a description of \texttt{\%Text;} see \ref{Text}), and \texttt{Heading} elements.10741075There must be exactly one \texttt{Heading} element in a \texttt{Subsection} element, containing the heading of the subsection.10761077Another type of subsection is a \texttt{ManSection}, explained now: }10781079}108010811082\section{\textcolor{Chapter }{ManSection{\textendash}a special kind of subsection}}\label{sec:mansect}1083\logpage{[ 3, 4, 0 ]}1084\hyperdef{L}{X877B8B7C7EDD09E9}{}1085{1086\texttt{ManSection}s are intended to describe a function, operation, method, variable, or some1087other technical instance. It is analogous to a manpage in the UNIX1088environment.1089\subsection{\textcolor{Chapter }{\texttt{{\textless}ManSection{\textgreater}}}}\logpage{[ 3, 4, 1 ]}1090\hyperdef{L}{X8375D9CC8672A1D5}{}1091{1092\index{ManSection@\texttt{ManSection}} \index{Description@\texttt{Description}} \index{Returns@\texttt{Returns}}1093\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1094<!ELEMENT ManSection ( Heading?,1095((Func, Returns?) | (Oper, Returns?) |1096(Meth, Returns?) | (Filt, Returns?) |1097(Prop, Returns?) | (Attr, Returns?) |1098(Constr, Returns?) |1099Var | Fam | InfoClass)+, Description )>1100<!ATTLIST ManSection Label CDATA #IMPLIED> <!-- For reference purposes -->11011102<!ELEMENT Returns (%Text;)*>1103<!ELEMENT Description (%Text;)*>1104\end{Verbatim}1105The \texttt{ManSection} element can have a \texttt{Label} attribute, such that this subsection can be referenced later on with a \texttt{Ref} element (see section \ref{Ref}). But this is probably rarely necessary because the elements \texttt{Func} and so on (explained below) generate automatically labels for cross1106referencing.11071108The content of a \texttt{ManSection} element is one or more elements describing certain items in \textsf{GAP}, each of them optionally followed by a \texttt{Returns} element, followed by a \texttt{Description} element, which contains \texttt{\%Text;} (see \ref{Text}) describing it. (Remember to include examples in the description as often as1109possible, see{\nobreakspace}\ref{Log}). The classes of items \textsf{GAPDoc} knows of are: functions (\texttt{Func}), operations (\texttt{Oper}), constructors (\texttt{Constr}), methods (\texttt{Meth}), filters (\texttt{Filt}), properties (\texttt{Prop}), attributes (\texttt{Attr}), variables (\texttt{Var}), families (\texttt{Fam}), and info classes (\texttt{InfoClass}). One \texttt{ManSection} should only describe several of such items when these are very closely1110related.11111112Each element for an item corresponding to a \textsf{GAP} function can be followed by a \texttt{Returns} element. In output versions of the document the string ``Returns: '' will be put in front of the content text. The text in the \texttt{Returns} element should usually be a short hint about the type of object returned by1113the function. This is intended to give a good mnemonic for the use of a1114function (together with a good choice of names for the formal arguments).11151116\texttt{ManSection}s are also sectioning elements which count as subsections. Usually there1117should be no \texttt{Heading}-element in a \texttt{ManSection}, in that case a heading is generated automatically from the first \texttt{Func}-like element. Sometimes this default behaviour does not look appropriate, for1118example when there are several \texttt{Func}-like elements. For such cases an optional \texttt{Heading} is allowed. }111911201121\subsection{\textcolor{Chapter }{\texttt{{\textless}Func{\textgreater}}}}\label{Func}1122\logpage{[ 3, 4, 2 ]}1123\hyperdef{L}{X7C41A7B5845205C4}{}1124{1125\index{Func@\texttt{Func}}1126\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1127<!ELEMENT Func EMPTY>1128<!ATTLIST Func Name CDATA #REQUIRED1129Label CDATA #IMPLIED1130Arg CDATA #REQUIRED1131Comm CDATA #IMPLIED>1132\end{Verbatim}1133This element is used within a \texttt{ManSection} element to specify the usage of a function. The \texttt{Name} attribute is required and its value is the name of the function. The value of1134the \texttt{Arg} attribute (also required) contains the full list of arguments including1135optional parts, which are denoted by square brackets. The argument names can1136be separated by whitespace, commas or the square brackets for the optional1137arguments, like \texttt{"grp[,{\nobreakspace}elm]"} or \texttt{"xx[y[z]{\nobreakspace}]"}. If \textsf{GAP} options are used, this can be followed by a colon \texttt{:} and one or more assignments, like \texttt{"n[,{\nobreakspace}r]: tries := 100"}.11381139The name of the function is also used as label for cross referencing. When the1140name of the function appears in the text of the document it should \emph{always} be written with the \texttt{Ref} element, see{\nobreakspace}\ref{Ref}. This allows to use a unique typesetting style for function names and1141automatic cross referencing.11421143If the optional \texttt{Label} attribute is given, it is appended (with a colon \texttt{:} in between) to the name of the function for cross referencing purposes. The1144text of the label can also appear in the document text. So, it should be a1145kind of short explanation.1146\begin{Verbatim}[fontsize=\small,frame=single,label=Example]1147<Func Arg="x[, y]" Name="LibFunc" Label="for my objects"/>1148\end{Verbatim}1149The optional \texttt{Comm} attribute should be a short description of the function, usually at most one1150line long (this is currently nowhere used).11511152This element automatically produces an index entry with the name of the1153function and, if present, the text of the \texttt{Label} attribute as subentry (see also{\nobreakspace}\ref{TheIndex} and{\nobreakspace}\ref{Index}). }115411551156\subsection{\textcolor{Chapter }{\texttt{{\textless}Oper{\textgreater}}}}\logpage{[ 3, 4, 3 ]}1157\hyperdef{L}{X7A15825E818A81CD}{}1158{1159\index{Oper@\texttt{Oper}}1160\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1161<!ELEMENT Oper EMPTY>1162<!ATTLIST Oper Name CDATA #REQUIRED1163Label CDATA #IMPLIED1164Arg CDATA #REQUIRED1165Comm CDATA #IMPLIED>1166\end{Verbatim}1167This element is used within a \texttt{ManSection} element to specify the usage of an operation. The attributes are used exactly1168in the same way as in the \texttt{Func} element (see \ref{Func}).11691170Note that multiple descriptions of the same operation may occur in a document1171because there may be several declarations in \textsf{GAP}. Furthermore there may be several \texttt{ManSection}s for methods of this operation (see{\nobreakspace}\ref{Meth}) which also use the same name. For reference purposes these must be1172distinguished by different \texttt{Label} attributes. }117311741175\subsection{\textcolor{Chapter }{\texttt{{\textless}Constr{\textgreater}}}}\logpage{[ 3, 4, 4 ]}1176\hyperdef{L}{X7FBFD7A3786C7CAB}{}1177{1178\index{Constr@\texttt{Constr}}1179\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1180<!ELEMENT Constr EMPTY>1181<!ATTLIST Constr Name CDATA #REQUIRED1182Label CDATA #IMPLIED1183Arg CDATA #REQUIRED1184Comm CDATA #IMPLIED>1185\end{Verbatim}1186This element is used within a \texttt{ManSection} element to specify the usage of a constructor. The attributes are used exactly1187in the same way as in the \texttt{Func} element (see \ref{Func}).11881189Note that multiple descriptions of the same constructor may occur in a1190document because there may be several declarations in \textsf{GAP}. Furthermore there may be several \texttt{ManSection}s for methods of this constructor (see{\nobreakspace}\ref{Meth}) which also use the same name. For reference purposes these must be1191distinguished by different \texttt{Label} attributes. }119211931194\subsection{\textcolor{Chapter }{\texttt{{\textless}Meth{\textgreater}}}}\label{Meth}1195\logpage{[ 3, 4, 5 ]}1196\hyperdef{L}{X81196E2B7F286A01}{}1197{1198\index{Meth@\texttt{Meth}}1199\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1200<!ELEMENT Meth EMPTY>1201<!ATTLIST Meth Name CDATA #REQUIRED1202Label CDATA #IMPLIED1203Arg CDATA #REQUIRED1204Comm CDATA #IMPLIED>1205\end{Verbatim}1206This element is used within a \texttt{ManSection} element to specify the usage of a method. The attributes are used exactly in1207the same way as in the \texttt{Func} element (see \ref{Func}).12081209Frequently, an operation is implemented by several different methods.1210Therefore it seems to be interesting to document them independently. This is1211possible by using the same method name in different \texttt{ManSection}s. It is however required that these subsections and those describing the1212corresponding operation are distinguished by different \texttt{Label} attributes. }121312141215\subsection{\textcolor{Chapter }{\texttt{{\textless}Filt{\textgreater}}}}\logpage{[ 3, 4, 6 ]}1216\hyperdef{L}{X7D8D2C38828D5854}{}1217{1218\index{Filt@\texttt{Filt}}1219\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1220<!ELEMENT Filt EMPTY>1221<!ATTLIST Filt Name CDATA #REQUIRED1222Label CDATA #IMPLIED1223Arg CDATA #IMPLIED1224Comm CDATA #IMPLIED1225Type CDATA #IMPLIED>1226\end{Verbatim}1227This element is used within a \texttt{ManSection} element to specify the usage of a filter. The first four attributes are used1228in the same way as in the \texttt{Func} element (see \ref{Func}), except that the \texttt{Arg} attribute is optional.12291230The \texttt{Type} attribute can be any string, but it is thought to be something like ``\texttt{Category}'' or ``\texttt{Representation}''. }123112321233\subsection{\textcolor{Chapter }{\texttt{{\textless}Prop{\textgreater}}}}\logpage{[ 3, 4, 7 ]}1234\hyperdef{L}{X7D6400A67C30B752}{}1235{1236\index{Prop@\texttt{Prop}}1237\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1238<!ELEMENT Prop EMPTY>1239<!ATTLIST Prop Name CDATA #REQUIRED1240Label CDATA #IMPLIED1241Arg CDATA #REQUIRED1242Comm CDATA #IMPLIED>1243\end{Verbatim}1244This element is used within a \texttt{ManSection} element to specify the usage of a property. The attributes are used exactly in1245the same way as in the \texttt{Func} element (see \ref{Func}).12461247}124812491250\subsection{\textcolor{Chapter }{\texttt{{\textless}Attr{\textgreater}}}}\logpage{[ 3, 4, 8 ]}1251\hyperdef{L}{X78CEEC5986987A97}{}1252{1253\index{Attr@\texttt{Attr}}1254\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1255<!ELEMENT Attr EMPTY>1256<!ATTLIST Attr Name CDATA #REQUIRED1257Label CDATA #IMPLIED1258Arg CDATA #REQUIRED1259Comm CDATA #IMPLIED>1260\end{Verbatim}1261This element is used within a \texttt{ManSection} element to specify the usage of an attribute (in \textsf{GAP}). The attributes are used exactly in the same way as in the \texttt{Func} element (see \ref{Func}).12621263}126412651266\subsection{\textcolor{Chapter }{\texttt{{\textless}Var{\textgreater}}}}\logpage{[ 3, 4, 9 ]}1267\hyperdef{L}{X7C3AACBE7BC6AABF}{}1268{1269\index{Var@\texttt{Var}}1270\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1271<!ELEMENT Var EMPTY>1272<!ATTLIST Var Name CDATA #REQUIRED1273Label CDATA #IMPLIED1274Comm CDATA #IMPLIED>1275\end{Verbatim}1276This element is used within a \texttt{ManSection} element to document a global variable. The attributes are used exactly in the1277same way as in the \texttt{Func} element (see \ref{Func}) except that there is no \texttt{Arg} attribute.12781279}128012811282\subsection{\textcolor{Chapter }{\texttt{{\textless}Fam{\textgreater}}}}\logpage{[ 3, 4, 10 ]}1283\hyperdef{L}{X85EE992E7FED2FE6}{}1284{1285\index{Fam@\texttt{Fam}}1286\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1287<!ELEMENT Fam EMPTY>1288<!ATTLIST Fam Name CDATA #REQUIRED1289Label CDATA #IMPLIED1290Comm CDATA #IMPLIED>1291\end{Verbatim}1292This element is used within a \texttt{ManSection} element to document a family. The attributes are used exactly in the same way1293as in the \texttt{Func} element (see \ref{Func}) except that there is no \texttt{Arg} attribute.12941295}129612971298\subsection{\textcolor{Chapter }{\texttt{{\textless}InfoClass{\textgreater}}}}\logpage{[ 3, 4, 11 ]}1299\hyperdef{L}{X78F0D4D1811E5BAE}{}1300{1301\index{InfoClass@\texttt{InfoClass}}1302\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1303<!ELEMENT InfoClass EMPTY>1304<!ATTLIST InfoClass Name CDATA #REQUIRED1305Label CDATA #IMPLIED1306Comm CDATA #IMPLIED>1307\end{Verbatim}1308This element is used within a \texttt{ManSection} element to document an info class. The attributes are used exactly in the same1309way as in the \texttt{Func} element (see \ref{Func}) except that there is no \texttt{Arg} attribute.13101311}13121313}131413151316\section{\textcolor{Chapter }{Cross Referencing and Citations}}\logpage{[ 3, 5, 0 ]}1317\hyperdef{L}{X78595FB585569617}{}1318{1319Cross referencing in the \textsf{GAPDoc} system is somewhat different to the usual {\LaTeX} cross referencing in so far, that a reference knows ``which type of object'' it is referencing. For example a ``reference to a function'' is distinguished from a ``reference to a chapter''. The idea of this is, that the markup must contain this information such that1320the converters can produce better output. The HTML converter can for example1321typeset a function reference just as the name of the function with a link to1322the description of the function, or a chapter reference as a number with a1323link in the other case.13241325Referencing is done with the \texttt{Ref} element:1326\subsection{\textcolor{Chapter }{\texttt{{\textless}Ref{\textgreater}}}}\label{Ref}1327\logpage{[ 3, 5, 1 ]}1328\hyperdef{L}{X8656F2338007406E}{}1329{1330\index{Ref@\texttt{Ref}}1331\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1332<!ELEMENT Ref EMPTY>1333<!ATTLIST Ref Func CDATA #IMPLIED1334Oper CDATA #IMPLIED1335Constr CDATA #IMPLIED1336Meth CDATA #IMPLIED1337Filt CDATA #IMPLIED1338Prop CDATA #IMPLIED1339Attr CDATA #IMPLIED1340Var CDATA #IMPLIED1341Fam CDATA #IMPLIED1342InfoClass CDATA #IMPLIED1343Chap CDATA #IMPLIED1344Sect CDATA #IMPLIED1345Subsect CDATA #IMPLIED1346Appendix CDATA #IMPLIED1347Text CDATA #IMPLIED13481349Label CDATA #IMPLIED1350BookName CDATA #IMPLIED1351Style (Text | Number) #IMPLIED> <!-- normally automatic -->1352\end{Verbatim}1353The \texttt{Ref} element is defined to be \texttt{EMPTY}. If one of the attributes \texttt{Func}, \texttt{Oper}, \texttt{Constr}, \texttt{Meth}, \texttt{Prop}, \texttt{Attr}, \texttt{Var}, \texttt{Fam}, \texttt{InfoClass}, \texttt{Chap}, \texttt{Sect}, \texttt{Subsect}, \texttt{Appendix} is given then there must be exactly one of these, making the reference one to1354the corresponding object. The \texttt{Label} attribute can be specified in addition to make the reference unique, for1355example if more than one method with a given name is present. (Note that there1356is no way to specify in the DTD that exactly one of the first listed1357attributes must be given, this is an additional rule.)13581359A reference to a \texttt{Label} element defined below (see \ref{Label}) is done by giving the \texttt{Label} attribute and optionally the \texttt{Text} attribute. If the \texttt{Text} attribute is present its value is typeset in place of the \texttt{Ref} element, if linking is possible (for example in HTML). If this is not1360possible, the section number is typeset. This type of reference is also used1361for references to tables (see \ref{Table}).13621363An external reference into another book can be specified by using the \texttt{BookName} attribute. In this case the \texttt{Label} attribute or, if this is not given, the function or section like attribute, is1364used to resolve the reference. The generated reference points to the first hit1365when asking ``?book name: label'' inside \textsf{GAP}.13661367The optional attribute \texttt{Style} can take only the values \texttt{Text} and \texttt{Number}. It can be used with references to sectioning units and it gives a hint to1368the converter programs, whether an explicit section number is generated or1369text. Normally all references to sections generate numbers and references to a \textsf{GAP} object generate the name of the corresponding object with some additional link1370or sectioning information, which is the behavior of \texttt{Style="Text"}. In case \texttt{Style="Number"} in all cases an explicit section number is generated. So1371\begin{Verbatim}[fontsize=\small,frame=single,label=Example]1372<Ref Subsect="Func" Style="Text"/> described in section1373<Ref Subsect="Func" Style="Number"/>1374\end{Verbatim}1375produces: \hyperref[Func]{`\texttt{{\textless}Func{\textgreater}}'} described in section \ref{Func}. }137613771378\subsection{\textcolor{Chapter }{\texttt{{\textless}Label{\textgreater}}}}\label{Label}1379\logpage{[ 3, 5, 2 ]}1380\hyperdef{L}{X7C85CA5484344DB5}{}1381{1382\index{Label@\texttt{Label}}1383\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1384<!ELEMENT Label EMPTY>1385<!ATTLIST Label Name CDATA #REQUIRED>1386\end{Verbatim}1387This element is used to define a label for referencing a certain position in1388the document, if this is possible. If an exact reference is not possible (like1389in a printed version of the document) a reference to the corresponding1390subsection is generated. The value of the \texttt{Name} attribute must be unique under all \texttt{Label} elements. }139113921393\subsection{\textcolor{Chapter }{\texttt{{\textless}Cite{\textgreater}}}}\label{Cite}1394\logpage{[ 3, 5, 3 ]}1395\hyperdef{L}{X851DE9D279D8FB04}{}1396{1397\index{Cite@\texttt{Cite}}1398\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1399<!ELEMENT Cite EMPTY>1400<!ATTLIST Cite Key CDATA #REQUIRED1401Where CDATA #IMPLIED>1402\end{Verbatim}1403This element is for bibliography citations. It is \texttt{EMPTY} by definition. The attribute \texttt{Key} is the key for a lookup in a Bib{\TeX} database that has to be specified in the \texttt{Bibliography} element (see \ref{Bibliography}). The value of the \texttt{Where} attribute specifies the position in the document as in the corresponding {\LaTeX} syntax \texttt{\texttt{\symbol{92}}cite[Where value]\texttt{\symbol{123}}Key1404value\texttt{\symbol{125}}}. }140514061407\subsection{\textcolor{Chapter }{\texttt{{\textless}Index{\textgreater}}}}\label{Index}1408\logpage{[ 3, 5, 4 ]}1409\hyperdef{L}{X811042BA78843777}{}1410{1411\index{Index@\texttt{Index}}1412\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1413<!ELEMENT Index (%InnerText;|Subkey)*>1414<!ATTLIST Index Key CDATA #IMPLIED1415Subkey CDATA #IMPLIED>1416<!ELEMENT Subkey (%InnerText;)*>1417\end{Verbatim}1418This element generates an index entry. The content of the element is typeset1419in the index. It can optionally contain a \texttt{Subkey} element. If one or both of the attributes \texttt{Key} and \texttt{Subkey} are given, then the attribute values are used for sorting the index entries.1420Otherwise the content itself is used for sorting. The attributes should be1421used when the content contains markup. Note that all \texttt{Func} and similar elements automatically generate index entries. If the \texttt{TheIndex} element (\ref{TheIndex}) is not present in the document all \texttt{Index} elements are ignored. }142214231424\subsection{\textcolor{Chapter }{\texttt{{\textless}URL{\textgreater}}}}\label{URL}1425\logpage{[ 3, 5, 5 ]}1426\hyperdef{L}{X81B3E46F839E1C5B}{}1427{1428\index{URL@\texttt{URL}}1429\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1430<!ELEMENT URL (#PCDATA|Alt|Link|LinkText)*> <!-- Link, LinkText1431variant for case where text needs further markup -->1432<!ATTLIST URL Text CDATA #IMPLIED> <!-- This is for output formats1433that have links like HTML -->1434<!ELEMENT Link (%InnerText;)*> <!-- the URL -->1435<!ELEMENT LinkText (%InnerText;)*> <!-- text for links, can contain markup -->14361437\end{Verbatim}1438This element is for references into the internet. It specifies an URL and1439optionally a text which can be used for a link (like in HTML or PDF versions1440of the document). This can be specified in two ways: Either the URL is given1441as element content and the text is given in the optional \texttt{Text} attribute (in this case the text cannot contain further markup), or the1442element contains the two elements \texttt{Link} and \texttt{LinkText} which in turn contain the URL and the text, respectively. The default value1443for the text is the URL itself. }144414451446\subsection{\textcolor{Chapter }{\texttt{{\textless}Email{\textgreater}}}}\label{elEmail}1447\logpage{[ 3, 5, 6 ]}1448\hyperdef{L}{X8310C4F084CD9DB9}{}1449{1450\index{Email@\texttt{Email}}1451\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1452<!ELEMENT Email (#PCDATA|Alt|Link|LinkText)*>1453\end{Verbatim}1454This element type is the special case of an URL specifying an email address.1455The content of the element should be the email address without any prefix like ``\texttt{mailto:}''. This address is typeset by all converters, also without any prefix. In the1456case of an output document format like HTML the converter can produce a link1457with a ``\texttt{mailto:}'' prefix. }145814591460\subsection{\textcolor{Chapter }{\texttt{{\textless}Homepage{\textgreater}}}}\label{elHomepage}1461\logpage{[ 3, 5, 7 ]}1462\hyperdef{L}{X7D5CC4267D04D7E7}{}1463{1464\index{Homepage@\texttt{Homepage}}1465\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1466<!ELEMENT Homepage (#PCDATA|Alt|Link|LinkText)*>1467\end{Verbatim}1468This element type is the special case of an URL specifying a WWW-homepage. }14691470}147114721473\section{\textcolor{Chapter }{Structural Elements like Lists}}\logpage{[ 3, 6, 0 ]}1474\hyperdef{L}{X840099DF83823686}{}1475{1476The \textsf{GAPDoc} system offers some limited access to structural elements like lists,1477enumerations, and tables. Although it is possible to use all {\LaTeX} constructs one always has to think about other output formats. The elements in1478this section are guaranteed to produce something reasonable in all output1479formats.1480\subsection{\textcolor{Chapter }{\texttt{{\textless}List{\textgreater}}}}\label{List}1481\logpage{[ 3, 6, 1 ]}1482\hyperdef{L}{X785183F67DA402A0}{}1483{1484\index{List@\texttt{List}}1485\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1486<!ELEMENT List ( ((Mark,Item)|Item)+ )>1487<!ATTLIST List Only CDATA #IMPLIED1488Not CDATA #IMPLIED>1489\end{Verbatim}1490This element produces a list. Each item in the list corresponds to an \texttt{Item} element. Every \texttt{Item} element is optionally preceded by a \texttt{Mark} element. The content of this is used as a marker for the item. Note that this1491marker can be a whole word or even a sentence. It will be typeset in some1492emphasized fashion and most converters will provide some indentation for the1493rest of the item.14941495The \texttt{Only} and \texttt{Not} attributes can be used to specify, that the list is included into the output1496by only one type of converter (\texttt{Only}) or all but one type of converter (\texttt{Not}). Of course at most one of the two attributes may occur in one element. The1497following values are allowed as of now: ``\texttt{LaTeX}'', ``\texttt{HTML}'', and ``\texttt{Text}''. See also the \texttt{Alt} element in \ref{Alt} for more about text alternatives for certain converters. }149814991500\subsection{\textcolor{Chapter }{\texttt{{\textless}Mark{\textgreater}}}}\logpage{[ 3, 6, 2 ]}1501\hyperdef{L}{X7B1545A9797442DC}{}1502{1503\index{Mark@\texttt{Mark}}1504\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1505<!ELEMENT Mark ( %InnerText;)*>1506\end{Verbatim}1507This element is used in the \texttt{List} element to mark items. See \ref{List} for an explanation. }150815091510\subsection{\textcolor{Chapter }{\texttt{{\textless}Item{\textgreater}}}}\label{Item}1511\logpage{[ 3, 6, 3 ]}1512\hyperdef{L}{X86C204987AB4B13D}{}1513{1514\index{Item@\texttt{Item}}1515\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1516<!ELEMENT Item ( %Text;)*>1517\end{Verbatim}1518This element is used in the \texttt{List}, \texttt{Enum}, and \texttt{Table} elements to specify the items. See sections \ref{List}, \ref{Enum}, and \ref{Table} for further information. }151915201521\subsection{\textcolor{Chapter }{\texttt{{\textless}Enum{\textgreater}}}}\label{Enum}1522\logpage{[ 3, 6, 4 ]}1523\hyperdef{L}{X78A52B00846562DE}{}1524{1525\index{Enum@\texttt{Enum}}1526\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1527<!ELEMENT Enum ( Item+ )>1528<!ATTLIST Enum Only CDATA #IMPLIED1529Not CDATA #IMPLIED>1530\end{Verbatim}1531This element is used like the \texttt{List} element (see \ref{List}) except that the items must not have marks attached to them. Instead, the1532items are numbered automatically. The same comments about the \texttt{Only} and \texttt{Not} attributes as above apply. }153315341535\subsection{\textcolor{Chapter }{\texttt{{\textless}Table{\textgreater}}}}\label{Table}1536\logpage{[ 3, 6, 5 ]}1537\hyperdef{L}{X7F9CAA577EB4070B}{}1538{1539\index{Table@\texttt{Table}} \index{Caption@\texttt{{\textless}Caption{\textgreater}}} \index{Row@\texttt{{\textless}Row{\textgreater}}} \index{Align@\texttt{{\textless}Align{\textgreater}}} \index{HorLine@\texttt{{\textless}HorLine{\textgreater}}} \index{Item in Table@\texttt{{\textless}Item{\textgreater}} in \texttt{{\textless}Table{\textgreater}}}1540\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1541<!ELEMENT Table ( Caption?, (Row | HorLine)+ )>1542<!ATTLIST Table Label CDATA #IMPLIED1543Only CDATA #IMPLIED1544Not CDATA #IMPLIED1545Align CDATA #REQUIRED>1546<!-- We allow | and l,c,r, nothing else -->1547<!ELEMENT Row ( Item+ )>1548<!ELEMENT HorLine EMPTY>1549<!ELEMENT Caption ( %InnerText;)*>1550\end{Verbatim}1551A table in \textsf{GAPDoc} consists of an optional \texttt{Caption} element followed by a sequence of \texttt{Row} and \texttt{HorLine} elements. A \texttt{HorLine} element produces a horizontal line in the table. A \texttt{Row} element consists of a sequence of \texttt{Item} elements as they also occur in \texttt{List} and \texttt{Enum} elements. The \texttt{Only} and \texttt{Not} attributes have the same functionality as described in the \texttt{List} element in \ref{List}.15521553The \texttt{Align} attribute is written like a {\LaTeX} tabular alignment specifier but only the letters ``\texttt{l}'', ``\texttt{r}'', ``\texttt{c}'', and ``\texttt{|}'' are allowed meaning left alignment, right alignment, centered alignment, and a1554vertical line as delimiter between columns respectively.15551556If the \texttt{Label} attribute is there, one can reference the table with the \texttt{Ref} element (see \ref{Ref}) using its \texttt{Label} attribute.15571558Usually only simple tables should be used. If you want a complicated table in1559the {\LaTeX} output you should provide alternatives for text and HTML output. Note that in1560HTML-4.0 there is no possibility to interpret the ``\texttt{|}'' column separators and \texttt{HorLine} elements as intended. There are lines between all columns and rows or no lines1561at all. }15621563}156415651566\section{\textcolor{Chapter }{Types of Text}}\logpage{[ 3, 7, 0 ]}1567\hyperdef{L}{X7CA1E1327AFBA578}{}1568{1569This section covers the markup of text. Various types of ``text'' exist. The following elements are used in the \textsf{GAPDoc} system to mark them. They mostly come in pairs, one long name which is easier1570to remember and a shortcut to make the markup ``lighter''.15711572Most of the following elements are thought to contain only character data and1573no further markup elements. It is however necessary to allow \texttt{Alt} elements to resolve the entities described in section \ref{GDent}.1574\subsection{\textcolor{Chapter }{\texttt{{\textless}Emph{\textgreater}} and \texttt{{\textless}E{\textgreater}}}}\logpage{[ 3, 7, 1 ]}1575\hyperdef{L}{X7B15C428861749FD}{}1576{1577\index{Emph@\texttt{Emph}} \index{E@\texttt{E}}1578\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1579<!ELEMENT Emph (%InnerText;)*> <!-- Emphasize something -->1580<!ELEMENT E (%InnerText;)*> <!-- the same as shortcut -->1581\end{Verbatim}1582This element is used to emphasize some piece of text. It may contain \texttt{\%InnerText;} (see \ref{InnerText}). }158315841585\subsection{\textcolor{Chapter }{\texttt{{\textless}Quoted{\textgreater}} and \texttt{{\textless}Q{\textgreater}}}}\logpage{[ 3, 7, 2 ]}1586\hyperdef{L}{X80028C2483C9467E}{}1587{1588\index{Quoted@\texttt{Quoted}} \index{Q@\texttt{Q}}1589\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1590<!ELEMENT Quoted (%InnerText;)*> <!-- Quoted (in quotes) text -->1591<!ELEMENT Q (%InnerText;)*> <!-- Quoted text (shortcut) -->1592\end{Verbatim}1593This element is used to put some piece of text into ``{\nobreakspace}''-quotes. It may contain \texttt{\%InnerText;} (see \ref{InnerText}). }159415951596\subsection{\textcolor{Chapter }{\texttt{{\textless}Keyword{\textgreater}} and \texttt{{\textless}K{\textgreater}}}}\logpage{[ 3, 7, 3 ]}1597\hyperdef{L}{X867BB95E7DC87014}{}1598{1599\index{Keyword@\texttt{Keyword}} \index{K@\texttt{K}}1600\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1601<!ELEMENT Keyword (#PCDATA|Alt)*> <!-- Keyword -->1602<!ELEMENT K (#PCDATA|Alt)*> <!-- Keyword (shortcut) -->1603\end{Verbatim}1604This element is used to mark something as a \emph{keyword}. Usually this will be a \textsf{GAP} keyword such as ``\texttt{if}'' or ``\texttt{for}''. No further markup elements are allowed within this element except for the \texttt{Alt} element, which is necessary. }160516061607\subsection{\textcolor{Chapter }{\texttt{{\textless}Arg{\textgreater}} and \texttt{{\textless}A{\textgreater}}}}\label{Arg}1608\logpage{[ 3, 7, 4 ]}1609\hyperdef{L}{X86FD4CCA7F98351F}{}1610{1611\index{Arg@\texttt{Arg}} \index{A@\texttt{A}}1612\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1613<!ELEMENT Arg (#PCDATA|Alt)*> <!-- Argument -->1614<!ELEMENT A (#PCDATA|Alt)*> <!-- Argument (shortcut) -->1615\end{Verbatim}1616This element is used inside \texttt{Description}s in \texttt{ManSection}s to mark something as an \emph{argument} (of a function, operation, or such). It is guaranteed that the converters1617typeset those exactly as in the definition of functions. No further markup1618elements are allowed within this element. }161916201621\subsection{\textcolor{Chapter }{\texttt{{\textless}Code{\textgreater}} and \texttt{{\textless}C{\textgreater}}}}\label{Code}1622\logpage{[ 3, 7, 5 ]}1623\hyperdef{L}{X8400998B7B3A4379}{}1624{1625\index{Code@\texttt{Code}} \index{C@\texttt{C}}1626\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1627<!ELEMENT Code (#PCDATA|Arg|Alt)*> <!-- GAP code -->1628<!ELEMENT C (#PCDATA|Arg|Alt)*> <!-- GAP code (shortcut) -->1629\end{Verbatim}1630This element is used to mark something as a piece of \emph{code} like for example a \textsf{GAP} expression. It is guaranteed that the converters typeset this exactly as in1631the \texttt{Listing} element (compare section \ref{Listing}). The only further markup elements allowed within this element are \texttt{{\textless}Arg{\textgreater}} elements (see \ref{Arg}). }163216331634\subsection{\textcolor{Chapter }{\texttt{{\textless}File{\textgreater}} and \texttt{{\textless}F{\textgreater}}}}\logpage{[ 3, 7, 6 ]}1635\hyperdef{L}{X875AF9B4812C5249}{}1636{1637\index{File@\texttt{File}} \index{F@\texttt{F}}1638\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1639<!ELEMENT File (#PCDATA|Alt)*> <!-- Filename -->1640<!ELEMENT F (#PCDATA|Alt)*> <!-- Filename (shortcut) -->1641\end{Verbatim}1642This element is used to mark something as a \emph{filename} or a \emph{pathname} in the file system. No further markup elements are allowed within this1643element. }164416451646\subsection{\textcolor{Chapter }{\texttt{{\textless}Button{\textgreater}} and \texttt{{\textless}B{\textgreater}}}}\logpage{[ 3, 7, 7 ]}1647\hyperdef{L}{X7929BA7D78A977FF}{}1648{1649\index{Button@\texttt{Button}} \index{B@\texttt{B}}1650\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1651<!ELEMENT Button (#PCDATA|Alt)*> <!-- "Button" (also Menu, Key, ...) -->1652<!ELEMENT B (#PCDATA|Alt)*> <!-- "Button" (shortcut) -->1653\end{Verbatim}1654This element is used to mark something as a \emph{button}. It can also be used for other items in a graphical user interface like \emph{menus}, \emph{menu entries}, or \emph{keys}. No further markup elements are allowed within this element. }165516561657\subsection{\textcolor{Chapter }{\texttt{{\textless}Package{\textgreater}}}}\logpage{[ 3, 7, 8 ]}1658\hyperdef{L}{X7F4FFA877B775188}{}1659{1660\index{Package@\texttt{Package}}1661\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1662<!ELEMENT Package (#PCDATA|Alt)*> <!-- A package name -->1663\end{Verbatim}1664This element is used to mark something as a name of a \emph{package}. This is for example used to define the entities \textsf{GAP}, \textsf{XGAP} or \textsf{GAPDoc} (see section \ref{GDent}). No further markup elements are allowed within this element. }166516661667\subsection{\textcolor{Chapter }{\texttt{{\textless}Listing{\textgreater}}}}\label{Listing}1668\logpage{[ 3, 7, 9 ]}1669\hyperdef{L}{X7F531B157D656836}{}1670{1671\index{Listing@\texttt{Listing}}1672\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1673<!ELEMENT Listing (#PCDATA)> <!-- This is just for GAP code listings -->1674<!ATTLIST Listing Type CDATA #IMPLIED> <!-- a comment about the type of1675listed code, may appear in1676output -->1677\end{Verbatim}1678This element is used to embed listings of programs into the document. Only1679character data and no other elements are allowed in the content. You should \emph{not} use the character entities described in section \ref{GDent} but instead type the characters directly. Only the general XML rules from1680section \ref{EnterXML} apply. Note especially the usage of \texttt{{\textless}![CDATA[} sections described there. It is guaranteed that all converters use a fixed1681width font for typesetting \texttt{Listing} elements. Compare also the usage of the \texttt{Code} and \texttt{C} elements in \ref{Code}.16821683The \texttt{Type} attribute contains a comment about the type of listed code. It may appear in1684the output. }168516861687\subsection{\textcolor{Chapter }{\texttt{{\textless}Log{\textgreater}} and \texttt{{\textless}Example{\textgreater}}}}\label{Log}1688\logpage{[ 3, 7, 10 ]}1689\hyperdef{L}{X810DEA1E83A57CFE}{}1690{1691\index{Log@\texttt{Log}} \index{Example@\texttt{Example}}1692\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1693<!ELEMENT Example (#PCDATA)> <!-- This is subject to the automatic1694example checking mechanism -->1695<!ELEMENT Log (#PCDATA)> <!-- This not -->1696\end{Verbatim}1697These two elements behave exactly like the \texttt{Listing} element (see \ref{Listing}). They are thought for protocols of \textsf{GAP} sessions. The only difference between the two is that \texttt{Example} sections are intended to be subject to an automatic manual checking mechanism1698used to ensure the correctness of the \textsf{GAP} manual whereas \texttt{Log} is not touched by this (see section \ref{Sec:TestExample} for checking tools).16991700To get a good layout of the examples for display in a standard terminal we1701suggest to use \texttt{SizeScreen([72]);} (see \texttt{SizeScreen} (\textbf{Reference: SizeScreen})) in your \textsf{GAP} session before producing the content of \texttt{Example} elements. }170217031704\subsection{\textcolor{Chapter }{\texttt{{\textless}Verb{\textgreater}}}}\label{Verb}1705\logpage{[ 3, 7, 11 ]}1706\hyperdef{L}{X7F8C4D018346B2CF}{}1707{1708There is one further type of verbatim-like element.1709\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1710<!ELEMENT Verb (#PCDATA)>1711\end{Verbatim}1712The content of such an element is guaranteed to be put into an output version1713exactly as it is using some fixed width font. Before the content a new line is1714started. If the line after the end of the start tag consists of whitespace1715only then this part of the content is skipped.17161717This element is intended to be used together with the \texttt{Alt} element to specify pre-formatted ASCII alternatives for complicated \texttt{Display} formulae or \texttt{Table}s. }17181719}172017211722\section{\textcolor{Chapter }{Elements for Mathematical Formulae}}\label{MathForm}1723\logpage{[ 3, 8, 0 ]}1724\hyperdef{L}{X8145F6B37C04AA0A}{}1725{17261727\subsection{\textcolor{Chapter }{\texttt{{\textless}Math{\textgreater}} and \texttt{{\textless}Display{\textgreater}}}}\label{Math}1728\logpage{[ 3, 8, 1 ]}1729\hyperdef{L}{X7AA02845868AA533}{}1730{1731\index{Math@\texttt{Math}} \index{Display@\texttt{Display}}1732\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1733<!-- Normal TeX math mode formula -->1734<!ELEMENT Math (#PCDATA|A|Arg|Alt)*>1735<!-- TeX displayed math mode formula -->1736<!ELEMENT Display (#PCDATA|A|Arg|Alt)*>1737<!-- Mode="M" causes <M>-style formatting -->1738<!ATTLIST Display Mode CDATA #IMPLIED>1739\end{Verbatim}1740These elements are used for mathematical formulae. As described in section \ref{GDformulae} they correspond to {\LaTeX}'s math and display math mode respectively.17411742The formulae are typed in as in {\LaTeX}, \emph{except} that the standard XML entities, see{\nobreakspace}\ref{XMLent} (in particular the characters \texttt{{\textless}} and \texttt{\&}), must be escaped - either by using the corresponding entities or by1743enclosing the formula between ``\texttt{{\textless}![CDATA[}'' and ``\texttt{]]{\textgreater}}''. (The main reference for {\LaTeX} is \cite{La85}.)17441745It is also possible to use some unicode characters for mathematical symbols1746directly, provided that it can be translated by \texttt{Encode} (\ref{Encode}) into \texttt{"LaTeX"} encoding and that \texttt{SimplifiedUnicodeString} (\ref{SimplifiedUnicodeString}) with arguments \texttt{"latin1"} and \texttt{"single"} returns something sensible. Currently, we support entities \texttt{\&CC;}, \texttt{\&ZZ;}, \texttt{\&NN;}, \texttt{\&PP;}, \texttt{\&QQ;}, \texttt{\&HH;}, \texttt{\&RR;} for the corresponding black board bold letters {\ensuremath{\mathbb C}},1747{\ensuremath{\mathbb Z}}, {\ensuremath{\mathbb N}}, {\ensuremath{\mathbb P}},1748{\ensuremath{\mathbb Q}}, {\ensuremath{\mathbb H}} and {\ensuremath{\mathbb1749R}}, respectively.17501751The only element type that is allowed within the formula elements is the \texttt{Arg} or \texttt{A} element (see \ref{Arg}), which is used to typeset identifiers that are arguments to \textsf{GAP} functions or operations.17521753If a \texttt{Display} element has an attribute \texttt{Mode} with value \texttt{"M"}, then the formula is formatted as in \texttt{M} elements (see{\nobreakspace}\ref{M}). Otherwise in text and HTML output the formula is shown as {\LaTeX} source code.17541755For simple formulae (and you should try to make all your formulae simple!)1756attempt to use the \texttt{M} element or the \texttt{Mode="M"} attribute in \texttt{Display} for which there is a well defined translation into text, which can be used for1757text and HTML output versions of the document. So, if possible try to avoid1758the \texttt{Math} elements and \texttt{Display} elements without attribute or provide useful text substitutes for complicated1759formulae via \texttt{Alt} elements (see{\nobreakspace}\ref{Alt} and{\nobreakspace}\ref{Verb}). }176017611762\subsection{\textcolor{Chapter }{\texttt{{\textless}M{\textgreater}}}}\label{M}1763\logpage{[ 3, 8, 2 ]}1764\hyperdef{L}{X7ABF42328467E966}{}1765{1766\index{M@\texttt{M}}1767\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1768<!-- Math with well defined translation to text output -->1769<!ELEMENT M (#PCDATA|A|Arg|Alt)*>1770\end{Verbatim}1771The ``\texttt{M}'' element type is intended for formulae in the running text for which there is a1772sensible text version. For the {\LaTeX} version of a \textsf{GAPDoc} document the \texttt{M} and \texttt{Math} elements are equivalent. The remarks in \ref{Math} about special characters and the \texttt{Arg} element apply here as well. A document which has all formulae enclosed in \texttt{M} elements can be well readable in text terminal output and printed output1773versions.17741775Compared to former versions of \textsf{GAPDoc} many more formulae can be put into \texttt{M} elements. Most modern terminal emulations support unicode characters and many1776mathematical symbols can now be represented by such characters. But even if a1777terminal can only display ASCII characters, the user will see some not too bad1778representation of a formula.17791780As examples, here are some {\LaTeX} macros which have a sensible ASCII translation and are guaranteed to be1781translated accordingly by text (and HTML) converters (for a full list of1782handled Macros see \texttt{RecNames(TEXTMTRANSLATIONS)}): \begin{center}1783\begin{tabular}{|l|l|}\hline1784\texttt{\symbol{92}}ast&1785\texttt{*}\\1786\hline1787\texttt{\symbol{92}}bf&1788\texttt{}\\1789\hline1790\texttt{\symbol{92}}bmod&1791\texttt{mod}\\1792\hline1793\texttt{\symbol{92}}cdot&1794\texttt{*}\\1795\hline1796\texttt{\symbol{92}}colon&1797\texttt{:}\\1798\hline1799\texttt{\symbol{92}}equiv&1800\texttt{=}\\1801\hline1802\texttt{\symbol{92}}geq&1803\texttt{{\textgreater}=}\\1804\hline1805\texttt{\symbol{92}}germ&1806\texttt{}\\1807\hline1808\texttt{\symbol{92}}hookrightarrow&1809\texttt{-{\textgreater}}\\1810\hline1811\texttt{\symbol{92}}iff&1812\texttt{{\textless}={\textgreater}}\\1813\hline1814\texttt{\symbol{92}}langle&1815\texttt{{\textless}}\\1816\hline1817\texttt{\symbol{92}}ldots&1818\texttt{...}\\1819\hline1820\texttt{\symbol{92}}left&1821\texttt{{\nobreakspace}}\\1822\hline1823\texttt{\symbol{92}}leq&1824\texttt{{\textless}=}\\1825\hline1826\texttt{\symbol{92}}leftarrow&1827\texttt{{\textless}-}\\1828\hline1829\texttt{\symbol{92}}Leftarrow&1830\texttt{{\textless}=}\\1831\hline1832\texttt{\symbol{92}}limits&1833\texttt{{\nobreakspace}}\\1834\hline1835\texttt{\symbol{92}}longrightarrow&1836\texttt{--{\textgreater}}\\1837\hline1838\texttt{\symbol{92}}Longrightarrow&1839\texttt{=={\textgreater}}\\1840\hline1841\texttt{\symbol{92}}mapsto&1842\texttt{-{\textgreater}}\\1843\hline1844\texttt{\symbol{92}}mathbb&1845\texttt{{\nobreakspace}}\\1846\hline1847\texttt{\symbol{92}}mathop&1848\texttt{{\nobreakspace}}\\1849\hline1850\texttt{\symbol{92}}mid&1851\texttt{|}\\1852\hline1853\texttt{\symbol{92}}pmod&1854\texttt{mod}\\1855\hline1856\texttt{\symbol{92}}prime&1857\texttt{'}\\1858\hline1859\texttt{\symbol{92}}rangle&1860\texttt{{\textgreater}}\\1861\hline1862\texttt{\symbol{92}}right&1863\texttt{{\nobreakspace}}\\1864\hline1865\texttt{\symbol{92}}rightarrow&1866\texttt{-{\textgreater}}\\1867\hline1868\texttt{\symbol{92}}Rightarrow&1869\texttt{={\textgreater}}\\1870\hline1871\texttt{\symbol{92}}rm, \texttt{\symbol{92}}sf, \texttt{\symbol{92}}textrm,1872\texttt{\symbol{92}}text&1873\texttt{}\\1874\hline1875\texttt{\symbol{92}}setminus&1876\texttt{\texttt{\symbol{92}}}\\1877\hline1878\texttt{\symbol{92}}thinspace&1879\texttt{ }\\1880\hline1881\texttt{\symbol{92}}times&1882\texttt{x}\\1883\hline1884\texttt{\symbol{92}}to&1885\texttt{-{\textgreater}}\\1886\hline1887\texttt{\symbol{92}}vert&1888\texttt{|}\\1889\hline1890\texttt{\symbol{92}}!&1891\texttt{}\\1892\hline1893\texttt{\symbol{92}},&1894\texttt{}\\1895\hline1896\texttt{\symbol{92}};&1897\texttt{{\nobreakspace}}\\1898\hline1899\texttt{\symbol{92}}\texttt{\symbol{123}}&1900\texttt{\texttt{\symbol{123}}}\\1901\hline1902\texttt{\symbol{92}}\texttt{\symbol{125}}&1903\texttt{\texttt{\symbol{125}}}\\1904\hline1905\end{tabular}\\[2mm]1906\textbf{Table: }{\LaTeX} macros with special text translation\end{center}19071908In all other macros only the backslash is removed (except for some macros1909describing more exotic symbols). Whitespace is normalized (to one blank) but1910not removed. Note that whitespace is not added, so you may want to add a few1911more spaces than you usually do in your {\LaTeX} documents.19121913Braces \texttt{\texttt{\symbol{123}}\texttt{\symbol{125}}} are removed in general, however pairs of double braces are converted to one1914pair of braces. This can be used to write \texttt{{\textless}M{\textgreater}x\texttt{\symbol{94}}\texttt{\symbol{123}}12\texttt{\symbol{125}}{\textless}/M{\textgreater}} for \texttt{x\texttt{\symbol{94}}12} and \texttt{{\textless}M{\textgreater}x{\textunderscore}\texttt{\symbol{123}}\texttt{\symbol{123}}i+1\texttt{\symbol{125}}\texttt{\symbol{125}}{\textless}/M{\textgreater}} for \texttt{x{\textunderscore}\texttt{\symbol{123}}i+1\texttt{\symbol{125}}}.19151916}19171918}191919201921\section{\textcolor{Chapter }{Everything else}}\label{sec:misc}1922\logpage{[ 3, 9, 0 ]}1923\hyperdef{L}{X7A0D26B180BEDE37}{}1924{19251926\subsection{\textcolor{Chapter }{\texttt{{\textless}Alt{\textgreater}}}}\label{Alt}1927\logpage{[ 3, 9, 1 ]}1928\hyperdef{L}{X850E69017945AE3E}{}1929{1930\index{Alt@\texttt{Alt}} This element is used to specify alternatives for different output formats1931within normal text. See also sections \ref{List}, \ref{Enum}, and \ref{Table} for alternatives in lists and tables.1932\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1933<!ELEMENT Alt (%InnerText;)*> <!-- This is only to allow "Only" and1934"Not" attributes for normal text -->1935<!ATTLIST Alt Only CDATA #IMPLIED1936Not CDATA #IMPLIED>1937\end{Verbatim}1938Of course exactly one of the two attributes must occur in one element. The1939attribute values must be one word or a list of words, separated by spaces or1940commas. The words which are currently recognized by the converter programs1941contained in \textsf{GAPDoc} are: ``\texttt{LaTeX}'', ``\texttt{HTML}'', and ``\texttt{Text}''. If the \texttt{Only} attribute is specified then only the corresponding converter will include the1942content of the element into the output document. If the \texttt{Not} attribute is specified the corresponding converter will ignore the content of1943the element. You can use other words to specify special alternatives for other1944converters of \textsf{GAPDoc} documents.19451946In the case of ``\texttt{HTML}'' there is a second word which is recognized and this can either be ``\texttt{MathJax}'' or ``\texttt{noMathJax}''. For example a pair of \texttt{Alt} elements with \texttt{{\textless}Alt Only="HTML noMathJax"{\textgreater}...} and \texttt{{\textless}Alt Not="HTML noMathJax"{\textgreater}...} could provide special content for the case of HTML output without use of \textsf{MathJax} and every other output.19471948We fix a rule for handling the content of an \texttt{Alt} element with \texttt{Only} attribute. In their content code for the corresponding output format is1949included directly. So, in case of HTML the content is HTML code, in case of {\LaTeX} the content is {\LaTeX} code. The converters don't apply any handling of special characters to this1950content. In the case of {\LaTeX} the formatting of the code is not changed.19511952Within the element only \texttt{\%InnerText;} (see \ref{InnerText}) is allowed. This is to ensure that the same set of chapters, sections, and1953subsections show up in all output formats. }195419551956\subsection{\textcolor{Chapter }{\texttt{{\textless}Par{\textgreater}} and \texttt{{\textless}P{\textgreater}}}}\label{Par}1957\logpage{[ 3, 9, 2 ]}1958\hyperdef{L}{X85D23A648444069F}{}1959{1960\index{Par@\texttt{Par}} \index{P@\texttt{P}}1961\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1962<!ELEMENT Par EMPTY> <!-- this is intentionally empty! -->1963<!ELEMENT P EMPTY> <!-- the same as shortcut -->1964\end{Verbatim}1965This \texttt{EMPTY} element marks the boundary of paragraphs. Note that an empty line in the input1966does not mark a new paragraph as opposed to the {\LaTeX} convention.19671968(Remark: it would be much easier to parse a document and to understand its1969sectioning and paragraph structure when there was an element whose \emph{content} is the text of a paragraph. But in practice many paragraph boundaries are1970implicitly clear which would make it somewhat painful to enclose each1971paragraph in extra tags. The introduction of the \texttt{P} or \texttt{Par} elements as above delegates this pain to the writer of a conversion program1972for \textsf{GAPDoc} documents.) }197319741975\subsection{\textcolor{Chapter }{\texttt{{\textless}Br{\textgreater}}}}\label{Br}1976\logpage{[ 3, 9, 3 ]}1977\hyperdef{L}{X7A3EF0647B10C1EC}{}1978{1979\index{Br@\texttt{Br}}1980\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1981<!ELEMENT Br EMPTY> <!-- a forced line break -->1982\end{Verbatim}1983This element can be used to force a line break in the output versions of a \textsf{GAPDoc} element, it does not start a new paragraph. Please, do not use this instead of1984a \texttt{Par} element, this would often lead to ugly output versions of your document. }198519861987\subsection{\textcolor{Chapter }{\texttt{{\textless}Ignore{\textgreater}}}}\label{Ignore}1988\logpage{[ 3, 9, 4 ]}1989\hyperdef{L}{X7A81FB717A30B485}{}1990{1991\index{Ignore@\texttt{Ignore}}1992\begin{Verbatim}[fontsize=\small,frame=single,label=From gapdoc.dtd]1993<!ELEMENT Ignore (%Text;| Chapter | Section | Subsection | ManSection |1994Heading)*>1995<!ATTLIST Ignore Remark CDATA #IMPLIED>1996\end{Verbatim}1997This element can appear anywhere. Its content is ignored by the standard1998converters. It can be used, for example, to include data which are not part of1999the actual \textsf{GAPDoc} document, like source code, or to make not finished parts of the document2000invisible.20012002Of course, one can use special converter programs which extract the contents2003of \texttt{Ignore} elements. Information on the type of the content can be stored in the optional2004attribute \texttt{Remark}. }20052006}20072008}200920102011\chapter{\textcolor{Chapter }{Distributing a Document into Several Files}}\label{Distributing}2012\logpage{[ 4, 0, 0 ]}2013\hyperdef{L}{X7A3355C07F57C280}{}2014{2015In \textsf{GAPDoc} there are facilities to distribute a single document over several files. This2016is for example interesting, if one wants to store the documentation of some2017code in the same file as the code itself. Or, if one just wants to store2018chapters of a document in separate files. There is a set of conventions how2019this is done and some tools to collect the text for further processing.20202021The technique can also be used to distribute and collect other types of2022documents into respectively from several files (e.g., source code, examples).202320242025\section{\textcolor{Chapter }{The Conventions}}\label{DistrConv}2026\logpage{[ 4, 1, 0 ]}2027\hyperdef{L}{X7CE078A07E8256DC}{}2028{2029\index{Include@\texttt{{\textless}\#Include{\textgreater}}} \index{GAPDoc@\texttt{{\textless}\#GAPDoc{\textgreater}}} In this description we use the string \texttt{GAPDoc} for marking pieces of a document to collect.20302031Pieces of documentation that shall be incorporated into another document are2032marked as follows:2033\begin{Verbatim}[fontsize=\small,frame=single,label=Example]2034## <#GAPDoc Label="MyPiece">2035## <E>This</E> is the piece.2036## The hash characters are removed.2037## <#/GAPDoc>2038\end{Verbatim}2039This piece is then included into another file by a statement like: \texttt{{\textless}\#Include Label="MyPiece"{\textgreater}} Here are the exact rules, how pieces are gathered:2040\begin{itemize}2041\item All lines up to a line containing the character sequence ``\texttt{{\textless}\#GAPDoc{\nobreakspace}Label="}'' (exactly one space character) are ignored. The characters on the same line2042before this sequence are stored as ``prefix''. The characters after the sequence up to the next double quotes character2043(which should not contain whitespace) are stored as ``label''. All other characters in the line are ignored.2044\item The following lines up to a line containing the character sequence ``\texttt{{\textless}\#/GAPDoc{\textgreater}}'' are stored under the label. These lines are processed as follows: The longest2045possible substring from the beginning of the line that equals the2046corresponding substring of the prefix is removed.2047\end{itemize}2048Having stored a list of labels and pieces of text gathered as above this can2049be used as follows.2050\begin{itemize}2051\item In \textsf{GAPDoc} documentation files all statements of the form ``\texttt{{\textless}\#Include Label="Key"{\textgreater}}'' are replaced by the sequence of lines stored under the label \texttt{Key}.2052\item Additionally, every occurrence of a statement of the form ``\texttt{{\textless}\#Include SYSTEM "Filename"{\textgreater}}'' is replaced by the whole file stored under the name \texttt{Filename} in the file system.2053\item These substitutions are done recursively (although one should probably avoid2054to use this extensively).2055\end{itemize}2056Here is another example:2057\begin{Verbatim}[fontsize=\small,frame=single,label=Example]2058# # <#GAPDoc Label="AnotherPiece"> some characters2059# # This text is not indented.2060# This text is indented by one blank.2061#Not indented.2062#<#/GAPDoc>2063\end{Verbatim}2064replaces \texttt{{\textless}\#Include Label="AnotherPiece"{\textgreater}} by2065\begin{Verbatim}[fontsize=\small,frame=single,label=Example]2066This text is not indented.2067This text is indented by one blank.2068Not indented.2069\end{Verbatim}2070Since these rules are very simple it is quite easy to write a program in2071almost any programming language which does this gathering of text pieces and2072the substitutions. In \textsf{GAPDoc} there is the \textsf{GAP} function \texttt{ComposedDocument} (\ref{ComposedDocument}) which does this.20732074Note that the XML-tag-like markup we have used here is not a legal XML markup,2075since the hash character is not allowed in element names. The mechanism2076described here is a preprocessing step which composes a document. }207720782079\section{\textcolor{Chapter }{A Tool for Collecting a Document}}\logpage{[ 4, 2, 0 ]}2080\hyperdef{L}{X81E07B0F83EBDA5F}{}2081{208220832084\subsection{\textcolor{Chapter }{ComposedDocument}}2085\logpage{[ 4, 2, 1 ]}\nobreak2086\hyperdef{L}{X857D77557D12559D}{}2087{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ComposedDocument({\mdseries\slshape tagname, path, main, source[, info]})\index{ComposedDocument@\texttt{ComposedDocument}}2088\label{ComposedDocument}2089}\hfill{\scriptsize (function)}}\\2090\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ComposedXMLString({\mdseries\slshape path, main, source[, info]})\index{ComposedXMLString@\texttt{ComposedXMLString}}2091\label{ComposedXMLString}2092}\hfill{\scriptsize (function)}}\\2093\textbf{\indent Returns:\ }2094a document as string, or a list with this string and information about the2095source positions2096209720982099The argument \mbox{\texttt{\mdseries\slshape tagname}} is the string used for the pseudo elements which mark the pieces of a document2100to collect. (In \ref{DistrConv} we used \texttt{GAPDoc} as \mbox{\texttt{\mdseries\slshape tagname}}. The second function \texttt{ComposedXMLString}\texttt{( ... )} is an abbreviation for \texttt{ComposedDocument}\texttt{("GAPDoc", ... )}.21012102The argument \mbox{\texttt{\mdseries\slshape path}} must be a path to some directory (as string or directory object), \mbox{\texttt{\mdseries\slshape main}} the name of a file and \mbox{\texttt{\mdseries\slshape source}} a list of file names. These file names are relative to \mbox{\texttt{\mdseries\slshape path}}, except they start with \texttt{"/"} to specify an absolute path or they start with \texttt{"gap://"} to specify a file relative to the \textsf{GAP} roots (see \texttt{FilenameGAP} (\ref{FilenameGAP})). The document is constructed via the mechanism described in2103Section{\nobreakspace}\ref{DistrConv}.21042105First the files given in \mbox{\texttt{\mdseries\slshape source}} are scanned for chunks of the document marked by \texttt{{\textless}\#\mbox{\texttt{\mdseries\slshape tagname}} Label="..."{\textgreater}} and \texttt{{\textless}/\#\mbox{\texttt{\mdseries\slshape tagname}}{\textgreater}} pairs. Then the file \mbox{\texttt{\mdseries\slshape main}} is read and all \texttt{{\textless}\#Include ... {\textgreater}}-tags are substituted recursively by other files or chunks of documentation2106found in the first step, respectively.21072108If the optional argument \mbox{\texttt{\mdseries\slshape info}} is given and set to \texttt{true} this function returns a list \texttt{[str, origin]}, where \texttt{str} is a string containing the composed document and \texttt{origin} is a sorted list of entries of the form \texttt{[pos, filename, line]}. Here \texttt{pos} runs through all character positions of starting lines or text pieces from2109different files in \texttt{str}. The \texttt{filename} and \texttt{line} describe the origin of this part of the collected document.21102111Without the fourth argument only the string \texttt{str} is returned.21122113By default \texttt{ComposedDocument} runs into an error if an \texttt{{\textless}\#Include ...{\textgreater}}-tag cannot be substituted (because a file or chunk is missing). This2114behaviour can be changed by setting \texttt{DOCCOMPOSEERROR := false;}. Then the missing parts are substituted by a short note about what is2115missing. Of course, this feature is only useful if the resulting document is a2116valid XML document (e.g., when the missing pieces are complete paragraphs or2117sections).211821192120\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2121!gapprompt@gap>| !gapinput@doc := ComposedDocument("GAPDoc", "/my/dir", "manual.xml", |2122!gapprompt@>| !gapinput@["../lib/func.gd", "../lib/func.gi"], true);;|2123\end{Verbatim}2124}2125212621272128\subsection{\textcolor{Chapter }{OriginalPositionDocument}}2129\logpage{[ 4, 2, 2 ]}\nobreak2130\hyperdef{L}{X86D1141E7EDCAAC8}{}2131{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{OriginalPositionDocument({\mdseries\slshape srcinfo, pos})\index{OriginalPositionDocument@\texttt{OriginalPositionDocument}}2132\label{OriginalPositionDocument}2133}\hfill{\scriptsize (function)}}\\2134\textbf{\indent Returns:\ }2135A pair \texttt{[filename, linenumber]}.2136213721382139Here \mbox{\texttt{\mdseries\slshape srcinfo}} must be a data structure as returned as second entry by \texttt{ComposedDocument} (\ref{ComposedDocument}) called with \mbox{\texttt{\mdseries\slshape info}}=\texttt{true}. It returns for a given position \mbox{\texttt{\mdseries\slshape pos}} in the composed document the file name and line number from which that text2140was collected. }2141214221432144\subsection{\textcolor{Chapter }{FilenameGAP}}2145\logpage{[ 4, 2, 3 ]}\nobreak2146\hyperdef{L}{X81E67E4678FB6843}{}2147{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{FilenameGAP({\mdseries\slshape fname})\index{FilenameGAP@\texttt{FilenameGAP}}2148\label{FilenameGAP}2149}\hfill{\scriptsize (function)}}\\2150\textbf{\indent Returns:\ }2151file name as string or fail2152215321542155This functions returns the full path of a file with name \mbox{\texttt{\mdseries\slshape fname}} relative to a \textsf{GAP} root path, or \texttt{fail} if such a file does not exist. The argument \mbox{\texttt{\mdseries\slshape fname}} can optionally start with the prefix \texttt{"gap://"} which will be removed.2156\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2157!gapprompt@gap>| !gapinput@FilenameGAP("hsdkfhs.g");|2158fail2159!gapprompt@gap>| !gapinput@FilenameGAP("lib/system.g");|2160"/usr/local/gap4/lib/system.g"2161!gapprompt@gap>| !gapinput@FilenameGAP("gap://lib/system.g");|2162"/usr/local/gap4/lib/system.g"2163\end{Verbatim}2164}21652166}21672168}216921702171\chapter{\textcolor{Chapter }{The Converters and an XML Parser}}\label{ch:conv}2172\logpage{[ 5, 0, 0 ]}2173\hyperdef{L}{X845E7FDC7C082CC4}{}2174{2175The \textsf{GAPDoc} package contains a set of programs which allow us to convert a \textsf{GAPDoc} book into several output versions and to make them available to \textsf{GAP}'s online help.21762177Currently the following output formats are provided: text for browsing inside2178a terminal running \textsf{GAP}, {\LaTeX} with \texttt{hyperref}-package for cross references via hyperlinks and HTML for reading with a2179Web-browser.218021812182\section{\textcolor{Chapter }{Producing Documentation from Source Files}}\label{MakeDoc}2183\logpage{[ 5, 1, 0 ]}2184\hyperdef{L}{X7D1BB5867C13FA14}{}2185{2186Here we explain how to use the functions which are described in more detail in2187the following sections. We assume that we have the main file \texttt{MyBook.xml} of a book \texttt{"MyBook"} in the directory \texttt{/my/book/path}. This contains \texttt{{\textless}\#Include ...{\textgreater}}-statements as explained in Chapter{\nobreakspace}\ref{Distributing}. These refer to some other files as well as pieces of text which are found in2188the comments of some \textsf{GAP} source files \texttt{../lib/a.gd} and \texttt{../lib/b.gi} (relative to the path above). A Bib{\TeX} database \texttt{MyBook.bib} for the citations is also in the directory given above. We want to produce a2189text-, \texttt{pdf-} and HTML-version of the document. (A {\LaTeX} version of the manual is produced, so it is also easy to compile \texttt{dvi}-, and postscript-versions.)21902191All the commands shown in this Section are collected in the single function \texttt{MakeGAPDocDoc} (\ref{MakeGAPDocDoc}).21922193First we construct the complete XML-document as a string with \texttt{ComposedDocument} (\ref{ComposedDocument}). This interprets recursively the \texttt{{\textless}\#Include ...{\textgreater}}-statements.2194\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2195!gapprompt@gap>| !gapinput@path := Directory("/my/book/path");;|2196!gapprompt@gap>| !gapinput@main := "MyBook.xml";;|2197!gapprompt@gap>| !gapinput@files := ["../lib/a.gd", "../lib/b.gi"];;|2198!gapprompt@gap>| !gapinput@bookname := "MyBook";;|2199!gapprompt@gap>| !gapinput@doc := ComposedDocument("GAPDoc", path, main, files, true);;|2200\end{Verbatim}2201Now \texttt{doc} is a list with two entries, the first is a string containing the XML-document,2202the second gives information from which files and locations which part of the2203document was collected. This is useful in the next step, if there are any2204errors in the document.22052206Next we parse the document and store its structure in a tree-like data2207structure. The commands for this are \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) and \texttt{CheckAndCleanGapDocTree} (\ref{CheckAndCleanGapDocTree}).2208\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2209!gapprompt@gap>| !gapinput@r := ParseTreeXMLString(doc[1], doc[2]);;|2210!gapprompt@gap>| !gapinput@CheckAndCleanGapDocTree(r);|2211true2212\end{Verbatim}2213We start to produce a text version of the manual, which can be read in a2214terminal (window). The command is \texttt{GAPDoc2Text} (\ref{GAPDoc2Text}). This produces a record with the actual text and some additional information.2215The text can be written chapter-wise into files with \texttt{GAPDoc2TextPrintTextFiles} (\ref{GAPDoc2TextPrintTextFiles}). The names of these files are \texttt{chap0.txt}, \texttt{chap1.txt} and so on. The text contains some markup using ANSI escape sequences. This2216markup is substituted by the \textsf{GAP} help system (user configurable) to show the text with colors and other2217attributes. For the bibliography we have to tell \texttt{GAPDoc2Text} (\ref{GAPDoc2Text}) the location of the Bib{\TeX} database by specifying a \texttt{path} as second argument.2218\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2219!gapprompt@gap>| !gapinput@t := GAPDoc2Text(r, path);;|2220!gapprompt@gap>| !gapinput@GAPDoc2TextPrintTextFiles(t, path);|2221\end{Verbatim}2222This command constructs all parts of the document including table of contents,2223bibliography and index. The functions \texttt{FormatParagraph} (\ref{FormatParagraph}) for formatting text paragraphs and \texttt{ParseBibFiles} (\ref{ParseBibFiles}) for reading Bib{\TeX} files with \textsf{GAP} may be of independent interest.22242225With the text version we have also produced the information which is used for2226searching with \textsf{GAP}'s online help. Also, labels are produced which can be used by links in the2227HTML- and \texttt{pdf}-versions of the manual.22282229Next we produce a {\LaTeX} version of the document. \texttt{GAPDoc2LaTeX} (\ref{GAPDoc2LaTeX}) returns a string containing the {\LaTeX} source. The utility function \texttt{FileString} (\ref{FileString}) writes the content of a string to a file, we choose \texttt{MyBook.tex}.2230\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2231!gapprompt@gap>| !gapinput@l := GAPDoc2LaTeX(r);;|2232!gapprompt@gap>| !gapinput@FileString(Filename(path, Concatenation(bookname, ".tex")), l);|2233\end{Verbatim}2234Assuming that you have a sufficiently good installation of {\TeX} available (see \texttt{GAPDoc2LaTeX} (\ref{GAPDoc2LaTeX}) for details) this can be processed with a series of commands like in the2235following example.2236\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2237cd /my/book/path2238pdflatex MyBook2239bibtex MyBook2240pdflatex MyBook2241makeindex MyBook2242pdflatex MyBook2243mv MyBook.pdf manual.pdf2244\end{Verbatim}2245After this we have a \texttt{pdf}-version of the document in the file \texttt{manual.pdf}. It contains hyperlink information which can be used with appropriate2246browsers for convenient reading of the document on screen (e.g., \texttt{xpdf} is nice because it allows remote calls to display named locations of the2247document). Of course, we could also use other commands like \texttt{latex} or \texttt{dvips} to process the {\LaTeX} source file. Furthermore we have produced a file \texttt{MyBook.pnr} which is \textsf{GAP}-readable and contains the page number information for each (sub-)section of2248the document.22492250We can add this page number information to the indexing information collected2251by the text converter and then print a \texttt{manual.six} file which is read by \textsf{GAP} when the manual is loaded. This is done with \texttt{AddPageNumbersToSix} (\ref{AddPageNumbersToSix}) and \texttt{PrintSixFile} (\ref{PrintSixFile}).2252\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2253!gapprompt@gap>| !gapinput@AddPageNumbersToSix(r, Filename(path, "MyBook.pnr"));|2254!gapprompt@gap>| !gapinput@PrintSixFile(Filename(path, "manual.six"), r, bookname);|2255\end{Verbatim}2256Finally we produce an HTML-version of the document and write it (chapter-wise)2257into files \texttt{chap0.html}, \texttt{chap1.html} and so on. They can be read with any Web-browser. The commands are \texttt{GAPDoc2HTML} (\ref{GAPDoc2HTML}) and \texttt{GAPDoc2HTMLPrintHTMLFiles} (\ref{GAPDoc2HTMLPrintHTMLFiles}). We also add a link from \texttt{manual.html} to \texttt{chap0.html}. You probably want to copy stylesheet files into the same directory, see \ref{StyleSheets} for more details. The argument \texttt{path} of \texttt{GAPDoc2HTML} (\ref{GAPDoc2HTML}) specifies the directory containing the Bib{\TeX} database files.2258\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2259!gapprompt@gap>| !gapinput@h := GAPDoc2HTML(r, path);;|2260!gapprompt@gap>| !gapinput@GAPDoc2HTMLPrintHTMLFiles(h, path);|2261\end{Verbatim}226222632264\subsection{\textcolor{Chapter }{MakeGAPDocDoc}}2265\logpage{[ 5, 1, 1 ]}\nobreak2266\hyperdef{L}{X826F530686F4D052}{}2267{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{MakeGAPDocDoc({\mdseries\slshape path, main, files, bookname[, gaproot]})\index{MakeGAPDocDoc@\texttt{MakeGAPDocDoc}}2268\label{MakeGAPDocDoc}2269}\hfill{\scriptsize (function)}}\\227022712272This function collects all the commands for producing a text-, \texttt{pdf}- and HTML-version of a \textsf{GAPDoc} document as described in Section{\nobreakspace}\ref{MakeDoc}. It checks the \texttt{.log} file from the call of \texttt{pdflatex} and reports if there are errors, warnings or overfull boxes.22732274\emph{Note:} If this function works for you depends on your operating system and installed2275software. It will probably work on most \texttt{UNIX} systems with a standard {\LaTeX} installation. If the function doesn't work for you look at the source code and2276adjust it to your system.22772278Here \mbox{\texttt{\mdseries\slshape path}} must be the directory (as string or directory object) containing the main file \mbox{\texttt{\mdseries\slshape main}} of the document (given with or without the \texttt{.xml} extension. The argument \mbox{\texttt{\mdseries\slshape files}} is a list of (probably source code) files relative to \mbox{\texttt{\mdseries\slshape path}} which contain pieces of documentation which must be included in the document,2279see Chapter{\nobreakspace}\ref{Distributing}. And \mbox{\texttt{\mdseries\slshape bookname}} is the name of the book used by \textsf{GAP}'s online help. The optional argument \mbox{\texttt{\mdseries\slshape gaproot}} must be a string which gives the relative path from \mbox{\texttt{\mdseries\slshape path}} to the main \textsf{GAP} root directory. If this is given, the HTML files are produced with relative2280paths to external books.22812282\index{MathJax@\textsf{MathJax}!in \texttt{MakeGAPDocDoc}} \texttt{MakeGAPDocDoc} can be called with additional arguments \texttt{"MathJax"}, \texttt{"Tth"} and/or \texttt{"MathML"}. If these are given additional variants of the HTML conversion are called,2283see \texttt{GAPDoc2HTML} (\ref{GAPDoc2HTML}) for details.22842285It is possible to use \textsf{GAPDoc} with other languages than English, see \texttt{SetGapDocLanguage} (\ref{SetGapDocLanguage}) for more details.22862287}22882289}229022912292\section{\textcolor{Chapter }{Parsing XML Documents}}\label{ParseXML}2293\logpage{[ 5, 2, 0 ]}2294\hyperdef{L}{X7FE2AF49838D9034}{}2295{2296Arbitrary well-formed XML documents can be parsed and browsed by the following2297functions.22982299\subsection{\textcolor{Chapter }{ParseTreeXMLString}}2300\logpage{[ 5, 2, 1 ]}\nobreak2301\hyperdef{L}{X847EB8498151D443}{}2302{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseTreeXMLString({\mdseries\slshape str[, srcinfo][, entitydict]})\index{ParseTreeXMLString@\texttt{ParseTreeXMLString}}2303\label{ParseTreeXMLString}2304}\hfill{\scriptsize (function)}}\\2305\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseTreeXMLFile({\mdseries\slshape fname[, entitydict]})\index{ParseTreeXMLFile@\texttt{ParseTreeXMLFile}}2306\label{ParseTreeXMLFile}2307}\hfill{\scriptsize (function)}}\\2308\textbf{\indent Returns:\ }2309a record which is root of a tree structure2310231123122313The first function parses an XML-document stored in string \mbox{\texttt{\mdseries\slshape str}} and returns the document in form of a tree.23142315The optional argument \mbox{\texttt{\mdseries\slshape srcinfo}} must have the same format as in \texttt{OriginalPositionDocument} (\ref{OriginalPositionDocument}). If it is given then error messages refer to the original source of the text2316with the problem.23172318With the optional argument \mbox{\texttt{\mdseries\slshape entitydict}} named entities can be given to the parser, for example entities which are2319defined in the \texttt{.dtd}-file (which is not read by this parser). The standard XML-entities do not2320need to be provided, and for \textsf{GAPDoc} documents the entity definitions from \texttt{gapdoc.dtd} are automatically provided. Entities in the document's \texttt{{\textless}!DOCTYPE} declaration are parsed and also need not to be provided here. The argument \mbox{\texttt{\mdseries\slshape entitydict}} must be a record where each component name is an entity name (without the2321surrounding \& and ;) to which is assigned its substitution string.23222323The second function is just a shortcut for \texttt{ParseTreeXMLString( StringFile(}\mbox{\texttt{\mdseries\slshape fname}}\texttt{), ... )}, see \texttt{StringFile} (\ref{StringFile}).23242325After these functions return the list of named entities which were known2326during the parsing can be found in the record \texttt{ENTITYDICT}.23272328A node in the result tree corresponds to an XML element, or to some parsed2329character data. In the first case it looks as follows:2330\begin{Verbatim}[fontsize=\small,frame=single,label=Example Node]2331rec( name := "Book",2332attributes := rec( Name := "EDIM" ),2333content := [ ... list of nodes for content ...],2334start := 312,2335stop := 15610,2336next := 15611 )2337\end{Verbatim}2338This means that \texttt{\mbox{\texttt{\mdseries\slshape str}}\texttt{\symbol{123}}[312..15610]\texttt{\symbol{125}}} looks like \texttt{{\textless}Book Name="EDIM"{\textgreater} ... content ...2339{\textless}/Book{\textgreater}}.23402341The leaves of the tree encode parsed character data as in the following2342example:2343\begin{Verbatim}[fontsize=\small,frame=single,label=Example Node]2344rec( name := "PCDATA",2345content := "text without markup " )2346\end{Verbatim}2347This function checks whether the XML document is \emph{well formed}, see \ref{XMLvalid} for an explanation. If an error in the XML structure is found, a break loop is2348entered and the text around the position where the problem starts is shown.2349With \texttt{Show();} one can browse the original input in the \texttt{Pager} (\textbf{Reference: Pager}), starting with the line where the error occurred. All entities are resolved2350when they are either entities defined in the \textsf{GAPDoc} package (in particular the standard XML entities) or if their definition is2351included in the \texttt{{\textless}!DOCTYPE ..{\textgreater}} tag of the document.23522353Note that \texttt{ParseTreeXMLString} does not parse and interpret the corresponding document type definition (the \texttt{.dtd}-file given in the \texttt{{\textless}!DOCTYPE ..{\textgreater}} tag). Hence it also does not check the \emph{validity} of the document (i.e., it is no \emph{validating XML parser}).23542355If you are using this function to parse a \textsf{GAPDoc} document you can use \texttt{CheckAndCleanGapDocTree} (\ref{CheckAndCleanGapDocTree}) for some validation and additional checking of the document structure. }2356235723582359\subsection{\textcolor{Chapter }{StringXMLElement}}2360\logpage{[ 5, 2, 2 ]}\nobreak2361\hyperdef{L}{X835887057D0B4DA8}{}2362{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringXMLElement({\mdseries\slshape tree})\index{StringXMLElement@\texttt{StringXMLElement}}2363\label{StringXMLElement}2364}\hfill{\scriptsize (function)}}\\2365\textbf{\indent Returns:\ }2366a list \texttt{[string, positions]}2367236823692370The argument \mbox{\texttt{\mdseries\slshape tree}} must have a format of a node in the parse tree of an XML document as returned2371by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) (including the root node representing the full document). This function2372computes a pair \texttt{[string, positions]} where \texttt{string} contains XML code which is equivalent to the code which was parsed to get \mbox{\texttt{\mdseries\slshape tree}}. And \texttt{positions} is a list of lists of four numbers \texttt{[eltb, elte, contb, conte]}. There is one such list for each XML element occuring in \texttt{string}, where \texttt{eltb} and \texttt{elte} are the begin and end position of this element in \texttt{string} and where \texttt{contb} and \texttt{conte} are begin and end position of the content of this element, or both are \texttt{0} if there is no content.23732374Note that parsing XML code is an irreversible task, we can only expect to get2375equivalent XML code from this function. But parsing the resulting \texttt{string} again and applying \texttt{StringXMLElement} again gives the same result. See the function \texttt{EntitySubstitution} (\ref{EntitySubstitution}) for back-substitutions of entities in the result. }2376237723782379\subsection{\textcolor{Chapter }{EntitySubstitution}}2380\logpage{[ 5, 2, 3 ]}\nobreak2381\hyperdef{L}{X786827BF793191B3}{}2382{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{EntitySubstitution({\mdseries\slshape xmlstring, entities})\index{EntitySubstitution@\texttt{EntitySubstitution}}2383\label{EntitySubstitution}2384}\hfill{\scriptsize (function)}}\\2385\textbf{\indent Returns:\ }2386a string2387238823892390The argument \mbox{\texttt{\mdseries\slshape xmlstring}} must be a string containing XML code or a pair \texttt{[string, positions]} as returned by \texttt{StringXMLElement} (\ref{StringXMLElement}). The argument \mbox{\texttt{\mdseries\slshape entities}} specifies entity names (without the surrounding \mbox{\texttt{\mdseries\slshape \&}} and \texttt{;}) and their substitution strings, either a list of pairs of strings or as a2391record with the names as components and the substitutions as values.23922393This function tries to substitute non-intersecting parts of \texttt{string} by the given entities. If the \texttt{positions} information is given then only parts of the document which allow a valid2394substitution by an entity are considered. Otherwise a simple text substitution2395without further check is done.23962397Note that in general the entity resolution in XML documents is a complicated2398and non-reversible task. But nevertheless this utility may be useful in not2399too complicated situations. }2400240124022403\subsection{\textcolor{Chapter }{DisplayXMLStructure}}2404\logpage{[ 5, 2, 4 ]}\nobreak2405\hyperdef{L}{X86589C5C859ACE38}{}2406{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{DisplayXMLStructure({\mdseries\slshape tree})\index{DisplayXMLStructure@\texttt{DisplayXMLStructure}}2407\label{DisplayXMLStructure}2408}\hfill{\scriptsize (function)}}\\240924102411This utility displays the tree structure of an XML document as it is returned2412by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) (without the \texttt{PCDATA} leaves).24132414Since this is usually quite long the result is shown using the \texttt{Pager} (\textbf{Reference: Pager}). }2415241624172418\subsection{\textcolor{Chapter }{ApplyToNodesParseTree}}2419\logpage{[ 5, 2, 5 ]}\nobreak2420\hyperdef{L}{X7A7B223A83E38B40}{}2421{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ApplyToNodesParseTree({\mdseries\slshape tree, fun})\index{ApplyToNodesParseTree@\texttt{ApplyToNodesParseTree}}2422\label{ApplyToNodesParseTree}2423}\hfill{\scriptsize (function)}}\\2424\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{AddRootParseTree({\mdseries\slshape tree})\index{AddRootParseTree@\texttt{AddRootParseTree}}2425\label{AddRootParseTree}2426}\hfill{\scriptsize (function)}}\\2427\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{RemoveRootParseTree({\mdseries\slshape tree})\index{RemoveRootParseTree@\texttt{RemoveRootParseTree}}2428\label{RemoveRootParseTree}2429}\hfill{\scriptsize (function)}}\\243024312432The function \texttt{ApplyToNodesParseTree} applies a function \mbox{\texttt{\mdseries\slshape fun}} to all nodes of the parse tree \mbox{\texttt{\mdseries\slshape tree}} of an XML document returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}).24332434The function \texttt{AddRootParseTree} is an application of this. It adds to all nodes a component \texttt{.root} to which the top node tree \mbox{\texttt{\mdseries\slshape tree}} is assigned. These components can be removed afterwards with \texttt{RemoveRootParseTree}. }24352436Here are two more utilities which use \texttt{ApplyToNodesParseTree} (\ref{ApplyToNodesParseTree}).24372438\subsection{\textcolor{Chapter }{GetTextXMLTree}}2439\logpage{[ 5, 2, 6 ]}\nobreak2440\hyperdef{L}{X7F76D4A27C7FB946}{}2441{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GetTextXMLTree({\mdseries\slshape tree})\index{GetTextXMLTree@\texttt{GetTextXMLTree}}2442\label{GetTextXMLTree}2443}\hfill{\scriptsize (function)}}\\2444\textbf{\indent Returns:\ }2445a string2446244724482449The argument \mbox{\texttt{\mdseries\slshape tree}} must be a node of a parse tree of some XML document, see \texttt{ParseTreeXMLFile} (\ref{ParseTreeXMLFile}). This function collects the content of this and all included elements2450recursively into a string. }2451245224532454\subsection{\textcolor{Chapter }{XMLElements}}2455\logpage{[ 5, 2, 7 ]}\nobreak2456\hyperdef{L}{X8466F74C80442F7D}{}2457{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{XMLElements({\mdseries\slshape tree, eltnames})\index{XMLElements@\texttt{XMLElements}}2458\label{XMLElements}2459}\hfill{\scriptsize (function)}}\\2460\textbf{\indent Returns:\ }2461a list of nodes2462246324642465The argument \mbox{\texttt{\mdseries\slshape tree}} must be a node of a parse tree of some XML document, see \texttt{ParseTreeXMLFile} (\ref{ParseTreeXMLFile}). This function returns a list of all subnodes of \mbox{\texttt{\mdseries\slshape tree}} (possibly including \mbox{\texttt{\mdseries\slshape tree}}) of elements with name given in the list of strings \mbox{\texttt{\mdseries\slshape eltnames}}. Use \texttt{"PCDATA"} as name for leave nodes which contain the actual text of the document. As an2466abbreviation \mbox{\texttt{\mdseries\slshape eltnames}} can also be a string which is then put in a one element list. }24672468And here are utilities for processing \textsf{GAPDoc} XML documents.24692470\subsection{\textcolor{Chapter }{CheckAndCleanGapDocTree}}2471\logpage{[ 5, 2, 8 ]}\nobreak2472\hyperdef{L}{X84CFF72484B19C0D}{}2473{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{CheckAndCleanGapDocTree({\mdseries\slshape tree})\index{CheckAndCleanGapDocTree@\texttt{CheckAndCleanGapDocTree}}2474\label{CheckAndCleanGapDocTree}2475}\hfill{\scriptsize (function)}}\\2476\textbf{\indent Returns:\ }2477nothing2478247924802481The argument \mbox{\texttt{\mdseries\slshape tree}} of this function is a parse tree from \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) of some \textsf{GAPDoc} document. This function does an (incomplete) validity check of the document2482according to the document type declaration in \texttt{gapdoc.dtd}. It also does some additional checks which cannot be described in the DTD2483(like checking whether chapters and sections have a heading). For elements2484with element content the whitespace between these elements is removed.24852486In case of an error the break loop is entered and the position of the error in2487the original XML document is printed. With \texttt{Show();} one can browse the original input in the \texttt{Pager} (\textbf{Reference: Pager}). }2488248924902491\subsection{\textcolor{Chapter }{AddParagraphNumbersGapDocTree}}2492\logpage{[ 5, 2, 9 ]}\nobreak2493\hyperdef{L}{X84062CD67B286FF0}{}2494{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{AddParagraphNumbersGapDocTree({\mdseries\slshape tree})\index{AddParagraphNumbersGapDocTree@\texttt{AddParagraphNumbersGapDocTree}}2495\label{AddParagraphNumbersGapDocTree}2496}\hfill{\scriptsize (function)}}\\2497\textbf{\indent Returns:\ }2498nothing2499250025012502The argument \mbox{\texttt{\mdseries\slshape tree}} must be an XML tree returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) applied to a \textsf{GAPDoc} document. This function adds to each node of the tree a component \texttt{.count} which is of form \texttt{[Chapter[, Section[, Subsection, Paragraph] ] ]}. Here the first three numbers should be the same as produced by the {\LaTeX} version of the document. Text before the first chapter is counted as chapter \texttt{0} and similarly for sections and subsections. Some elements are always2503considered to start a new paragraph. }2504250525062507\subsection{\textcolor{Chapter }{InfoXMLParser}}2508\logpage{[ 5, 2, 10 ]}\nobreak2509\hyperdef{L}{X78A22C58841E5D0B}{}2510{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{InfoXMLParser\index{InfoXMLParser@\texttt{InfoXMLParser}}2511\label{InfoXMLParser}2512}\hfill{\scriptsize (info class)}}\\251325142515The default level of this info class is 1. Functions like \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) are then printing some information, in particular in case of errors. You can2516suppress it by setting the level of \texttt{InfoXMLParser} to 0. With level 2 there may be some more information for debugging purposes. }25172518}251925202521\section{\textcolor{Chapter }{The Converters}}\label{Converters}2522\logpage{[ 5, 3, 0 ]}2523\hyperdef{L}{X8560E1A2845EC2C1}{}2524{2525Here are more details about the conversion programs for \textsf{GAPDoc} XML documents.25262527\subsection{\textcolor{Chapter }{GAPDoc2LaTeX}}2528\logpage{[ 5, 3, 1 ]}\nobreak2529\hyperdef{L}{X85BE6DF178423EF5}{}2530{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GAPDoc2LaTeX({\mdseries\slshape tree})\index{GAPDoc2LaTeX@\texttt{GAPDoc2LaTeX}}2531\label{GAPDoc2LaTeX}2532}\hfill{\scriptsize (function)}}\\2533\textbf{\indent Returns:\ }2534{\LaTeX} document as string25352536\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SetGapDocLaTeXOptions({\mdseries\slshape [...]})\index{SetGapDocLaTeXOptions@\texttt{SetGapDocLaTeXOptions}}2537\label{SetGapDocLaTeXOptions}2538}\hfill{\scriptsize (function)}}\\2539\textbf{\indent Returns:\ }2540Nothing2541254225432544The argument \mbox{\texttt{\mdseries\slshape tree}} for this function is a tree describing a \textsf{GAPDoc} XML document as returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) (probably also checked with \texttt{CheckAndCleanGapDocTree} (\ref{CheckAndCleanGapDocTree})). The output is a string containing a version of the document which can be2545written to a file and processed with {\LaTeX} or pdf{\LaTeX} (and probably Bib{\TeX} and \texttt{makeindex}).25462547The output uses the \texttt{report} document class and needs the following {\LaTeX} packages: \texttt{a4wide}, \texttt{amssymb}, \texttt{inputenc}, \texttt{makeidx}, \texttt{color}, \texttt{fancyvrb}, \texttt{psnfss}, \texttt{pslatex}, \texttt{enumitem} and \texttt{hyperref}. These are for example provided by the \textsf{teTeX-1.0} or \textsf{texlive} distributions of {\TeX} (which in turn are used for most {\TeX} packages of current Linux distributions); see \href{http://www.tug.org/tetex/} {\texttt{http://www.tug.org/tetex/}}.25482549In particular, the resulting \texttt{pdf}-output (and \texttt{dvi}-output) contains (internal and external) hyperlinks which can be very useful2550for onscreen browsing of the document.25512552The {\LaTeX} processing also produces a file with extension \texttt{.pnr} which is \textsf{GAP} readable and contains the page numbers for all (sub)sections of the document.2553This can be used by \textsf{GAP}'s online help; see \texttt{AddPageNumbersToSix} (\ref{AddPageNumbersToSix}). Non-ASCII characters in the \textsf{GAPDoc} document are translated to {\LaTeX} input in ASCII-encoding with the help of \texttt{Encode} (\ref{Encode}) and the option \texttt{"LaTeX"}. See the documentation of \texttt{Encode} (\ref{Encode}) for how to proceed if you have a character which is not handled (yet).25542555This function works by running recursively through the document tree and2556calling a handler function for each \textsf{GAPDoc} XML element. Many of these handler functions (usually in \texttt{GAPDoc2LaTeXProcs.{\textless}ElementName{\textgreater}}) are not difficult to understand (the greatest complications are some2557commands for index entries, labels or the output of page number information).2558So it should be easy to adjust layout details to your own taste by slight2559modifications of the program.25602561Former versions of \textsf{GAPDoc} supported some XML processing instructions to add some extra lines to the2562preamble of the {\LaTeX} document. Its use is now deprecated, use the much more flexible \texttt{SetGapDocLaTeXOptions} instead: The default layout of the resulting documents can be changed with \texttt{SetGapDocLaTeXOptions}. This changes parts of the header of the {\LaTeX} file produced by \textsf{GAPDoc}. You can see the header with some placeholders by \texttt{Page(GAPDoc2LaTeXProcs.Head);}. The placeholders are filled with components from the record \texttt{GAPDoc2LaTeXProcs.DefaultOptions}. The arguments of \texttt{SetGapDocLaTeXOptions} can be records with the same structure (or parts of it) with different values.2563As abbreviations there are also three strings supported as arguments. These2564are \texttt{"nocolor"} for switching all colors to black; then \texttt{"nopslatex"} to use standard {\LaTeX} fonts instead of postscript fonts; and finally \texttt{"utf8"} to choose UTF-8 as input encoding for the {\LaTeX} document. }2565256625672568\subsection{\textcolor{Chapter }{GAPDoc2Text}}2569\logpage{[ 5, 3, 2 ]}\nobreak2570\hyperdef{L}{X86CD0B197CD58D2A}{}2571{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GAPDoc2Text({\mdseries\slshape tree[, bibpath][, width]})\index{GAPDoc2Text@\texttt{GAPDoc2Text}}2572\label{GAPDoc2Text}2573}\hfill{\scriptsize (function)}}\\2574\textbf{\indent Returns:\ }2575record containing text files as strings and other information2576257725782579The argument \mbox{\texttt{\mdseries\slshape tree}} for this function is a tree describing a \textsf{GAPDoc} XML document as returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) (probably also checked with \texttt{CheckAndCleanGapDocTree} (\ref{CheckAndCleanGapDocTree})). This function produces a text version of the document which can be used2580with \textsf{GAP}'s online help (with the \texttt{"screen"} viewer, see \texttt{SetHelpViewer} (\textbf{Reference: SetHelpViewer})). It includes title page, bibliography and index. The bibliography is made2581from BibXMLext or Bib{\TeX} databases, see \ref{ch:bibutil}. Their location must be given with the argument \mbox{\texttt{\mdseries\slshape bibpath}} (as string or directory object).25822583The output is a record with one component for each chapter (with names \texttt{"0"}, \texttt{"1"}, ..., \texttt{"Bib"} and \texttt{"Ind"}). Each such component is again a record with the following components:2584\begin{description}2585\item[{\texttt{text}}] the text of the whole chapter as a string2586\item[{\texttt{ssnr}}] list of subsection numbers in this chapter (like \texttt{[3, 2, 1]} for chapter{\nobreakspace}3, section{\nobreakspace}2,2587subsection{\nobreakspace}1)2588\item[{\texttt{linenr}}] corresponding list of line numbers where the subsections start2589\item[{\texttt{len}}] number of lines of this chapter2590\end{description}2591The result can be written into files with the command \texttt{GAPDoc2TextPrintTextFiles} (\ref{GAPDoc2TextPrintTextFiles}).25922593As a side effect this function also produces the \texttt{manual.six} information which is used for searching in \textsf{GAP}'s online help. This is stored in \texttt{\mbox{\texttt{\mdseries\slshape tree}}.six} and can be printed into a \texttt{manual.six} file with \texttt{PrintSixFile} (\ref{PrintSixFile}) (preferably after producing a {\LaTeX} version of the document as well and adding the page number information to \texttt{\mbox{\texttt{\mdseries\slshape tree}}.six}, see \texttt{GAPDoc2LaTeX} (\ref{GAPDoc2LaTeX}) and \texttt{AddPageNumbersToSix} (\ref{AddPageNumbersToSix})).25942595The text produced by this function contains some markup via ANSI escape2596sequences. The sequences used here are usually ignored by terminals. But the \textsf{GAP} help system will substitute them by interpreted color and attribute sequences2597(see \texttt{TextAttr} (\ref{TextAttr})) before displaying them. There is a default markup used for this but it can2598also be configured by the user, see \texttt{SetGAPDocTextTheme} (\ref{SetGAPDocTextTheme}). Furthermore, the text produced is in UTF-8 encoding. The encoding is also2599translated on the fly, if \texttt{GAPInfo.TermEncoding} is set to some encoding supported by \texttt{Encode} (\ref{Encode}), e.g., \texttt{"ISO-8859-1"} or \texttt{"latin1"}.26002601With the optional argument \mbox{\texttt{\mdseries\slshape width}} a different length of the output text lines can be chosen. The default is 762602and all lines in the resulting text start with two spaces. This looks good on2603a terminal with a standard width of 80 characters and you probably don't want2604to use this argument. }2605260626072608\subsection{\textcolor{Chapter }{GAPDoc2TextPrintTextFiles}}2609\logpage{[ 5, 3, 3 ]}\nobreak2610\hyperdef{L}{X7DFCE7357D6032A2}{}2611{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GAPDoc2TextPrintTextFiles({\mdseries\slshape t[, path]})\index{GAPDoc2TextPrintTextFiles@\texttt{GAPDoc2TextPrintTextFiles}}2612\label{GAPDoc2TextPrintTextFiles}2613}\hfill{\scriptsize (function)}}\\2614\textbf{\indent Returns:\ }2615nothing2616261726182619The first argument must be a result returned by \texttt{GAPDoc2Text} (\ref{GAPDoc2Text}). The second argument is a path for the files to write, it can be given as2620string or directory object. The text of each chapter is written into a2621separate file with name \texttt{chap0.txt}, \texttt{chap1.txt}, ..., \texttt{chapBib.txt}, and \texttt{chapInd.txt}.26222623If you want to make your document accessible via the \textsf{GAP} online help you must put at least these files for the text version into a2624directory, together with the file \texttt{manual.six}, see \texttt{PrintSixFile} (\ref{PrintSixFile}). Then specify the path to the \texttt{manual.six} file in the packages \texttt{PackageInfo.g} file, see (\textbf{Reference: The PackageInfo.g File}).26252626Optionally you can add the \texttt{dvi}- and \texttt{pdf}-versions of the document which are produced with \texttt{GAPDoc2LaTeX} (\ref{GAPDoc2LaTeX}) to this directory. The files must have the names \texttt{manual.dvi} and \texttt{manual.pdf}, respectively. Also you can add the files of the HTML version produced with \texttt{GAPDoc2HTML} (\ref{GAPDoc2HTML}) to this directory, see \texttt{GAPDoc2HTMLPrintHTMLFiles} (\ref{GAPDoc2HTMLPrintHTMLFiles}). The handler functions in \textsf{GAP} for this help format detect automatically which of the optional formats of a2627book are actually available. }2628262926302631\subsection{\textcolor{Chapter }{AddPageNumbersToSix}}2632\logpage{[ 5, 3, 4 ]}\nobreak2633\hyperdef{L}{X7EB5E86F87A09F94}{}2634{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{AddPageNumbersToSix({\mdseries\slshape tree, pnrfile})\index{AddPageNumbersToSix@\texttt{AddPageNumbersToSix}}2635\label{AddPageNumbersToSix}2636}\hfill{\scriptsize (function)}}\\2637\textbf{\indent Returns:\ }2638nothing2639264026412642Here \mbox{\texttt{\mdseries\slshape tree}} must be the XML tree of a \textsf{GAPDoc} document, returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}). Running \texttt{latex} on the result of \texttt{GAPDoc2LaTeX(\mbox{\texttt{\mdseries\slshape tree}})} produces a file \mbox{\texttt{\mdseries\slshape pnrfile}} (with extension \texttt{.pnr}). The command \texttt{GAPDoc2Text(\mbox{\texttt{\mdseries\slshape tree}})} creates a component \texttt{\mbox{\texttt{\mdseries\slshape tree}}.six} which contains all information about the document for the \textsf{GAP} online help, except the page numbers in the \texttt{.dvi, .ps, .pdf} versions of the document. This command adds the missing page number2643information to \texttt{\mbox{\texttt{\mdseries\slshape tree}}.six}. }2644264526462647\subsection{\textcolor{Chapter }{PrintSixFile}}2648\logpage{[ 5, 3, 5 ]}\nobreak2649\hyperdef{L}{X7D42CFED7885BC00}{}2650{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{PrintSixFile({\mdseries\slshape tree, bookname, fname})\index{PrintSixFile@\texttt{PrintSixFile}}2651\label{PrintSixFile}2652}\hfill{\scriptsize (function)}}\\2653\textbf{\indent Returns:\ }2654nothing2655265626572658This function prints the \texttt{.six} file \mbox{\texttt{\mdseries\slshape fname}} for a \textsf{GAPDoc} document stored in \mbox{\texttt{\mdseries\slshape tree}} with name \mbox{\texttt{\mdseries\slshape bookname}}. Such a file contains all information about the book which is needed by the \textsf{GAP} online help. This information must first be created by calls of \texttt{GAPDoc2Text} (\ref{GAPDoc2Text}) and \texttt{AddPageNumbersToSix} (\ref{AddPageNumbersToSix}). }2659266026612662\subsection{\textcolor{Chapter }{SetGAPDocTextTheme}}2663\logpage{[ 5, 3, 6 ]}\nobreak2664\hyperdef{L}{X7DEB37417BBD8941}{}2665{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SetGAPDocTextTheme({\mdseries\slshape [optrec1[, optrec2], ...]})\index{SetGAPDocTextTheme@\texttt{SetGAPDocTextTheme}}2666\label{SetGAPDocTextTheme}2667}\hfill{\scriptsize (function)}}\\2668\textbf{\indent Returns:\ }2669nothing2670267126722673This utility function is for readers of the screen version of \textsf{GAP} manuals which are generated by the \textsf{GAPDoc} package. It allows to configure the color and attribute layout of the2674displayed text. There is a default which can be reset by calling this function2675without argument.26762677As an abbreviation the arguments \mbox{\texttt{\mdseries\slshape optrec1}} and so on can be strings for the known name of a theme. Information about2678valid names is shown with \texttt{SetGAPDocTextTheme("");}.26792680Otherwise, \mbox{\texttt{\mdseries\slshape optrec1}} and so on must be a record. Its entries overwrite the corresponding entries in2681the default and in previous arguments. To construct valid markup you can use \texttt{TextAttr} (\ref{TextAttr}). Entries must be either pairs of strings, which are put before and after the2682corresponding text, or as an abbreviation it can be a single string. In the2683latter case, the second string is implied; if the string contains an escape2684sequence the second string is \texttt{TextAttr.reset}, otherwise the given string is used. The following components are recognized:2685\begin{description}2686\item[{\texttt{flush}}] \texttt{"both"} for left-right justified paragraphs, and \texttt{"left"} for ragged right ones2687\item[{\texttt{Heading}}] chapter and (sub-)section headings2688\item[{\texttt{Func}}] function, operation, ... names2689\item[{\texttt{Arg}}] argument names in descriptions2690\item[{\texttt{Example}}] example code2691\item[{\texttt{Package}}] package names2692\item[{\texttt{Returns}}] Returns-line in descriptions2693\item[{\texttt{URL}}] URLs2694\item[{\texttt{Mark}}] Marks in description lists2695\item[{\texttt{K}}] \textsf{GAP} keywords2696\item[{\texttt{C}}] code or text to type2697\item[{\texttt{F}}] file names2698\item[{\texttt{B}}] buttons2699\item[{\texttt{M}}] simplified math elements2700\item[{\texttt{Math}}] normal math elements2701\item[{\texttt{Display}}] displayed math elements2702\item[{\texttt{Emph}}] emphasized text2703\item[{\texttt{Q}}] quoted text2704\item[{\texttt{Ref}}] reference text2705\item[{\texttt{Prompt}}] \textsf{GAP} prompt in examples2706\item[{\texttt{BrkPrompt}}] \textsf{GAP} break prompt in examples2707\item[{\texttt{GAPInput}}] \textsf{GAP} input in examples2708\item[{\texttt{reset}}] reset to default, don't change this2709\item[{\texttt{BibAuthor}}] author names in bibliography2710\item[{\texttt{BibTitle}}] titles in bibliography2711\item[{\texttt{BibJournal}}] journal names in bibliography2712\item[{\texttt{BibVolume}}] volume number in bibliography2713\item[{\texttt{BibLabel}}] labels for bibliography entries2714\item[{\texttt{BibReset}}] reset for bibliography, don't change2715\item[{\texttt{ListBullet}}] bullet for simple lists (2 visible characters long)2716\item[{\texttt{EnumMarks}}] one visible character before and after the number in enumerated lists2717\item[{\texttt{DefLineMarker}}] marker before function and variable definitions (2 visible characters long)2718\item[{\texttt{FillString}}] for filling in definitions and example separator lines2719\end{description}27202721\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2722!gapprompt@gap>| !gapinput@# use no colors for GAP examples and |2723!gapprompt@gap>| !gapinput@# change display of headings to bold green|2724!gapprompt@gap>| !gapinput@SetGAPDocTextTheme("noColorPrompt", |2725!gapprompt@>| !gapinput@ rec(Heading:=Concatenation(TextAttr.bold, TextAttr.2)));|2726\end{Verbatim}2727}2728272927302731\subsection{\textcolor{Chapter }{GAPDoc2HTML}}2732\logpage{[ 5, 3, 7 ]}\nobreak2733\hyperdef{L}{X84F22EEB78845CFD}{}2734{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GAPDoc2HTML({\mdseries\slshape tree[, bibpath[, gaproot]][, mtrans]})\index{GAPDoc2HTML@\texttt{GAPDoc2HTML}}2735\label{GAPDoc2HTML}2736}\hfill{\scriptsize (function)}}\\2737\textbf{\indent Returns:\ }2738record containing HTML files as strings and other information2739274027412742\index{MathJax@\textsf{MathJax}} The argument \mbox{\texttt{\mdseries\slshape tree}} for this function is a tree describing a \textsf{GAPDoc} XML document as returned by \texttt{ParseTreeXMLString} (\ref{ParseTreeXMLString}) (probably also checked with \texttt{CheckAndCleanGapDocTree} (\ref{CheckAndCleanGapDocTree})). Without an \mbox{\texttt{\mdseries\slshape mtrans}} argument this function produces an HTML version of the document which can be2743read with any Web-browser and also be used with \textsf{GAP}'s online help (see \texttt{SetHelpViewer} (\textbf{Reference: SetHelpViewer})). It includes title page, bibliography, and index. The bibliography is made2744from Bib{\TeX} databases. Their location must be given with the argument \mbox{\texttt{\mdseries\slshape bibpath}} (as string or directory object, if not given the current directory is used).2745If the third argument \mbox{\texttt{\mdseries\slshape gaproot}} is given and is a string then this string is interpreted as relative path to \textsf{GAP}'s main root directory. Reference-URLs to external HTML-books which begin with2746the \textsf{GAP} root path are then rewritten to start with the given relative path. This makes2747the HTML-documentation portable provided a package is installed in some2748standard location below the \textsf{GAP} root.27492750The output is a record with one component for each chapter (with names \texttt{"0"}, \texttt{"1"}, ..., \texttt{"Bib"}, and \texttt{"Ind"}). Each such component is again a record with the following components:2751\begin{description}2752\item[{\texttt{text}}] the text of an HTML file containing the whole chapter (as a string)2753\item[{\texttt{ssnr}}] list of subsection numbers in this chapter (like \texttt{[3, 2, 1]} for chapter{\nobreakspace}3, section{\nobreakspace}2,2754subsection{\nobreakspace}1)2755\end{description}2756\emph{Standard output format without} \mbox{\texttt{\mdseries\slshape mtrans}} \emph{argument}27572758The HTML code produced with this converter conforms to the W3C specification ``XHTML 1.0 strict'', see \href{http://www.w3.org/TR/xhtml1} {\texttt{http://www.w3.org/TR/xhtml1}}. First, this means that the HTML files are valid XML files. Secondly, the2759extension ``strict'' says in particular that the code doesn't contain any explicit font or color2760information.27612762Mathematical formulae are handled as in the text converter \texttt{GAPDoc2Text} (\ref{GAPDoc2Text}). We don't want to assume that the browser can use symbol fonts. Some \textsf{GAP} users like to browse the online help with \texttt{lynx}, see \texttt{SetHelpViewer} (\textbf{Reference: SetHelpViewer}), which runs inside the same terminal windows as \textsf{GAP}.27632764To view the generated files in graphical browsers, stylesheet files with2765layout configuration should be copied into the directory with the generated2766HTML files, see \ref{StyleSheets}.27672768\label{mtransarg} \emph{Output format with} \mbox{\texttt{\mdseries\slshape mtrans}} argument27692770Currently, there are three variants of this converter available which handle2771mathematical formulae differently. They are accessed via the optional last \mbox{\texttt{\mdseries\slshape mtrans}} argument.27722773If \mbox{\texttt{\mdseries\slshape mtrans}} is set to \texttt{"MathJax"} the formulae are essentially translated as for {\LaTeX} documents (there is no processing of \texttt{{\textless}M{\textgreater}} elements as decribed in \ref{M}). Inline formulae are delimited by \texttt{\texttt{\symbol{92}}(} and \texttt{\texttt{\symbol{92}})} and displayed formulae by \texttt{\texttt{\symbol{92}}[} and \texttt{\texttt{\symbol{92}}]}. With \textsf{MathJax} webpages can contain nicely formatted scalable and searchable formulae. The2774resulting files link by default to \href{http://cdn.mathjax.org} {http://cdn.mathjax.org} to get the \textsf{MathJax} script and fonts. This means that they can only be used on computers with2775internet access. An alternative URL can be set by overwriting \texttt{GAPDoc2HTMLProcs.MathJaxURL} before building the HTML version of a manual. This way a local installation of \textsf{MathJax} could be used. See \href{http://www.mathjax.org/} {http://www.mathjax.org/} for more details.27762777The following possibilities for \mbox{\texttt{\mdseries\slshape mtrans}} are still supported, but since the \textsf{MathJax} approach seems much better, their use is deprecated.27782779If the argument \mbox{\texttt{\mdseries\slshape mtrans}} is set to \texttt{"Tth"} it is assumed that you have installed the {\LaTeX} to HTML translation program \texttt{tth}. This is used to translate the contents of the \texttt{M}, \texttt{Math} and \texttt{Display} elements into HTML code. Note that the resulting code is not compliant with2780any standard. Formally it is ``XHTML 1.0 Transitional'', it contains explicit font specifications and the characters of mathematical2781symbols are included via their position in a ``Symbol'' font. Some graphical browsers can be configured to display this in a useful2782manner, check \href{http://hutchinson.belmont.ma.us/tth/} {the Tth homepage} for more details.27832784This function works by running recursively through the document tree and2785calling a handler function for each \textsf{GAPDoc} XML element. Many of these handler functions (usually in \texttt{GAPDoc2TextProcs.{\textless}ElementName{\textgreater}}) are not difficult to understand (the greatest complications are some2786commands for index entries, labels or the output of page number information).2787So it should be easy to adjust certain details to your own taste by slight2788modifications of the program.27892790The result of this converter can be written to files with the command \texttt{GAPDoc2HTMLPrintHTMLFiles} (\ref{GAPDoc2HTMLPrintHTMLFiles}).27912792There are two user preferences for reading the HTML manuals produced by \textsf{GAPDoc}. A user can choose among several style files which determine the appearance2793of the manual pages with \texttt{SetUserPreference("GAPDoc", "HTMLStyle", [...]);} where the list in the third argument are arguments for \texttt{SetGAPDocHTMLStyle} (\ref{SetGAPDocHTMLStyle}). The second preference is set by \texttt{SetUserPreference("GAPDoc", "UseMathJax", ...);} where the third argument is \texttt{true} or \texttt{false} (default). If this is set to \texttt{true}, the \textsf{GAP} help system displays the \textsf{MathJax} version of the HTML manuals. }2794279527962797\subsection{\textcolor{Chapter }{GAPDoc2HTMLPrintHTMLFiles}}2798\logpage{[ 5, 3, 8 ]}\nobreak2799\hyperdef{L}{X84A7007778073E7A}{}2800{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{GAPDoc2HTMLPrintHTMLFiles({\mdseries\slshape t[, path]})\index{GAPDoc2HTMLPrintHTMLFiles@\texttt{GAPDoc2HTMLPrintHTMLFiles}}2801\label{GAPDoc2HTMLPrintHTMLFiles}2802}\hfill{\scriptsize (function)}}\\2803\textbf{\indent Returns:\ }2804nothing2805280628072808The first argument must be a result returned by \texttt{GAPDoc2HTML} (\ref{GAPDoc2HTML}). The second argument is a path for the files to write, it can be given as2809string or directory object. The text of each chapter is written into a2810separate file with name \texttt{chap0.html}, \texttt{chap1.html}, ..., \texttt{chapBib.html}, and \texttt{chapInd.html}.28112812The \textsf{MathJax} versions are written to files \texttt{chap0{\textunderscore}mj.html}, ..., \texttt{chapInd{\textunderscore}mj.html}.28132814The experimental version which is produced with \texttt{tth} uses different names for the files, namely \texttt{chap0{\textunderscore}sym.html}, and so on for files which need symbol fonts.28152816You should also add stylesheet files to the directory with the HTML files, see \ref{StyleSheets}. }281728182819\subsection{\textcolor{Chapter }{Stylesheet files}}\label{StyleSheets}2820\logpage{[ 5, 3, 9 ]}2821\hyperdef{L}{X788AB14383272FDB}{}2822{2823\index{CSS stylesheets} For graphical browsers the layout of the generated HTML manuals can be highly2824configured by cascading stylesheet (CSS) and javascript files. Such files are2825provided in the \texttt{styles} directory of the \textsf{GAPDoc} package.28262827We recommend that these files are copied into each manual directory (such that2828each of them is selfcontained). There is a utility function \texttt{CopyHTMLStyleFiles} (\ref{CopyHTMLStyleFiles}) which does this. Of course, these files may be changed or new styles may be2829added. New styles may also be sent to the \textsf{GAPDoc} authors for possible inclusion in future versions.28302831The generated HTML files refer to the file \texttt{manual.css} which conforms to the W3C specification CSS 2.0, see \href{http://www.w3.org/TR/REC-CSS2} {\texttt{http://www.w3.org/TR/REC-CSS2}}, and the javascript file \texttt{manual.js} (only in browsers which support CSS or javascript, respectively; but the HTML2832files are also readable without any of them). To add a style \texttt{mystyle} one or both of \texttt{mystyle.css} and \texttt{mystyle.js} must be provided; these can overwrite default settings and add new javascript2833functions. For more details see the comments in \texttt{manual.js}.28342835}2836283728382839\subsection{\textcolor{Chapter }{CopyHTMLStyleFiles}}2840\logpage{[ 5, 3, 10 ]}\nobreak2841\hyperdef{L}{X813599E982DE9B98}{}2842{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{CopyHTMLStyleFiles({\mdseries\slshape dir})\index{CopyHTMLStyleFiles@\texttt{CopyHTMLStyleFiles}}2843\label{CopyHTMLStyleFiles}2844}\hfill{\scriptsize (function)}}\\2845\textbf{\indent Returns:\ }2846nothing2847284828492850This utility function copies the \texttt{*.css} and \texttt{*.js} files from the \texttt{styles} directory of the \textsf{GAPDoc} package into the directory \mbox{\texttt{\mdseries\slshape dir}}. }2851285228532854\subsection{\textcolor{Chapter }{SetGAPDocHTMLStyle}}2855\logpage{[ 5, 3, 11 ]}\nobreak2856\hyperdef{L}{X85AFD98383174BB5}{}2857{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SetGAPDocHTMLStyle({\mdseries\slshape [style1[, style2], ...]})\index{SetGAPDocHTMLStyle@\texttt{SetGAPDocHTMLStyle}}2858\label{SetGAPDocHTMLStyle}2859}\hfill{\scriptsize (function)}}\\2860\textbf{\indent Returns:\ }2861nothing2862286328642865This utility function is for readers of the HTML version of \textsf{GAP} manuals which are generated by the \textsf{GAPDoc} package. It allows to configure the display style of the manuals. This will2866only have an effect if you are using a browser that supports \textsf{javascript}. There is a default which can be reset by calling this function without2867argument.28682869The arguments \mbox{\texttt{\mdseries\slshape style1}} and so on must be strings. You can find out about the valid strings by2870following the \textsc{[Style]} link on top of any manual page. (Going back to the original page, its address2871has a setting for \texttt{GAPDocStyle} which is the list of strings, separated by commas, you want to use here.)2872\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]2873!gapprompt@gap>| !gapinput@# show/hide subsections in tables on contents only after click,|2874!gapprompt@gap>| !gapinput@# and don't use colors in GAP examples|2875!gapprompt@gap>| !gapinput@SetGAPDocHTMLStyle("toggless", "nocolorprompt");|2876\end{Verbatim}2877}2878287928802881\subsection{\textcolor{Chapter }{InfoGAPDoc}}2882\logpage{[ 5, 3, 12 ]}\nobreak2883\hyperdef{L}{X864A528B81C661A2}{}2884{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{InfoGAPDoc\index{InfoGAPDoc@\texttt{InfoGAPDoc}}2885\label{InfoGAPDoc}2886}\hfill{\scriptsize (info class)}}\\288728882889The default level of this info class is 1. The converter functions for \textsf{GAPDoc} documents are then printing some information. You can suppress this by setting2890the level of \texttt{InfoGAPDoc} to 0. With level 2 there may be some more information for debugging purposes. }2891289228932894\subsection{\textcolor{Chapter }{SetGapDocLanguage}}2895\logpage{[ 5, 3, 13 ]}\nobreak2896\hyperdef{L}{X82AB468887ED0DBB}{}2897{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SetGapDocLanguage({\mdseries\slshape [lang]})\index{SetGapDocLanguage@\texttt{SetGapDocLanguage}}2898\label{SetGapDocLanguage}2899}\hfill{\scriptsize (function)}}\\2900\textbf{\indent Returns:\ }2901nothing2902290329042905\index{Using \textsf{GAPDoc} with other languages} The \textsf{GAPDoc} converter programs sometimes produce text which is not explicit in the2906document, e.g., headers like ``Abstract'', ``Appendix'', links to ``Next Chapter'', variable types ``function'' and so on.29072908With \texttt{SetGapDocLanguage} the language for these texts can be changed. The argument \mbox{\texttt{\mdseries\slshape lang}} must be a string. Calling without argument or with a language name for which2909no translations are available is the same as using the default \texttt{"english"}.29102911If your language \mbox{\texttt{\mdseries\slshape lang}} is not yet available, look at the record \texttt{GAPDocTexts.english} and translate all the strings to \mbox{\texttt{\mdseries\slshape lang}}. Then assign this record to \texttt{GAPDocTexts.(\mbox{\texttt{\mdseries\slshape lang}})} and send it to the \textsf{GAPDoc} authors for inclusion in future versions of \textsf{GAPDoc}. (Currently, there are translations for \texttt{english}, \texttt{german}, \texttt{russian} and \texttt{ukrainian}.)29122913\emph{Further hints:} To get strings produced by {\LaTeX} right you will probably use the \texttt{babel} package with option \mbox{\texttt{\mdseries\slshape lang}}, see \texttt{SetGapDocLaTeXOptions} (\ref{SetGapDocLaTeXOptions}). If \mbox{\texttt{\mdseries\slshape lang}} cannot be encoded in \texttt{latin1} encoding you can consider the use of \texttt{"utf8"} with \texttt{SetGapDocLaTeXOptions} (\ref{SetGapDocLaTeXOptions}). }29142915}291629172918\section{\textcolor{Chapter }{Testing Manual Examples}}\label{Sec:TestExample}2919\logpage{[ 5, 4, 0 ]}2920\hyperdef{L}{X800299827B88ABBE}{}2921{2922\index{\texttt{ManualExamples}} \index{\texttt{TestManualExamples}} We also provide some tools to check and adjust the examples given in \texttt{{\textless}Example{\textgreater}}-elements.29232924Former versions of \textsf{GAPDoc} provided functions \texttt{ManualExamples} and \texttt{TestManualExamples}. These functions are still available, but no longer documented. Their use is2925deprecated.29262927\subsection{\textcolor{Chapter }{ExtractExamples}}2928\logpage{[ 5, 4, 1 ]}\nobreak2929\hyperdef{L}{X8337B2BC79253B3F}{}2930{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ExtractExamples({\mdseries\slshape path, main, files, units})\index{ExtractExamples@\texttt{ExtractExamples}}2931\label{ExtractExamples}2932}\hfill{\scriptsize (function)}}\\2933\textbf{\indent Returns:\ }2934a list of lists29352936\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ExtractExamplesXMLTree({\mdseries\slshape tree, units})\index{ExtractExamplesXMLTree@\texttt{ExtractExamplesXMLTree}}2937\label{ExtractExamplesXMLTree}2938}\hfill{\scriptsize (function)}}\\2939\textbf{\indent Returns:\ }2940a list of lists2941294229432944The argument \mbox{\texttt{\mdseries\slshape tree}} must be a parse tree of a \textsf{GAPDoc} document, see \texttt{ParseTreeXMLFile} (\ref{ParseTreeXMLFile}). The function \texttt{ExtractExamplesXMLTree} returns a data structure representing the \texttt{{\textless}Example{\textgreater}} elements of the document. The return value can be used with \texttt{RunExamples} (\ref{RunExamples}) to check and optionally update the examples of the document.29452946Depending on the argument \mbox{\texttt{\mdseries\slshape units}} several examples are collected in one list. Recognized values for \mbox{\texttt{\mdseries\slshape units}} are \texttt{"Chapter"}, \texttt{"Section"}, \texttt{"Subsection"} or \texttt{"Single"}. The latter means that each example is in a separate list. For all other2947value of \mbox{\texttt{\mdseries\slshape units}} just one list with all examples is returned.29482949The arguments \mbox{\texttt{\mdseries\slshape path}}, \mbox{\texttt{\mdseries\slshape main}} and \mbox{\texttt{\mdseries\slshape files}} of \texttt{ExtractExamples} are the same as for \texttt{ComposedDocument} (\ref{ComposedDocument}). This function first contructs and parses the \textsf{GAPDoc} document and then applies \texttt{ExtractExamplesXMLTree}. }2950295129522953\subsection{\textcolor{Chapter }{RunExamples}}2954\logpage{[ 5, 4, 2 ]}\nobreak2955\hyperdef{L}{X781D56FC7B938DCB}{}2956{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{RunExamples({\mdseries\slshape exmpls[, optrec]})\index{RunExamples@\texttt{RunExamples}}2957\label{RunExamples}2958}\hfill{\scriptsize (function)}}\\2959\textbf{\indent Returns:\ }2960\texttt{true} or \texttt{false}2961296229632964The argument \mbox{\texttt{\mdseries\slshape exmpls}} must be the output of a call to \texttt{ExtractExamples} (\ref{ExtractExamples}) or \texttt{ExtractExamplesXMLTree} (\ref{ExtractExamplesXMLTree}). The optional argument \mbox{\texttt{\mdseries\slshape optrec}} must be a record, its components can change the default behaviour of this2965function.29662967By default this function runs the \textsf{GAP} input of all examples and compares the actual output with the output given in2968the examples. If differences occur these are displayed together with2969information on the location of the source code of that example. Before running2970the examples in each unit (entry of \mbox{\texttt{\mdseries\slshape exmpls}}) the function \texttt{START{\textunderscore}TEST} (\textbf{Reference: START{\textunderscore}TEST}) is called and the screen width is set to 72 characters.29712972This function returns \texttt{true} if no differences are found and \texttt{false} otherwise.29732974If the argument \mbox{\texttt{\mdseries\slshape optrec}} is given, the following components are recognized:2975\begin{description}2976\item[{\texttt{showDiffs}}] The default value is \texttt{true}, if set to something else found differences in the examples are not2977displayed.2978\item[{\texttt{width}}] The value must be a positive integer which is used as screen width when2979running the examples. As mentioned above, the default is 72 which is a2980sensible value for the text version of the \textsf{GAPDoc} document used in a 80 character wide terminal.2981\item[{\texttt{ignoreComments}}] The default is \texttt{false}.\\2982If set to \texttt{true} comments in the input will be ignored (as in the default behaviour of the \texttt{Test} (\textbf{Reference: Test}) function).2983\item[{\texttt{changeSources}}] If this is set to \texttt{true} then the source code of all manual examples which show differences is adjusted2984to the current outputs. The default is \texttt{false}.\\2985Use this feature with care. Note that sometimes differences can indicate a2986bug, and in such a case it is more appropriate to fix the bug instead of2987changing the example output.2988\item[{\texttt{compareFunction}}] The function used to compare the output shown in the example and the current2989output. See \texttt{Test} (\textbf{Reference: Test}) for more details.2990\item[{\texttt{checkWidth}}] If this option is a positive integer \texttt{n} the function prints warnings if an example contains any line with more than \texttt{n} characters (input and output lines are considered). By default this option is2991set to \texttt{false}.2992\end{description}2993}29942995}29962997}299829993000\chapter{\textcolor{Chapter }{String and Text Utilities}}\label{ch:util}3001\logpage{[ 6, 0, 0 ]}3002\hyperdef{L}{X86CEF540862EE042}{}3003{30043005\section{\textcolor{Chapter }{Text Utilities}}\label{TextUtil}3006\logpage{[ 6, 1, 0 ]}3007\hyperdef{L}{X847DA07C7C46B38A}{}3008{3009This section describes some utility functions for handling texts within \textsf{GAP}. They are used by the functions in the \textsf{GAPDoc} package but may be useful for other purposes as well. We start with some3010variables containing useful strings and go on with functions for parsing and3011reformatting text.3012301330143015\subsection{\textcolor{Chapter }{WHITESPACE}}3016\logpage{[ 6, 1, 1 ]}\nobreak3017\hyperdef{L}{X786D477C7AB636AA}{}3018{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WHITESPACE\index{WHITESPACE@\texttt{WHITESPACE}}3019\label{WHITESPACE}3020}\hfill{\scriptsize (global variable)}}\\3021\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{CAPITALLETTERS\index{CAPITALLETTERS@\texttt{CAPITALLETTERS}}3022\label{CAPITALLETTERS}3023}\hfill{\scriptsize (global variable)}}\\3024\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SMALLLETTERS\index{SMALLLETTERS@\texttt{SMALLLETTERS}}3025\label{SMALLLETTERS}3026}\hfill{\scriptsize (global variable)}}\\3027\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LETTERS\index{LETTERS@\texttt{LETTERS}}3028\label{LETTERS}3029}\hfill{\scriptsize (global variable)}}\\3030\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{DIGITS\index{DIGITS@\texttt{DIGITS}}3031\label{DIGITS}3032}\hfill{\scriptsize (global variable)}}\\3033\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{HEXDIGITS\index{HEXDIGITS@\texttt{HEXDIGITS}}3034\label{HEXDIGITS}3035}\hfill{\scriptsize (global variable)}}\\3036\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{BOXCHARS\index{BOXCHARS@\texttt{BOXCHARS}}3037\label{BOXCHARS}3038}\hfill{\scriptsize (global variable)}}\\303930403041These variables contain sets of characters which are useful for text3042processing. They are defined as follows.304330443045\begin{description}3046\item[{\texttt{WHITESPACE}}] \texttt{" \texttt{\symbol{92}}n\texttt{\symbol{92}}t\texttt{\symbol{92}}r"}3047\item[{\texttt{CAPITALLETTERS}}] \texttt{"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}3048\item[{\texttt{SMALLLETTERS}}] \texttt{"abcdefghijklmnopqrstuvwxyz"}3049\item[{\texttt{LETTERS}}] concatenation of \texttt{CAPITALLETTERS} and \texttt{SMALLLETTERS}3050\item[{\texttt{DIGITS}}] \texttt{"0123456789"}3051\item[{\texttt{HEXDIGITS}}] \texttt{"0123456789ABCDEFabcdef"}3052\item[{\texttt{BOXCHARS}}] \texttt{Encode(Unicode(9472 + [ 0, 2, 12, 44, 16, 28,305360, 36, 20, 52, 24, 1, 3, 15, 51, 19, 35, 75, 43, 23, 59, 27, 80, 81,305484, 102, 87, 96, 108, 99, 90, 105, 93 ]), "UTF-8")}, these are in UTF-8 encoding, the \texttt{i}-th unicode character is \texttt{BOXCHARS\texttt{\symbol{123}}[3*i-2..3*i]\texttt{\symbol{125}}}.3055\end{description}3056}3057305830593060\subsection{\textcolor{Chapter }{TextAttr}}3061\logpage{[ 6, 1, 2 ]}\nobreak3062\hyperdef{L}{X785F61E77899580E}{}3063{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{TextAttr\index{TextAttr@\texttt{TextAttr}}3064\label{TextAttr}3065}\hfill{\scriptsize (global variable)}}\\306630673068The record \texttt{TextAttr} contains strings which can be printed to change the terminal attribute for the3069following characters. This only works with terminals which understand basic3070ANSI escape sequences. Try the following example to see if this is the case3071for the terminal you are using. It shows the effect of the foreground and3072background color attributes and of the \texttt{.bold}, \texttt{.blink}, \texttt{.normal}, \texttt{.reverse} and \texttt{.underscore} which can partly be mixed.3073\begin{Verbatim}[fontsize=\small,frame=single,label=Example]3074extra := ["CSI", "reset", "delline", "home"];;3075for t in Difference(RecNames(TextAttr), extra) do3076Print(TextAttr.(t), "TextAttr.", t, TextAttr.reset,"\n");3077od;3078\end{Verbatim}3079The suggested defaults for colors \texttt{0..7} are black, red, green, brown, blue, magenta, cyan, white. But this may be3080different for your terminal configuration.30813082The escape sequence \texttt{.delline} deletes the content of the current line and \texttt{.home} moves the cursor to the beginning of the current line.3083\begin{Verbatim}[fontsize=\small,frame=single,label=Example]3084for i in [1..5] do3085Print(TextAttr.home, TextAttr.delline, String(i,-6), "\c");3086Sleep(1);3087od;3088\end{Verbatim}3089\index{UseColorsInTerminal} Whenever you use this in some printing routines you should make it optional.3090Use these attributes only when \texttt{UserPreference("UseColorsInTerminal");} returns \texttt{true}. }3091309230933094\subsection{\textcolor{Chapter }{WrapTextAttribute}}3095\logpage{[ 6, 1, 3 ]}\nobreak3096\hyperdef{L}{X7B8AD7517E5FD0EA}{}3097{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WrapTextAttribute({\mdseries\slshape str, attr})\index{WrapTextAttribute@\texttt{WrapTextAttribute}}3098\label{WrapTextAttribute}3099}\hfill{\scriptsize (function)}}\\3100\textbf{\indent Returns:\ }3101a string with markup3102310331043105The argument \mbox{\texttt{\mdseries\slshape str}} must be a text as \textsf{GAP} string, possibly with markup by escape sequences as in \texttt{TextAttr} (\ref{TextAttr}). This function returns a string which is wrapped by the escape sequences \mbox{\texttt{\mdseries\slshape attr}} and \texttt{TextAttr.reset}. It takes care of markup in the given string by appending \mbox{\texttt{\mdseries\slshape attr}} also after each given \texttt{TextAttr.reset} in \mbox{\texttt{\mdseries\slshape str}}.3106\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3107!gapprompt@gap>| !gapinput@str := Concatenation("XXX",TextAttr.2, "BLUB", TextAttr.reset,"YYY");|3108"XXX\033[32mBLUB\033[0mYYY"3109!gapprompt@gap>| !gapinput@str2 := WrapTextAttribute(str, TextAttr.1);|3110"\033[31mXXX\033[32mBLUB\033[0m\033[31m\027YYY\033[0m"3111!gapprompt@gap>| !gapinput@str3 := WrapTextAttribute(str, TextAttr.underscore);|3112"\033[4mXXX\033[32mBLUB\033[0m\033[4m\027YYY\033[0m"3113!gapprompt@gap>| !gapinput@# use Print(str); and so on to see how it looks like.|3114\end{Verbatim}3115}3116311731183119\subsection{\textcolor{Chapter }{FormatParagraph}}3120\logpage{[ 6, 1, 4 ]}\nobreak3121\hyperdef{L}{X812058CE7C8E9022}{}3122{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{FormatParagraph({\mdseries\slshape str[, len][, flush][, attr][, widthfun]})\index{FormatParagraph@\texttt{FormatParagraph}}3123\label{FormatParagraph}3124}\hfill{\scriptsize (function)}}\\3125\textbf{\indent Returns:\ }3126the formatted paragraph as string3127312831293130This function formats a text given in the string \mbox{\texttt{\mdseries\slshape str}} as a paragraph. The optional arguments have the following meaning:3131\begin{description}3132\item[{\mbox{\texttt{\mdseries\slshape len}}}] the length of the lines of the formatted text, default is \texttt{78} (counted without a visible length of the strings specified in the \mbox{\texttt{\mdseries\slshape attr}} argument)3133\item[{\mbox{\texttt{\mdseries\slshape flush}}}] can be \texttt{"left"}, \texttt{"right"}, \texttt{"center"} or \texttt{"both"}, telling that lines should be flushed left, flushed right, centered or3134left-right justified, respectively, default is \texttt{"both"}3135\item[{\mbox{\texttt{\mdseries\slshape attr}}}] is a list of two strings; the first is prepended and the second appended to3136each line of the result (can for example be used for indenting, \texttt{[" ", ""]}, or some markup, \texttt{[TextAttr.bold, TextAttr.reset]}, default is \texttt{["", ""]})3137\item[{\mbox{\texttt{\mdseries\slshape widthfun}}}] must be a function which returns the display width of text in \mbox{\texttt{\mdseries\slshape str}}. The default is \texttt{Length} assuming that each byte corresponds to a character of width one. If \mbox{\texttt{\mdseries\slshape str}} is given in \texttt{UTF-8} encoding one can use \texttt{WidthUTF8String} (\ref{WidthUTF8String}) here.3138\end{description}3139This function tries to handle markup with the escape sequences explained in \texttt{TextAttr} (\ref{TextAttr}) correctly.3140\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3141!gapprompt@gap>| !gapinput@str := "One two three four five six seven eight nine ten eleven.";;|3142!gapprompt@gap>| !gapinput@Print(FormatParagraph(str, 25, "left", ["/* ", " */"])); |3143/* One two three four five */3144/* six seven eight nine ten */3145/* eleven. */3146\end{Verbatim}3147}3148314931503151\subsection{\textcolor{Chapter }{SubstitutionSublist}}3152\logpage{[ 6, 1, 5 ]}\nobreak3153\hyperdef{L}{X82A9121678923445}{}3154{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SubstitutionSublist({\mdseries\slshape list, sublist, new[, flag]})\index{SubstitutionSublist@\texttt{SubstitutionSublist}}3155\label{SubstitutionSublist}3156}\hfill{\scriptsize (function)}}\\3157\textbf{\indent Returns:\ }3158the changed list3159316031613162This function looks for (non-overlapping) occurrences of a sublist \mbox{\texttt{\mdseries\slshape sublist}} in a list \mbox{\texttt{\mdseries\slshape list}} (compare \texttt{PositionSublist} (\textbf{Reference: PositionSublist})) and returns a list where these are substituted with the list \mbox{\texttt{\mdseries\slshape new}}.31633164The optional argument \mbox{\texttt{\mdseries\slshape flag}} can either be \texttt{"all"} (this is the default if not given) or \texttt{"one"}. In the second case only the first occurrence of \mbox{\texttt{\mdseries\slshape sublist}} is substituted.31653166If \mbox{\texttt{\mdseries\slshape sublist}} does not occur in \mbox{\texttt{\mdseries\slshape list}} then \mbox{\texttt{\mdseries\slshape list}} itself is returned (and not a \texttt{ShallowCopy(list)}).3167\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3168!gapprompt@gap>| !gapinput@SubstitutionSublist("xababx", "ab", "a");|3169"xaax"3170\end{Verbatim}3171}3172317331743175\subsection{\textcolor{Chapter }{StripBeginEnd}}3176\logpage{[ 6, 1, 6 ]}\nobreak3177\hyperdef{L}{X83DE31017B557136}{}3178{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StripBeginEnd({\mdseries\slshape list, strip})\index{StripBeginEnd@\texttt{StripBeginEnd}}3179\label{StripBeginEnd}3180}\hfill{\scriptsize (function)}}\\3181\textbf{\indent Returns:\ }3182changed string3183318431853186Here \mbox{\texttt{\mdseries\slshape list}} and \mbox{\texttt{\mdseries\slshape strip}} must be lists. This function returns the sublist of list which does not3187contain the leading and trailing entries which are entries of \mbox{\texttt{\mdseries\slshape strip}}. If the result is equal to \mbox{\texttt{\mdseries\slshape list}} then \mbox{\texttt{\mdseries\slshape list}} itself is returned.3188\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3189!gapprompt@gap>| !gapinput@StripBeginEnd(" ,a, b,c, ", ", ");|3190"a, b,c"3191\end{Verbatim}3192}3193319431953196\subsection{\textcolor{Chapter }{StripEscapeSequences}}3197\logpage{[ 6, 1, 7 ]}\nobreak3198\hyperdef{L}{X7A5978CF84C3C2D3}{}3199{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StripEscapeSequences({\mdseries\slshape str})\index{StripEscapeSequences@\texttt{StripEscapeSequences}}3200\label{StripEscapeSequences}3201}\hfill{\scriptsize (function)}}\\3202\textbf{\indent Returns:\ }3203string without escape sequences3204320532063207This function returns the string one gets from the string \mbox{\texttt{\mdseries\slshape str}} by removing all escape sequences which are explained in \texttt{TextAttr} (\ref{TextAttr}). If \mbox{\texttt{\mdseries\slshape str}} does not contain such a sequence then \mbox{\texttt{\mdseries\slshape str}} itself is returned. }3208320932103211\subsection{\textcolor{Chapter }{RepeatedString}}3212\logpage{[ 6, 1, 8 ]}\nobreak3213\hyperdef{L}{X7D71CB837EE969D4}{}3214{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{RepeatedString({\mdseries\slshape c, len})\index{RepeatedString@\texttt{RepeatedString}}3215\label{RepeatedString}3216}\hfill{\scriptsize (function)}}\\3217\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{RepeatedUTF8String({\mdseries\slshape c, len})\index{RepeatedUTF8String@\texttt{RepeatedUTF8String}}3218\label{RepeatedUTF8String}3219}\hfill{\scriptsize (function)}}\\322032213222Here \mbox{\texttt{\mdseries\slshape c}} must be either a character or a string and \mbox{\texttt{\mdseries\slshape len}} is a non-negative number. Then \texttt{RepeatedString} returns a string of length \mbox{\texttt{\mdseries\slshape len}} consisting of copies of \mbox{\texttt{\mdseries\slshape c}}.32233224In the variant \texttt{RepeatedUTF8String} the argument \mbox{\texttt{\mdseries\slshape c}} is considered as string in UTF-8 encoding, and it can also be specified as3225unicode string or character, see \texttt{Unicode} (\ref{Unicode}). The result is a string in UTF-8 encoding which has visible width \mbox{\texttt{\mdseries\slshape len}} as explained in \texttt{WidthUTF8String} (\ref{WidthUTF8String}).3226\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3227!gapprompt@gap>| !gapinput@RepeatedString('=',51);|3228"==================================================="3229!gapprompt@gap>| !gapinput@RepeatedString("*=",51);|3230"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*"3231!gapprompt@gap>| !gapinput@s := "b�h";;|3232!gapprompt@gap>| !gapinput@enc := GAPInfo.TermEncoding;;|3233!gapprompt@gap>| !gapinput@if enc <> "UTF-8" then s := Encode(Unicode(s, enc), "UTF-8"); fi;|3234!gapprompt@gap>| !gapinput@l := RepeatedUTF8String(s, 8);;|3235!gapprompt@gap>| !gapinput@u := Unicode(l, "UTF-8");;|3236!gapprompt@gap>| !gapinput@Print(Encode(u, enc), "\n");|3237b�hb�hb�3238\end{Verbatim}3239}3240324132423243\subsection{\textcolor{Chapter }{NumberDigits}}3244\logpage{[ 6, 1, 9 ]}\nobreak3245\hyperdef{L}{X7CEEA5B57D7BB38F}{}3246{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{NumberDigits({\mdseries\slshape str, base})\index{NumberDigits@\texttt{NumberDigits}}3247\label{NumberDigits}3248}\hfill{\scriptsize (function)}}\\3249\textbf{\indent Returns:\ }3250integer32513252\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{DigitsNumber({\mdseries\slshape n, base})\index{DigitsNumber@\texttt{DigitsNumber}}3253\label{DigitsNumber}3254}\hfill{\scriptsize (function)}}\\3255\textbf{\indent Returns:\ }3256string3257325832593260The argument \mbox{\texttt{\mdseries\slshape str}} of \texttt{NumberDigits} must be a string consisting only of an optional leading \texttt{'-'} and characters in \texttt{0123456789abcdefABCDEF}, describing an integer in base \mbox{\texttt{\mdseries\slshape base}} with $2 \leq \mbox{\texttt{\mdseries\slshape base}} \leq 16$. This function returns the corresponding integer.32613262The function \texttt{DigitsNumber} does the reverse.3263\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3264!gapprompt@gap>| !gapinput@NumberDigits("1A3F",16);|326567193266!gapprompt@gap>| !gapinput@DigitsNumber(6719, 16);|3267"1A3F"3268\end{Verbatim}3269}3270327132723273\subsection{\textcolor{Chapter }{LabelInt}}3274\logpage{[ 6, 1, 10 ]}\nobreak3275\hyperdef{L}{X79EF038284598D41}{}3276{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LabelInt({\mdseries\slshape n, type, pre, post})\index{LabelInt@\texttt{LabelInt}}3277\label{LabelInt}3278}\hfill{\scriptsize (function)}}\\3279\textbf{\indent Returns:\ }3280string3281328232833284The argument \mbox{\texttt{\mdseries\slshape n}} must be an integer in the range from 1 to 5000, while \mbox{\texttt{\mdseries\slshape pre}} and \mbox{\texttt{\mdseries\slshape post}} must be strings.32853286The argument \mbox{\texttt{\mdseries\slshape type}} can be one of \texttt{"Decimal"}, \texttt{"Roman"}, \texttt{"roman"}, \texttt{"Alpha"}, \texttt{"alpha"}.32873288The function returns a string that starts with \mbox{\texttt{\mdseries\slshape pre}}, followed by a decimal, respectively roman number or alphanumerical number3289literal (capital, respectively small letters), followed by \mbox{\texttt{\mdseries\slshape post}}.329032913292\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3293!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"Decimal","","."));|3294[ "1.", "2.", "3.", "4.", "5.", "691." ]3295!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"alpha","(",")"));|3296[ "(a)", "(b)", "(c)", "(d)", "(e)", "(zo)" ]3297!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"alpha","(",")"));|3298[ "(a)", "(b)", "(c)", "(d)", "(e)", "(zo)" ]3299!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"Alpha","",".)"));|3300[ "A.)", "B.)", "C.)", "D.)", "E.)", "ZO.)" ]3301!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"roman","","."));|3302[ "i.", "ii.", "iii.", "iv.", "v.", "dcxci." ]3303!gapprompt@gap>| !gapinput@List([1,2,3,4,5,691], i-> LabelInt(i,"Roman","",""));|3304[ "I", "II", "III", "IV", "V", "DCXCI" ]3305\end{Verbatim}3306}3307330833093310\subsection{\textcolor{Chapter }{PositionMatchingDelimiter}}3311\logpage{[ 6, 1, 11 ]}\nobreak3312\hyperdef{L}{X7AF694D9839BF65C}{}3313{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{PositionMatchingDelimiter({\mdseries\slshape str, delim, pos})\index{PositionMatchingDelimiter@\texttt{PositionMatchingDelimiter}}3314\label{PositionMatchingDelimiter}3315}\hfill{\scriptsize (function)}}\\3316\textbf{\indent Returns:\ }3317position as integer or \texttt{fail}3318331933203321Here \mbox{\texttt{\mdseries\slshape str}} must be a string and \mbox{\texttt{\mdseries\slshape delim}} a string with two different characters. This function searches the smallest3322position \texttt{r} of the character \texttt{\mbox{\texttt{\mdseries\slshape delim}}[2]} in \mbox{\texttt{\mdseries\slshape str}} such that the number of occurrences of \texttt{\mbox{\texttt{\mdseries\slshape delim}}[2]} in \mbox{\texttt{\mdseries\slshape str}} between positions \texttt{\mbox{\texttt{\mdseries\slshape pos}}+1} and \texttt{r} is by one greater than the corresponding number of occurrences of \texttt{\mbox{\texttt{\mdseries\slshape delim}}[1]}.33233324If such an \texttt{r} exists, it is returned. Otherwise \texttt{fail} is returned.3325\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3326!gapprompt@gap>| !gapinput@PositionMatchingDelimiter("{}x{ab{c}d}", "{}", 0);|3327fail3328!gapprompt@gap>| !gapinput@PositionMatchingDelimiter("{}x{ab{c}d}", "{}", 1);|332923330!gapprompt@gap>| !gapinput@PositionMatchingDelimiter("{}x{ab{c}d}", "{}", 6);|3331113332\end{Verbatim}3333}3334333533363337\subsection{\textcolor{Chapter }{WordsString}}3338\logpage{[ 6, 1, 12 ]}\nobreak3339\hyperdef{L}{X832556617F10AAA8}{}3340{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WordsString({\mdseries\slshape str})\index{WordsString@\texttt{WordsString}}3341\label{WordsString}3342}\hfill{\scriptsize (function)}}\\3343\textbf{\indent Returns:\ }3344list of strings containing the words3345334633473348This returns the list of words of a text stored in the string \mbox{\texttt{\mdseries\slshape str}}. All non-letters are considered as word boundaries and are removed.3349\begin{Verbatim}[commandchars=@|A,fontsize=\small,frame=single,label=Example]3350@gapprompt|gap>A @gapinput|WordsString("one_two \n three!?");A3351[ "one", "two", "three" ]3352\end{Verbatim}3353}3354335533563357\subsection{\textcolor{Chapter }{Base64String}}3358\logpage{[ 6, 1, 13 ]}\nobreak3359\hyperdef{L}{X83F2821783DA9826}{}3360{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{Base64String({\mdseries\slshape str})\index{Base64String@\texttt{Base64String}}3361\label{Base64String}3362}\hfill{\scriptsize (function)}}\\3363\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringBase64({\mdseries\slshape bstr})\index{StringBase64@\texttt{StringBase64}}3364\label{StringBase64}3365}\hfill{\scriptsize (function)}}\\3366\textbf{\indent Returns:\ }3367a string3368336933703371The first function translates arbitrary binary data given as a GAP string into3372a \emph{base 64} encoded string. This encoded string contains only printable ASCII characters3373and is used in various data transfer protocols (\texttt{MIME} encoded emails, weak password encryption, ...). We use the specification in \href{http://tools.ietf.org/html/rfc2045} {RFC 2045}.33743375The second function has the reverse functionality. Here we also accept the3376characters \texttt{-{\textunderscore}} instead of \texttt{+/} as last two characters. Whitespace is ignored.3377\begin{Verbatim}[commandchars=@|D,fontsize=\small,frame=single,label=Example]3378@gapprompt|gap>D @gapinput|b := Base64String("This is a secret!");D3379"VGhpcyBpcyBhIHNlY3JldCEA="3380@gapprompt|gap>D @gapinput|StringBase64(b); D3381"This is a secret!"3382\end{Verbatim}3383}33843385}338633873388\section{\textcolor{Chapter }{Unicode Strings}}\label{sec:Unicode}3389\logpage{[ 6, 2, 0 ]}3390\hyperdef{L}{X8489C67D80399814}{}3391{3392The \textsf{GAPDoc} package provides some tools to deal with unicode characters and strings. These3393can be used for recoding text strings between various encodings.3394\subsection{\textcolor{Chapter }{Unicode Strings and Characters}}\logpage{[ 6, 2, 1 ]}3395\hyperdef{L}{X8475671278948DDD}{}3396{3397\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{Unicode({\mdseries\slshape list[, encoding]})\index{Unicode@\texttt{Unicode}}3398\label{Unicode}3399}\hfill{\scriptsize (operation)}}\\3400\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{UChar({\mdseries\slshape num})\index{UChar@\texttt{UChar}}3401\label{UChar}3402}\hfill{\scriptsize (operation)}}\\3403\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{IsUnicodeString\index{IsUnicodeString@\texttt{IsUnicodeString}}3404\label{IsUnicodeString}3405}\hfill{\scriptsize (filter)}}\\3406\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{IsUnicodeCharacter\index{IsUnicodeCharacter@\texttt{IsUnicodeCharacter}}3407\label{IsUnicodeCharacter}3408}\hfill{\scriptsize (filter)}}\\3409\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{IntListUnicodeString({\mdseries\slshape ustr})\index{IntListUnicodeString@\texttt{IntListUnicodeString}}3410\label{IntListUnicodeString}3411}\hfill{\scriptsize (function)}}\\341234133414Unicode characters are described by their \emph{codepoint}, an integer in the range from $0$ to $2^{21}-1$. For details about unicode, see \href{http://www.unicode.org} {\texttt{http://www.unicode.org}}.34153416The function \texttt{UChar} wraps an integer \mbox{\texttt{\mdseries\slshape num}} into a \textsf{GAP} object lying in the filter \texttt{IsUnicodeCharacter}. Use \texttt{Int} to get the codepoint back. The argument \mbox{\texttt{\mdseries\slshape num}} can also be a \textsf{GAP} character which is then translated to an integer via \texttt{IntChar} (\textbf{Reference: IntChar}).34173418\texttt{Unicode} produces a \textsf{GAP} object in the filter \texttt{IsUnicodeString}. This is a wrapped list of integers for the unicode characters in the string.3419The function \texttt{IntListUnicodeString} gives access to this list of integers. Basic list functionality is available3420for \texttt{IsUnicodeString} elements. The entries are in \texttt{IsUnicodeCharacter}. The argument \mbox{\texttt{\mdseries\slshape list}} for \texttt{Unicode} is either a list of integers or a \textsf{GAP} string. In the latter case an \mbox{\texttt{\mdseries\slshape encoding}} can be specified as string, its default is \texttt{"UTF-8"}.34213422\index{URL encoding}\index{RFC 3986} Currently supported encodings can be found in \texttt{UNICODE{\textunderscore}RECODE.NormalizedEncodings} (ASCII, ISO-8859-X, UTF-8 and aliases). The encoding \texttt{"XML"} means an ASCII encoding in which non-ASCII characters are specified by XML3423character entities. The encoding \texttt{"URL"} is for URL-encoded (also called percent-encoded strings, as specified in RFC34243986 (\href{http://www.ietf.org/rfc/rfc3986.txt} {see here}). The listed encodings \texttt{"LaTeX"} and aliases cannot be used with \texttt{Unicode}. See the operation \texttt{Encode} (\ref{Encode}) for mapping a unicode string to a \textsf{GAP} string.342534263427\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3428!gapprompt@gap>| !gapinput@ustr := Unicode("a and \366", "latin1");|3429Unicode("a and �")3430!gapprompt@gap>| !gapinput@ustr = Unicode("a and ö", "XML"); |3431true3432!gapprompt@gap>| !gapinput@IntListUnicodeString(ustr);|3433[ 97, 32, 97, 110, 100, 32, 246 ]3434!gapprompt@gap>| !gapinput@ustr[7];|3435'�'3436\end{Verbatim}3437}3438343934403441\subsection{\textcolor{Chapter }{Encode}}3442\logpage{[ 6, 2, 2 ]}\nobreak3443\hyperdef{L}{X818A31567EB30A39}{}3444{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{Encode({\mdseries\slshape ustr[, encoding]})\index{Encode@\texttt{Encode}}3445\label{Encode}3446}\hfill{\scriptsize (operation)}}\\3447\textbf{\indent Returns:\ }3448a \textsf{GAP} string34493450\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SimplifiedUnicodeString({\mdseries\slshape ustr[, encoding][, "single"]})\index{SimplifiedUnicodeString@\texttt{SimplifiedUnicodeString}}3451\label{SimplifiedUnicodeString}3452}\hfill{\scriptsize (function)}}\\3453\textbf{\indent Returns:\ }3454a unicode string34553456\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LowercaseUnicodeString({\mdseries\slshape ustr})\index{LowercaseUnicodeString@\texttt{LowercaseUnicodeString}}3457\label{LowercaseUnicodeString}3458}\hfill{\scriptsize (function)}}\\3459\textbf{\indent Returns:\ }3460a unicode string34613462\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{UppercaseUnicodeString({\mdseries\slshape ustr})\index{UppercaseUnicodeString@\texttt{UppercaseUnicodeString}}3463\label{UppercaseUnicodeString}3464}\hfill{\scriptsize (function)}}\\3465\textbf{\indent Returns:\ }3466a unicode string34673468\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LaTeXUnicodeTable\index{LaTeXUnicodeTable@\texttt{LaTeXUnicodeTable}}3469\label{LaTeXUnicodeTable}3470}\hfill{\scriptsize (global variable)}}\\3471\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SimplifiedUnicodeTable\index{SimplifiedUnicodeTable@\texttt{SimplifiedUnicodeTable}}3472\label{SimplifiedUnicodeTable}3473}\hfill{\scriptsize (global variable)}}\\3474\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LowercaseUnicodeTable\index{LowercaseUnicodeTable@\texttt{LowercaseUnicodeTable}}3475\label{LowercaseUnicodeTable}3476}\hfill{\scriptsize (global variable)}}\\347734783479The operation \texttt{Encode} translates a unicode string \mbox{\texttt{\mdseries\slshape ustr}} into a \textsf{GAP} string in some specified \mbox{\texttt{\mdseries\slshape encoding}}. The default encoding is \texttt{"UTF-8"}.34803481Supported encodings can be found in \texttt{UNICODE{\textunderscore}RECODE.NormalizedEncodings}. Except for some cases mentioned below characters which are not available in3482the target encoding are substituted by '?' characters.34833484If the \mbox{\texttt{\mdseries\slshape encoding}} is \texttt{"URL"} (see \texttt{Unicode} (\ref{Unicode})) then an optional argument \mbox{\texttt{\mdseries\slshape encreserved}} can be given, it must be a list of reserved characters which should be percent3485encoded; the default is to encode only the \texttt{\%} character.34863487The encoding \texttt{"LaTeX"} substitutes non-ASCII characters and {\LaTeX} special characters by {\LaTeX} code as given in an ordered list \texttt{LaTeXUnicodeTable} of pairs [codepoint, string]. If you have a unicode character for which no3488substitution is contained in that list, you will get a warning and the3489translation is \texttt{Unicode(nr)}. In this case find a substitution and add a corresponding [codepoint, string]3490pair to \texttt{LaTeXUnicodeTable} using \texttt{AddSet} (\textbf{Reference: AddSet}). Also, please, tell the \textsf{GAPDoc} authors about your addition, such that we can extend the list \texttt{LaTeXUnicodeTable}. (Most of the initial entries were generated from lists in the {\TeX} projects enc{\TeX} and \texttt{ucs}.) There are some variants of this encoding:34913492\texttt{"LaTeXleavemarkup"} does the same translations for non-ASCII characters but leaves the {\LaTeX} special characters (e.g., any {\LaTeX} commands) as they are.34933494\texttt{"LaTeXUTF8"} does not give a warning about unicode characters without explicit translation,3495instead it translates the character to its \texttt{UTF-8} encoding. Make sure to setup your {\LaTeX} document such that all these characters are understood.34963497\texttt{"LaTeXUTF8leavemarkup"} is a combination of the last two variants.34983499Note that the \texttt{"LaTeX"} encoding can only be used with \texttt{Encode} but not for the opposite translation with \texttt{Unicode} (\ref{Unicode}) (which would need far too complicated heuristics).35003501The function \texttt{SimplifiedUnicodeString} can be used to substitute many non-ASCII characters by related ASCII3502characters or strings (e.g., by a corresponding character without accents).3503The argument \mbox{\texttt{\mdseries\slshape ustr}} and the result are unicode strings, if \mbox{\texttt{\mdseries\slshape encoding}} is \texttt{"ASCII"} then all non-ASCII characters are translated, otherwise only the non-latin13504characters. If the string \texttt{"single"} in an argument then only substitutions are considered which don't make the3505result string longer. The translations are stored in a sorted list \texttt{SimplifiedUnicodeTable}. Its entries are of the form \texttt{[codepoint, trans1, trans2, ...]}. Here \texttt{trans1} and so on is either an integer for the codepoint of a substitution character3506or it is a list of codepoint integers. If you are missing characters in this3507list and know a sensible ASCII approximation, then add an entry (with \texttt{AddSet} (\textbf{Reference: AddSet})) and tell the \textsf{GAPDoc} authors about it. (The initial content of \texttt{SimplifiedUnicodeTable} was mainly generated from the ``\texttt{transtab}'' tables by Markus Kuhn.)35083509The function \texttt{LowercaseUnicodeString} gets and returns a unicode string and translates each uppercase character to3510its corresponding lowercase version. This function uses a list \texttt{LowercaseUnicodeTable} of pairs of codepoint integers. This list was generated using the file \texttt{UnicodeData.txt} from the unicode definition (field 14 in each row).35113512The function \texttt{UppercaseUnicodeString} does the similar translation to uppercase characters.3513\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3514!gapprompt@gap>| !gapinput@ustr := Unicode("a and ö", "XML");|3515Unicode("a and �")3516!gapprompt@gap>| !gapinput@SimplifiedUnicodeString(ustr, "ASCII");|3517Unicode("a and oe")3518!gapprompt@gap>| !gapinput@SimplifiedUnicodeString(ustr, "ASCII", "single");|3519Unicode("a and o")3520!gapprompt@gap>| !gapinput@ustr2 := UppercaseUnicodeString(ustr);;|3521!gapprompt@gap>| !gapinput@Print(Encode(ustr2, GAPInfo.TermEncoding), "\n");|3522A AND �3523\end{Verbatim}3524}352535263527\subsection{\textcolor{Chapter }{Lengths of UTF-8 strings}}\logpage{[ 6, 2, 3 ]}3528\hyperdef{L}{X801237207E06A876}{}3529{3530\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WidthUTF8String({\mdseries\slshape str})\index{WidthUTF8String@\texttt{WidthUTF8String}}3531\label{WidthUTF8String}3532}\hfill{\scriptsize (function)}}\\3533\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{NrCharsUTF8String({\mdseries\slshape str})\index{NrCharsUTF8String@\texttt{NrCharsUTF8String}}3534\label{NrCharsUTF8String}3535}\hfill{\scriptsize (function)}}\\3536\textbf{\indent Returns:\ }3537an integer3538353935403541Let \mbox{\texttt{\mdseries\slshape str}} be a \textsf{GAP} string with text in UTF-8 encoding. There are three ``lengths'' of such a string which must be distinguished. The operation \texttt{Length} (\textbf{Reference: Length}) returns the number of bytes and so the memory occupied by \mbox{\texttt{\mdseries\slshape str}}. The function \texttt{NrCharsUTF8String} returns the number of unicode characters in \mbox{\texttt{\mdseries\slshape str}}, that is the length of \texttt{Unicode(\mbox{\texttt{\mdseries\slshape str}})}.35423543In many applications the function \texttt{WidthUTF8String} is more interesting, it returns the number of columns needed by the string if3544printed to a terminal. This takes into account that some unicode characters3545are combining characters and that there are wide characters which need two3546columns (e.g., for Chinese or Japanese). (To be precise: This implementation3547assumes that there are no control characters in \mbox{\texttt{\mdseries\slshape str}} and uses the character width returned by the \texttt{wcwidth} function in the GNU C-library called with UTF-8 locale.)3548\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3549!gapprompt@gap>| !gapinput@# A, German umlaut u, B, zero width space, C, newline|3550!gapprompt@gap>| !gapinput@str := Encode( Unicode( "AüB​C\n", "XML" ) );;|3551!gapprompt@gap>| !gapinput@Print(str);|3552A�BC3553!gapprompt@gap>| !gapinput@# umlaut u needs two bytes and the zero width space three|3554!gapprompt@gap>| !gapinput@Length(str);|355593556!gapprompt@gap>| !gapinput@NrCharsUTF8String(str);|355763558!gapprompt@gap>| !gapinput@# zero width space and newline don't contribute to width|3559!gapprompt@gap>| !gapinput@WidthUTF8String(str);|356043561\end{Verbatim}3562}3563356435653566\subsection{\textcolor{Chapter }{InitialSubstringUTF8String}}3567\logpage{[ 6, 2, 4 ]}\nobreak3568\hyperdef{L}{X7E2974CD84977819}{}3569{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{InitialSubstringUTF8String({\mdseries\slshape str, maxwidth})\index{InitialSubstringUTF8String@\texttt{InitialSubstringUTF8String}}3570\label{InitialSubstringUTF8String}3571}\hfill{\scriptsize (function)}}\\3572\textbf{\indent Returns:\ }3573UTF-8 encoded string3574357535763577The argument \mbox{\texttt{\mdseries\slshape str}} must be a \textsf{GAP} string with text in UTF-8 encoding or a unicode string. The function returns3578the longest initial substring of \mbox{\texttt{\mdseries\slshape str}} which has at most visible width \mbox{\texttt{\mdseries\slshape maxwidth}}, as UTF-8 encoded \textsf{GAP} string.3579\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3580!gapprompt@gap>| !gapinput@# A, German umlaut u, B, zero width space, C, newline|3581!gapprompt@gap>| !gapinput@str := Encode( Unicode( "AüB​C\n", "XML" ) );;|3582!gapprompt@gap>| !gapinput@ini := InitialSubstringUTF8String(str, 3);;|3583!gapprompt@gap>| !gapinput@WidthUTF8String(ini);|358433585!gapprompt@gap>| !gapinput@IntListUnicodeString(Unicode(ini));|3586[ 65, 252, 66, 8203 ]3587\end{Verbatim}3588}35893590}359135923593\section{\textcolor{Chapter }{Print Utilities}}\label{PrintUtil}3594\logpage{[ 6, 3, 0 ]}3595\hyperdef{L}{X860C83047DC4F1BC}{}3596{3597The following printing utilities turned out to be useful for interactive work3598with texts in \textsf{GAP}. But they are more general and so we document them here.35993600\subsection{\textcolor{Chapter }{PrintTo1}}3601\logpage{[ 6, 3, 1 ]}\nobreak3602\hyperdef{L}{X8603B90C7C3F0AB1}{}3603{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{PrintTo1({\mdseries\slshape filename, fun})\index{PrintTo1@\texttt{PrintTo1}}3604\label{PrintTo1}3605}\hfill{\scriptsize (function)}}\\3606\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{AppendTo1({\mdseries\slshape filename, fun})\index{AppendTo1@\texttt{AppendTo1}}3607\label{AppendTo1}3608}\hfill{\scriptsize (function)}}\\360936103611The argument \mbox{\texttt{\mdseries\slshape fun}} must be a function without arguments. Everything which is printed by a call \mbox{\texttt{\mdseries\slshape fun()}} is printed into the file \mbox{\texttt{\mdseries\slshape filename}}. As with \texttt{PrintTo} (\textbf{Reference: PrintTo}) and \texttt{AppendTo} (\textbf{Reference: AppendTo}) this overwrites or appends to, respectively, a previous content of \mbox{\texttt{\mdseries\slshape filename}}.36123613These functions can be particularly efficient when many small pieces of text3614shall be written to a file, because no multiple reopening of the file is3615necessary.3616\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3617!gapprompt@gap>| !gapinput@f := function() local i; |3618!gapprompt@>| !gapinput@ for i in [1..100000] do Print(i, "\n"); od; end;; |3619!gapprompt@gap>| !gapinput@PrintTo1("nonsense", f); # now check the local file `nonsense'|3620\end{Verbatim}3621}3622362336243625\subsection{\textcolor{Chapter }{StringPrint}}3626\logpage{[ 6, 3, 2 ]}\nobreak3627\hyperdef{L}{X829B720C86E57E8B}{}3628{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringPrint({\mdseries\slshape obj1[, obj2[, ...]]})\index{StringPrint@\texttt{StringPrint}}3629\label{StringPrint}3630}\hfill{\scriptsize (function)}}\\3631\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringView({\mdseries\slshape obj})\index{StringView@\texttt{StringView}}3632\label{StringView}3633}\hfill{\scriptsize (function)}}\\363436353636These functions return a string containing the output of a \texttt{Print} or \texttt{ViewObj} call with the same arguments.36373638This should be considered as a (temporary?) hack. It would be better to have \texttt{String} (\textbf{Reference: String}) methods for all \textsf{GAP} objects and to have a generic \texttt{Print} (\textbf{Reference: Print})-function which just interprets these strings. }3639364036413642\subsection{\textcolor{Chapter }{PrintFormattedString}}3643\logpage{[ 6, 3, 3 ]}\nobreak3644\hyperdef{L}{X812A8326844BC910}{}3645{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{PrintFormattedString({\mdseries\slshape str})\index{PrintFormattedString@\texttt{PrintFormattedString}}3646\label{PrintFormattedString}3647}\hfill{\scriptsize (function)}}\\364836493650This function prints a string \mbox{\texttt{\mdseries\slshape str}}. The difference to \texttt{Print(str);} is that no additional line breaks are introduced by \textsf{GAP}'s standard printing mechanism. This can be used to print lines which are3651longer than the current screen width. In particular one can print text which3652contains escape sequences like those explained in \texttt{TextAttr} (\ref{TextAttr}), where lines may have more characters than \emph{visible characters}. }3653365436553656\subsection{\textcolor{Chapter }{Page}}3657\logpage{[ 6, 3, 4 ]}\nobreak3658\hyperdef{L}{X7BB6731F7E3AAA98}{}3659{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{Page({\mdseries\slshape ...})\index{Page@\texttt{Page}}3660\label{Page}3661}\hfill{\scriptsize (function)}}\\3662\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{PageDisplay({\mdseries\slshape obj})\index{PageDisplay@\texttt{PageDisplay}}3663\label{PageDisplay}3664}\hfill{\scriptsize (function)}}\\366536663667These functions are similar to \texttt{Print} (\textbf{Reference: Print}) and \texttt{Display} (\textbf{Reference: Display}), respectively. The difference is that the output is not sent directly to the3668screen, but is piped into the current pager; see \texttt{Pager} (\textbf{Reference: Pager}).3669\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3670!gapprompt@gap>| !gapinput@Page([1..1421]+0);|3671!gapprompt@gap>| !gapinput@PageDisplay(CharacterTable("Symmetric", 14));|3672\end{Verbatim}3673}3674367536763677\subsection{\textcolor{Chapter }{StringFile}}3678\logpage{[ 6, 3, 5 ]}\nobreak3679\hyperdef{L}{X7E14D32181FBC3C3}{}3680{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringFile({\mdseries\slshape filename})\index{StringFile@\texttt{StringFile}}3681\label{StringFile}3682}\hfill{\scriptsize (function)}}\\3683\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{FileString({\mdseries\slshape filename, str[, append]})\index{FileString@\texttt{FileString}}3684\label{FileString}3685}\hfill{\scriptsize (function)}}\\368636873688The function \texttt{StringFile} returns the content of file \mbox{\texttt{\mdseries\slshape filename}} as a string. This works efficiently with arbitrary (binary or text) files. If3689something went wrong, this function returns \texttt{fail}.36903691Conversely the function \texttt{FileString} writes the content of a string \mbox{\texttt{\mdseries\slshape str}} into the file \mbox{\texttt{\mdseries\slshape filename}}. If the optional third argument \mbox{\texttt{\mdseries\slshape append}} is given and equals \texttt{true} then the content of \mbox{\texttt{\mdseries\slshape str}} is appended to the file. Otherwise previous content of the file is deleted.3692This function returns the number of bytes written or \texttt{fail} if something went wrong.36933694Both functions are quite efficient, even with large files. }36953696}36973698}369937003701\chapter{\textcolor{Chapter }{Utilities for Bibliographies}}\label{ch:bibutil}3702\logpage{[ 7, 0, 0 ]}3703\hyperdef{L}{X7EB94CE97ABF7192}{}3704{3705A standard for collecting references (in particular to mathematical texts) is Bib{\TeX} (\href{http://www.ctan.org/tex-archive/biblio/bibtex/distribs/doc/} {\texttt{http://www.ctan.org/tex-archive/biblio/bibtex/distribs/doc/}}). A disadvantage of Bib{\TeX} is that the format of the data is specified with the use by {\LaTeX} in mind. The data format is less suited for conversion to other document types3706like plain text or HTML.37073708In the first section we describe utilities for using data from Bib{\TeX} files in \textsf{GAP}.37093710In the second section we introduce a new XML based data format BibXMLext for3711bibliographies which seems better suited for other tasks than using it with {\LaTeX}.37123713Another section will describe utilities to deal with BibXMLext data in \textsf{GAP}.3714\section{\textcolor{Chapter }{Parsing Bib{\TeX} Files}}\label{ParseBib}3715\logpage{[ 7, 1, 0 ]}3716\hyperdef{L}{X7A4126EC7BD68F64}{}3717{3718Here are functions for parsing, normalizing and printing reference lists in Bib{\TeX} format. The reference describing this format is{\nobreakspace}\cite[Appendix B]{La85}.37193720\subsection{\textcolor{Chapter }{ParseBibFiles}}3721\logpage{[ 7, 1, 1 ]}\nobreak3722\hyperdef{L}{X82555C307FDC1817}{}3723{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseBibFiles({\mdseries\slshape bibfile1[, bibfile2[, ...]]})\index{ParseBibFiles@\texttt{ParseBibFiles}}3724\label{ParseBibFiles}3725}\hfill{\scriptsize (function)}}\\3726\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseBibStrings({\mdseries\slshape str1[, str2[, ...]]})\index{ParseBibStrings@\texttt{ParseBibStrings}}3727\label{ParseBibStrings}3728}\hfill{\scriptsize (function)}}\\3729\textbf{\indent Returns:\ }3730list \texttt{[list of bib-records, list of abbrevs, list of expansions]}3731373237333734The first function parses the files \mbox{\texttt{\mdseries\slshape bibfile1}} and so on (if a file does not exist the extension \texttt{.bib} is appended) in Bib{\TeX} format and returns a list as follows: \texttt{[entries, strings, texts]}. Here \texttt{entries} is a list of records, one record for each reference contained in \mbox{\texttt{\mdseries\slshape bibfile}}. Then \texttt{strings} is a list of abbreviations defined by \texttt{@string}-entries in \mbox{\texttt{\mdseries\slshape bibfile}} and \texttt{texts} is a list which contains in the corresponding position the full text for such3735an abbreviation.37363737The second function does the same, but the input is given as \textsf{GAP} strings \mbox{\texttt{\mdseries\slshape str1}} and so on.37383739The records in \texttt{entries} store key-value pairs of a Bib{\TeX} reference in the form \texttt{rec(key1 = value1, ...)}. The names of the keys are converted to lower case. The type of the reference3740(i.e., book, article, ...) and the citation key are stored as components \texttt{.Type} and \texttt{.Label}. The records also have a \texttt{.From} field that says that the data are read from a Bib{\TeX} source.37413742As an example consider the following Bib{\TeX} file.3743\begin{Verbatim}[fontsize=\small,frame=single,label=doc/test.bib]3744@string{ j = "Important Journal" }3745@article{ AB2000, Author= "Fritz A. First and Sec, X. Y.",3746TITLE="Short", journal = j, year = 2000 }3747\end{Verbatim}37483749\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3750!gapprompt@gap>| !gapinput@bib := ParseBibFiles("doc/test.bib");|3751[ [ rec( From := rec( BibTeX := true ), Label := "AB2000",3752Type := "article", author := "Fritz A. First and Sec, X. Y."3753, journal := "Important Journal", title := "Short",3754year := "2000" ) ], [ "j" ], [ "Important Journal" ] ]3755\end{Verbatim}3756}3757375837593760\subsection{\textcolor{Chapter }{NormalizedNameAndKey}}3761\logpage{[ 7, 1, 2 ]}\nobreak3762\hyperdef{L}{X7C9F0C337A0A0FF0}{}3763{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{NormalizedNameAndKey({\mdseries\slshape namestr})\index{NormalizedNameAndKey@\texttt{NormalizedNameAndKey}}3764\label{NormalizedNameAndKey}3765}\hfill{\scriptsize (function)}}\\3766\textbf{\indent Returns:\ }3767list of strings and names as lists37683769\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{NormalizeNameAndKey({\mdseries\slshape r})\index{NormalizeNameAndKey@\texttt{NormalizeNameAndKey}}3770\label{NormalizeNameAndKey}3771}\hfill{\scriptsize (function)}}\\3772\textbf{\indent Returns:\ }3773nothing3774377537763777The argument \mbox{\texttt{\mdseries\slshape namestr}} must be a string describing an author or a list of authors as described in the Bib{\TeX} documentation in \cite[Appendix B 1.2]{La85}. The function \texttt{NormalizedNameAndKey} returns a list of the form [ normalized name string, short key, long key,3778names as lists]. The first entry is a normalized form of the input where names3779are written as ``lastname, first name initials''. The second and third entry are the name parts of a short and long key for3780the bibliography entry, formed from the (initials of) last names. The fourth3781entry is a list of lists, one for each name, where a name is described by3782three strings for the last name, the first name initials and the first name(s)3783as given in the input.37843785The function \texttt{NormalizeNameAndKey} gets as argument \mbox{\texttt{\mdseries\slshape r}} a record for a bibliography entry as returned by \texttt{ParseBibFiles} (\ref{ParseBibFiles}). It substitutes \texttt{.author} and \texttt{.editor} fields of \mbox{\texttt{\mdseries\slshape r}} by their normalized form, the original versions are stored in fields \texttt{.authororig} and \texttt{.editororig}.37863787Furthermore a short and a long citation key is generated and stored in3788components \texttt{.printedkey} (only if no \texttt{.key} is already bound) and \texttt{.keylong}.37893790We continue the example from \texttt{ParseBibFiles} (\ref{ParseBibFiles}).3791\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3792!gapprompt@gap>| !gapinput@bib := ParseBibFiles("doc/test.bib");;|3793!gapprompt@gap>| !gapinput@NormalizedNameAndKey(bib[1][1].author);|3794[ "First, F. A. and Sec, X. Y.", "FS", "firstsec",3795[ [ "First", "F. A.", "Fritz A." ], [ "Sec", "X. Y.", "X. Y." ] ] ]3796!gapprompt@gap>| !gapinput@NormalizeNameAndKey(bib[1][1]);|3797!gapprompt@gap>| !gapinput@bib[1][1];|3798rec( From := rec( BibTeX := true ), Label := "AB2000",3799Type := "article", author := "First, F. A. and Sec, X. Y.",3800authororig := "Fritz A. First and Sec, X. Y.",3801journal := "Important Journal", keylong := "firstsec2000",3802printedkey := "FS00", title := "Short", year := "2000" )3803\end{Verbatim}3804}3805380638073808\subsection{\textcolor{Chapter }{WriteBibFile}}3809\logpage{[ 7, 1, 3 ]}\nobreak3810\hyperdef{L}{X7C2B2F65851EAA0B}{}3811{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WriteBibFile({\mdseries\slshape bibfile, bib})\index{WriteBibFile@\texttt{WriteBibFile}}3812\label{WriteBibFile}3813}\hfill{\scriptsize (function)}}\\3814\textbf{\indent Returns:\ }3815nothing3816381738183819This is the converse of \texttt{ParseBibFiles} (\ref{ParseBibFiles}). Here \mbox{\texttt{\mdseries\slshape bib}} either must have a format as list of three lists as it is returned by \texttt{ParseBibFiles} (\ref{ParseBibFiles}). Or \mbox{\texttt{\mdseries\slshape bib}} can be a record as returned by \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}). A Bib{\TeX} file \mbox{\texttt{\mdseries\slshape bibfile}} is written and the entries are formatted in a uniform way. All given3820abbreviations are used while writing this file.38213822We continue the example from \texttt{NormalizeNameAndKey} (\ref{NormalizeNameAndKey}). The command3823\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3824!gapprompt@gap>| !gapinput@WriteBibFile("nicer.bib", bib);|3825\end{Verbatim}3826produces a file \texttt{nicer.bib} as follows:3827\begin{Verbatim}[fontsize=\small,frame=single,label=nicer.bib]3828@string{j = "Important Journal" }38293830@article{ AB2000,3831author = {First, F. A. and Sec, X. Y.},3832title = {Short},3833journal = j,3834year = {2000},3835authororig = {Fritz A. First and Sec, X. Y.},3836keylong = {firstsec2000},3837printedkey = {FS00}3838}3839\end{Verbatim}3840}3841384238433844\subsection{\textcolor{Chapter }{LabelsFromBibTeX}}3845\logpage{[ 7, 1, 4 ]}\nobreak3846\hyperdef{L}{X783FD118794399DF}{}3847{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{LabelsFromBibTeX({\mdseries\slshape path, keys, bibfiles, style})\index{LabelsFromBibTeX@\texttt{LabelsFromBibTeX}}3848\label{LabelsFromBibTeX}3849}\hfill{\scriptsize (function)}}\\3850\textbf{\indent Returns:\ }3851a list of pairs of strings \texttt{[key, label]}3852385338543855This function uses \texttt{bibtex} to determine the ordering of a list of references and a label for each entry3856which is typeset in a document citing these references.38573858The argument \mbox{\texttt{\mdseries\slshape path}} is a directory specified as string or directory object. The argument \mbox{\texttt{\mdseries\slshape bibfiles}} must be a list of files in Bib{\TeX} format, each specified by a path relative to the first argument, or an3859absolute path (starting with \texttt{'/'}) or relative to the \textsf{GAP} roots (starting with \texttt{"gap://"}). The list \mbox{\texttt{\mdseries\slshape keys}} must contain strings which occur as keys in the given Bib{\TeX} files. Finally the string \mbox{\texttt{\mdseries\slshape style}} must be the name of a bibliography style (like \texttt{"alpha"}).38603861The list returned by this function contains pairs \texttt{[key, label]} where \texttt{key} is one of the entries of \mbox{\texttt{\mdseries\slshape keys}} and \texttt{label} is a string used for citations of the bibliography entry in a document. These3862pairs are ordered as the reference list produced by Bib{\TeX}.3863\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]3864!gapprompt@gap>| !gapinput@f := Filename(DirectoriesPackageLibrary("gapdoc","doc"), "test.bib");;|3865!gapprompt@gap>| !gapinput@LabelsFromBibTeX(".", ["AB2000"], [f], "alpha");|3866[ [ "AB2000", "FS00" ] ]3867\end{Verbatim}3868}3869387038713872\subsection{\textcolor{Chapter }{InfoBibTools}}3873\logpage{[ 7, 1, 5 ]}\nobreak3874\hyperdef{L}{X85C1D50F7E37A99A}{}3875{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{InfoBibTools\index{InfoBibTools@\texttt{InfoBibTools}}3876\label{InfoBibTools}3877}\hfill{\scriptsize (info class)}}\\387838793880The default level of this info class is 1. Functions like \texttt{ParseBibFiles} (\ref{ParseBibFiles}), \texttt{StringBibAs...} are then printing some information. You can suppress it by setting the level3881of \texttt{InfoBibTools} to 0. With level 2 there may be some more information for debugging purposes. }38823883}388438853886\section{\textcolor{Chapter }{The BibXMLext Format}}\label{BibXMLformat}3887\logpage{[ 7, 2, 0 ]}3888\hyperdef{L}{X7FB8F6BD80D859D1}{}3889{3890Bibliographical data in Bib{\TeX} files have the disadvantage that the actual data are given in {\LaTeX} syntax. This makes it difficult to use the data for anything but for {\LaTeX}, say for representations of the data as plain text or HTML. For example:3891mathematical formulae are in {\LaTeX} \texttt{\$} environments, non-ASCII characters can be specified in many strange ways, and3892how to specify URLs for links if the output format allows them?38933894Here we propose an XML data format for bibliographical data which addresses3895these problems, it is called BibXMLext. In the next section we describe some3896tools for generating (an approximation to) this data format from Bib{\TeX} data, and for using data given in BibXMLext format for various purposes.38973898The first motivation for this development was the handling of bibliographical3899data in \textsf{GAPDoc}, but the format and the tools are certainly useful for other purposes as3900well.39013902We started from a DTD \texttt{bibxml.dtd} which is publicly available, say from \href{http://bibtexml.sf.net/} {\texttt{http://bibtexml.sf.net/}}. This is essentially a reformulation of the definition of the Bib{\TeX} format, including several of some widely used further fields. This has already3903the advantage that a generic XML parser can check the validity of the data3904entries, for example for missing compulsary fields in entries. We applied the3905following changes and extensions to define the DTD for BibXMLext, stored in3906the file \texttt{bibxmlext.dtd} which can be found in the root directory of this \textsf{GAPDoc} package (and in Appendix \ref{bibxmlextdtd}):3907\begin{description}3908\item[{names}] Lists of names in the \texttt{author} and \texttt{editor} fields in Bib{\TeX} are difficult to parse. Here they must be given by a sequence of \texttt{{\textless}name{\textgreater}}-elements which each contain an optional \texttt{{\textless}first{\textgreater}}- and a \texttt{{\textless}last{\textgreater}}-element for the first and last names, respectively.3909\item[{\texttt{{\textless}M{\textgreater}} and \texttt{{\textless}Math{\textgreater}}}] These elements enclose mathematical formulae, the content is {\LaTeX} code (without the \texttt{\$}). These should be handled in the same way as the elements with the same names3910in \textsf{GAPDoc}, see \ref{M} and \ref{Math}. In particular, simple formulae which have a well defined plain text3911representation can be given in \texttt{{\textless}M{\textgreater}}-elements.3912\item[{Encoding}] Note that in XML files we can use the full range of unicode characters, see \href{http://www.unicode.org/} {\texttt{http://www.unicode.org/}}. All non-ASCII characters should be specified as unicode characters. This3913makes dealing with special characters easy for plain text or HTML, only for3914use with {\LaTeX} some sort of translation is necessary.3915\item[{\texttt{{\textless}URL{\textgreater}}}] These elements are allowed everywhere in the text and should be represented by3916links in converted formats which allow this. It is used in the same way as the3917element with the same name in \textsf{GAPDoc}, see \ref{URL}.3918\item[{\texttt{{\textless}Alt Only="..."{\textgreater}} and \texttt{{\textless}Alt Not="..."{\textgreater}}}] Sometimes information should be given in different ways, depending on the3919output format of the data. This is possible with the \texttt{{\textless}Alt{\textgreater}}-elements with the same definition as in \textsf{GAPDoc}, see \ref{Alt}.3920\item[{\texttt{{\textless}C{\textgreater}}}] This element should be used to protect text from case changes by converters3921(the extra \texttt{\texttt{\symbol{123}}\texttt{\symbol{125}}} characters in Bib{\TeX} title fields).3922\item[{\texttt{{\textless}string key="..." value="..."/{\textgreater}} and \texttt{{\textless}value key="..."/{\textgreater}}}] The \texttt{{\textless}string{\textgreater}}-element defines key-value pairs which can be used in any field via the \texttt{{\textless}value{\textgreater}}-element (not only for whole fields but also parts of the text).3923\item[{\texttt{{\textless}other type="..."{\textgreater}}}] This is a generic element for fields which are otherwise not supported. An3924arbitrary number of them is allowed for each entry, so any kind of additional3925data can be added to entries.3926\item[{\texttt{{\textless}Wrap Name="..."{\textgreater}}}] This generic element is allowed inside all fields. This markup will be just3927ignored (but not the element content) by our standard tools. But it can be a3928useful hook for introducing arbitrary further markup (and our tools can easily3929be extended to handle it).3930\item[{Extra entities}] The DTD defines the standard XML entities (\ref{XMLspchar} and the entities \texttt{\ } (non-breakable space), \texttt{\–} and \texttt{\©right;}. Use \texttt{\–} in page ranges.3931\end{description}3932For further details of the DTD we refer to the file \texttt{bibxmlext.dtd} itself which is shown in appendix \ref{bibxmlextdtd}. That file also recalls some information from the Bib{\TeX} documentation on how the standard fields of entries should be used. Which3933entry types and which fields are supported (and the ordering of the fields3934which is fixed by a DTD) can be either read off the DTD, or within \textsf{GAP} one can use the function \texttt{TemplateBibXML} (\ref{TemplateBibXML}) to get templates for the various entry types.39353936Here is an example of a BibXMLext document:3937\begin{Verbatim}[fontsize=\small,frame=single,label=doc/testbib.xml]3938<?xml version="1.0" encoding="UTF-8"?>3939<!DOCTYPE file SYSTEM "bibxmlext.dtd">3940<file>3941<string key="j" value="Important Journal"/>3942<entry id="AB2000"><article>3943<author>3944<name><first>Fritz A.</first><last>First</last></name>3945<name><first>X. Y.</first><last>Secőnd</last></name>3946</author>3947<title>The <Wrap Name="Package"> <C>F</C>ritz</Wrap> package for the3948formula <M>x^y - l_{{i+1}} \rightarrow \mathbb{R}</M></title>3949<journal><value key="j"/></journal>3950<year>2000</year>3951<number>13</number>3952<pages>13–25</pages>3953<note>Online data at <URL Text="Bla Bla Publisher">3954http://www.publish.com/~ImpJ/123#data</URL></note>3955<other type="mycomment">very useful</other>3956</article></entry>3957</file>39583959\end{Verbatim}3960There is a standard XML header and a \texttt{DOCTYPE} declaration referring to the \texttt{bibxmlext.dtd} DTD mentioned above. Local entities could be defined in the \texttt{DOCTYPE} tag as shown in the example in \ref{GDent}. The actual content of the document is inside a \texttt{{\textless}file{\textgreater}}-element, it consists of \texttt{{\textless}string{\textgreater}}- and \texttt{{\textless}entry{\textgreater}}-elements. Several of the BibXMLext markup features are shown. We will use3961this input document for some examples below. }396239633964\section{\textcolor{Chapter }{Utilities for BibXMLext data}}\label{BibXMLtools}3965\logpage{[ 7, 3, 0 ]}3966\hyperdef{L}{X7AC255DE7D2531B6}{}3967{39683969\subsection{\textcolor{Chapter }{Translating Bib{\TeX} to BibXMLext}}\label{Subsect:IntroXMLBib}3970\logpage{[ 7, 3, 1 ]}3971\hyperdef{L}{X7C5548E77ECA29D7}{}3972{3973First we describe a tool which can translate bibliography entries from Bib{\TeX} data to BibXMLext \texttt{{\textless}entry{\textgreater}}-elements. It also does some validation of the data. In some cases it is3974desirable to improve the result by hand afterwards (editing formulae, adding \texttt{{\textless}URL{\textgreater}}-elements, translating non-ASCII characters to unicode, ...).39753976See \texttt{WriteBibXMLextFile} (\ref{WriteBibXMLextFile}) below for how to write the results to a BibXMLext file. }3977397839793980\subsection{\textcolor{Chapter }{HeuristicTranslationsLaTeX2XML.Apply}}3981\logpage{[ 7, 3, 2 ]}\nobreak3982\hyperdef{L}{X7A025E0A7A1CD390}{}3983{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{HeuristicTranslationsLaTeX2XML.Apply({\mdseries\slshape str})\index{HeuristicTranslationsLaTeX2XML.Apply@\texttt{Heuristic}\-\texttt{Translations}\-\texttt{La}\-\texttt{Te}\-\texttt{X2}\-\texttt{X}\-\texttt{M}\-\texttt{L.}\-\texttt{Apply}}3984\label{HeuristicTranslationsLaTeX2XML.Apply}3985}\hfill{\scriptsize (function)}}\\3986\textbf{\indent Returns:\ }3987a string39883989\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{HeuristicTranslationsLaTeX2XML.ApplyToFile({\mdseries\slshape fnam[, outnam]})\index{HeuristicTranslationsLaTeX2XML.ApplyToFile@\texttt{Heuristic}\-\texttt{Translations}\-\texttt{La}\-\texttt{Te}\-\texttt{X2}\-\texttt{X}\-\texttt{M}\-\texttt{L.}\-\texttt{Apply}\-\texttt{To}\-\texttt{File}}3990\label{HeuristicTranslationsLaTeX2XML.ApplyToFile}3991}\hfill{\scriptsize (function)}}\\3992\textbf{\indent Returns:\ }3993nothing3994399539963997These utilities translate some {\LaTeX} code into text in UTF-8 encoding. The input is given as a string \mbox{\texttt{\mdseries\slshape str}}, or a file name \mbox{\texttt{\mdseries\slshape fnam}}, respectively. The first function returns the translated string. The second3998function with one argument overwrites the given file with the translated text.3999Optionally, the translated file content can be written to another file, if its4000name is given as second argument \mbox{\texttt{\mdseries\slshape outnam}}.40014002The record \texttt{HeuristicTranslationsLaTeX2XML} mainly contains translations of {\LaTeX} macros for special characters which were found in hundreds of Bib{\TeX} entries from \href{http://www.ams.org/mathscinet/} {MathSciNet}. Just look at this record if you want to know how it works. It is easy to4003extend, and if you have improvements which may be of general interest, please4004send them to the \textsf{GAPDoc} author.4005\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4006!gapprompt@gap>| !gapinput@s := "\\\"u\\'{e}\\`e{\\ss}";;|4007!gapprompt@gap>| !gapinput@Print(s, "\n"); |4008\"u\'{e}\`e{\ss}4009!gapprompt@gap>| !gapinput@Print(HeuristicTranslationsLaTeX2XML.Apply(s),"\n");|4010����4011\end{Verbatim}4012}4013401440154016\subsection{\textcolor{Chapter }{StringBibAsXMLext}}4017\logpage{[ 7, 3, 3 ]}\nobreak4018\hyperdef{L}{X85F33C64787A00B7}{}4019{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringBibAsXMLext({\mdseries\slshape bibentry[, abbrvs, vals][, encoding]})\index{StringBibAsXMLext@\texttt{StringBibAsXMLext}}4020\label{StringBibAsXMLext}4021}\hfill{\scriptsize (function)}}\\4022\textbf{\indent Returns:\ }4023a string with XML code, or \texttt{fail}4024402540264027The argument \mbox{\texttt{\mdseries\slshape bibentry}} is a record representing an entry from a Bib{\TeX} file, as returned in the first list of the result of \texttt{ParseBibFiles} (\ref{ParseBibFiles}). The optional two arguments \mbox{\texttt{\mdseries\slshape abbrvs}} and \mbox{\texttt{\mdseries\slshape vals}} can be lists of abbreviations and substitution strings, as returned as second4028and third list element in the result of \texttt{ParseBibFiles} (\ref{ParseBibFiles}). The optional argument \mbox{\texttt{\mdseries\slshape encoding}} specifies the character encoding of the string components of \mbox{\texttt{\mdseries\slshape bibentry}}. If this is not given it is checked if all strings are valid UTF-8 encoded4029strings, in that case it is assumed that the encoding is UTF-8, otherwise the4030latin1 encoding is assumed.40314032The function \texttt{StringBibAsXMLext} creates XML code of an \texttt{{\textless}entry{\textgreater}}-element in \texttt{BibXMLext} format. The result is in UTF-8 encoding and contains some heuristic4033translations, like splitting name lists, finding places for \texttt{{\textless}C{\textgreater}}-elements, putting formulae in \texttt{{\textless}M{\textgreater}}-elements, substituting some characters. The result should always be checked4034and maybe improved by hand. Some validity checks are applied to the given4035data, for example if all non-optional fields are given. If this check fails4036the function returns \texttt{fail}.40374038If your Bib{\TeX} input contains {\LaTeX} markup for special characters, it can be convenient to translate this input4039with \texttt{HeuristicTranslationsLaTeX2XML.Apply} (\ref{HeuristicTranslationsLaTeX2XML.Apply}) or \texttt{HeuristicTranslationsLaTeX2XML.ApplyToFile} (\ref{HeuristicTranslationsLaTeX2XML.ApplyToFile}) before parsing it as Bib{\TeX}.40404041As an example we consider again the short Bib{\TeX} file \texttt{doc/test.bib} shown in the example for \texttt{ParseBibFiles} (\ref{ParseBibFiles}).4042\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4043!gapprompt@gap>| !gapinput@bib := ParseBibFiles("doc/test.bib");;|4044!gapprompt@gap>| !gapinput@str := StringBibAsXMLext(bib[1][1], bib[2], bib[3]);;|4045!gapprompt@gap>| !gapinput@Print(str, "\n");|4046<entry id="AB2000"><article>4047<author>4048<name><first>Fritz A.</first><last>First</last></name>4049<name><first>X. Y.</first><last>Sec</last></name>4050</author>4051<title>Short</title>4052<journal><value key="j"/></journal>4053<year>2000</year>4054</article></entry>4055\end{Verbatim}4056}40574058The following functions allow parsing of data which are already in BibXMLext4059format.40604061\subsection{\textcolor{Chapter }{ParseBibXMLextString}}4062\logpage{[ 7, 3, 4 ]}\nobreak4063\hyperdef{L}{X86BD29AE7A453721}{}4064{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseBibXMLextString({\mdseries\slshape str[, res]})\index{ParseBibXMLextString@\texttt{ParseBibXMLextString}}4065\label{ParseBibXMLextString}4066}\hfill{\scriptsize (function)}}\\4067\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{ParseBibXMLextFiles({\mdseries\slshape fname1[, fname2[, ...]]})\index{ParseBibXMLextFiles@\texttt{ParseBibXMLextFiles}}4068\label{ParseBibXMLextFiles}4069}\hfill{\scriptsize (function)}}\\4070\textbf{\indent Returns:\ }4071a record with fields \texttt{.entries}, \texttt{.strings} and \texttt{.entities}4072407340744075The first function gets a string \mbox{\texttt{\mdseries\slshape str}} containing a \texttt{BibXMLext} document or a part of it. It returns a record with the three mentioned fields.4076Here \texttt{.entries} is a list of partial XML parse trees for the \texttt{{\textless}entry{\textgreater}}-elements in \mbox{\texttt{\mdseries\slshape str}}. The field \texttt{.strings} is a list of key-value pairs from the \texttt{{\textless}string{\textgreater}}-elements in \mbox{\texttt{\mdseries\slshape str}}. And \texttt{.strings} is a list of name-value pairs of the named entities which were used during the4077parsing.40784079The optional argument \mbox{\texttt{\mdseries\slshape res}} can be the result of a former call of this function, in that case the newly4080parsed entries are added to this data structure.40814082The second function \texttt{ParseBibXMLextFiles} uses the first on the content of all files given by filenames \mbox{\texttt{\mdseries\slshape fname1}} and so on. It collects the results in a single record.40834084As an example we parse the file \texttt{testbib.xml} shown in \ref{BibXMLformat}.4085\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4086!gapprompt@gap>| !gapinput@bib := ParseBibXMLextFiles("doc/testbib.xml");;|4087!gapprompt@gap>| !gapinput@RecNames(bib);|4088[ "entries", "strings", "entities" ]4089!gapprompt@gap>| !gapinput@bib.entries;|4090[ <BibXMLext entry: AB2000> ]4091!gapprompt@gap>| !gapinput@bib.strings;|4092[ [ "j", "Important Journal" ] ]4093!gapprompt@gap>| !gapinput@bib.entities[1]; |4094[ "amp", "&#38;" ]4095\end{Verbatim}4096}4097409840994100\subsection{\textcolor{Chapter }{WriteBibXMLextFile}}4101\logpage{[ 7, 3, 5 ]}\nobreak4102\hyperdef{L}{X7811108C7E5B1709}{}4103{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{WriteBibXMLextFile({\mdseries\slshape fname, bib})\index{WriteBibXMLextFile@\texttt{WriteBibXMLextFile}}4104\label{WriteBibXMLextFile}4105}\hfill{\scriptsize (function)}}\\4106\textbf{\indent Returns:\ }4107nothing4108410941104111This function writes a BibXMLext file with name \mbox{\texttt{\mdseries\slshape fname}}.41124113There are three possibilities to specify the bibliography entries in the4114argument \mbox{\texttt{\mdseries\slshape bib}}. It can be a list of three lists as returned by \texttt{ParseBibFiles} (\ref{ParseBibFiles}). Or it can be just the first of such three lists in which case the other two4115lists are assumed to be empty. To all entries of the (first) list the function \texttt{StringBibAsXMLext} (\ref{StringBibAsXMLext}) is applied and the resulting strings are written to the result file.41164117The third possibility is that \mbox{\texttt{\mdseries\slshape bib}} is a record in the format as returned by \texttt{ParseBibXMLextString} (\ref{ParseBibXMLextString}) and \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}). In this case the entries for the BibXMLext file are produced with \texttt{StringXMLElement} (\ref{StringXMLElement}), and if \mbox{\texttt{\mdseries\slshape bib}}\texttt{.entities} is bound then it is tried to resubstitute parts of the string by the given4118entities with \texttt{EntitySubstitution} (\ref{EntitySubstitution}).41194120As an example we write back the result of the example shown for \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}) to an equivalent XML file.4121\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4122!gapprompt@gap>| !gapinput@bib := ParseBibXMLextFiles("doc/testbib.xml");;|4123!gapprompt@gap>| !gapinput@WriteBibXMLextFile("test.xml", bib);|4124\end{Verbatim}4125}412641274128\subsection{\textcolor{Chapter }{Bibliography Entries as Records}}\label{Subsect:RecBib}4129\logpage{[ 7, 3, 6 ]}4130\hyperdef{L}{X82167F1280F4310E}{}4131{4132For working with BibXMLext entries we find it convenient to first translate4133the parse tree of an entry, as returned by \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}), to a record with the field names of the entry as components whose value is4134the content of the field as string. These strings are generated with respect4135to a result type. The records are generated by the following function which4136can be customized by the user. }4137413841394140\subsection{\textcolor{Chapter }{RecBibXMLEntry}}4141\logpage{[ 7, 3, 7 ]}\nobreak4142\hyperdef{L}{X786C33ED79F425F1}{}4143{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{RecBibXMLEntry({\mdseries\slshape entry[, restype][, strings][, options]})\index{RecBibXMLEntry@\texttt{RecBibXMLEntry}}4144\label{RecBibXMLEntry}4145}\hfill{\scriptsize (function)}}\\4146\textbf{\indent Returns:\ }4147a record with fields as strings4148414941504151This function generates a content string for each field of a bibliography4152entry and assigns them to record components. This content may depend on the4153requested result type and possibly some given options.41544155The arguments are as follows: \mbox{\texttt{\mdseries\slshape entry}} is the parse tree of an \texttt{{\textless}entry{\textgreater}} element as returned by \texttt{ParseBibXMLextString} (\ref{ParseBibXMLextString}) or \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}). The optional argument \mbox{\texttt{\mdseries\slshape restype}} describes the type of the result. This package supports currently the types \texttt{"BibTeX"}, \texttt{"Text"} and \texttt{"HTML"}. The default is \texttt{"BibTeX"}. The optional argument \mbox{\texttt{\mdseries\slshape strings}} must be a list of key-value pairs as returned in the component \texttt{.strings} in the result of \texttt{ParseBibXMLextString} (\ref{ParseBibXMLextString}). The argument \mbox{\texttt{\mdseries\slshape options}} must be a record.41564157If the entry contains an \texttt{author} field then the result will also contain a component \texttt{.authorAsList} which is a list containing for each author a list with three entries of the4158form \texttt{[last name, first name initials, first name]} (the third entry means the first name as given in the data). Similarly, an \texttt{editor} field is accompanied by a component \texttt{.editorAsList}.41594160The following \mbox{\texttt{\mdseries\slshape options}} are currently supported.41614162If \texttt{options.fullname} is bound and set to \texttt{true} then the full given first names for authors and editors will be used, the4163default is to use the initials of the first names. Also, if \texttt{options.namefirstlast} is bound and set to \texttt{true} then the names are written in the form ``first-name(s) last-name'', the default is the form ``last-name, first-name(s)''.41644165If \texttt{options.href} is bound and set to \texttt{false} then the \texttt{"BibTeX"} type result will not use \texttt{\texttt{\symbol{92}}href} commands. The default is to produce \texttt{\texttt{\symbol{92}}href} commands from \texttt{{\textless}URL{\textgreater}}-elements such that {\LaTeX} with the \texttt{hyperref} package can produce links for them.41664167The content of an \texttt{{\textless}Alt{\textgreater}}-element with \texttt{Only}-attribute is included if \mbox{\texttt{\mdseries\slshape restype}} is given in the attribute and ignored otherwise, and vice versa in case of a \texttt{Not}-attribute. If \texttt{options.useAlt} is bound, it must be a list of strings to which \mbox{\texttt{\mdseries\slshape restype}} is added. Then an \texttt{{\textless}Alt{\textgreater}}-element with \texttt{Only}-attribute is evaluated if the intersection of \texttt{options.useAlt} and the types given in the attribute is not empty. In case of a \texttt{Not}-attribute the element is evaluated if this intersection is empty.41684169If \mbox{\texttt{\mdseries\slshape restype}} is \texttt{"BibTeX"} then the string fields in the result will be recoded with \texttt{Encode} (\ref{Encode}) and target \texttt{"LaTeX"}. If \texttt{options.hasLaTeXmarkup} is bound and set to \texttt{true} (for example, because the data are originally read from Bib{\TeX} files), then the target \texttt{"LaTeXleavemarkup"} will be used.41704171We use again the file shown in the example for \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}).4172\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4173!gapprompt@gap>| !gapinput@bib := ParseBibXMLextFiles("doc/testbib.xml");;|4174!gapprompt@gap>| !gapinput@e := bib.entries[1];; strs := bib.strings;;|4175!gapprompt@gap>| !gapinput@Print(RecBibXMLEntry(e, "BibTeX", strs), "\n");|4176rec(4177From := rec(4178BibXML := true,4179options := rec(4180),4181type := "BibTeX" ),4182Label := "AB2000",4183Type := "article",4184author := "First, F. A. and Sec{\\H o}nd, X. Y.",4185authorAsList :=4186[ [ "First", "F. A.", "Fritz A." ],4187[ "Sec\305\221nd", "X. Y.", "X. Y." ] ],4188journal := "Important Journal",4189mycomment := "very useful",4190note :=4191"Online data at \\href {http://www.publish.com/~ImpJ/123#data} {Bla\4192Bla Publisher}",4193number := "13",4194pages := "13{\\textendash}25",4195printedkey := "FS00",4196title :=4197"The {F}ritz package for the \n formula $x^y - l_{{i+1}} \4198\\rightarrow \\mathbb{R}$",4199year := "2000" )4200!gapprompt@gap>| !gapinput@Print(RecBibXMLEntry(e, "HTML", strs).note, "\n");|4201Online data at <a href="http://www.publish.com/~ImpJ/123#data">Bla Bla\4202Publisher</a>4203\end{Verbatim}4204}4205420642074208\subsection{\textcolor{Chapter }{AddHandlerBuildRecBibXMLEntry}}4209\logpage{[ 7, 3, 8 ]}\nobreak4210\hyperdef{L}{X8067261385905A36}{}4211{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{AddHandlerBuildRecBibXMLEntry({\mdseries\slshape elementname, restype, handler})\index{AddHandlerBuildRecBibXMLEntry@\texttt{AddHandlerBuildRecBibXMLEntry}}4212\label{AddHandlerBuildRecBibXMLEntry}4213}\hfill{\scriptsize (function)}}\\4214\textbf{\indent Returns:\ }4215nothing4216421742184219The argument \mbox{\texttt{\mdseries\slshape elementname}} must be the name of an entry field supported by the BibXMLext format, the name4220of one of the special elements \texttt{"C"}, \texttt{"M"}, \texttt{"Math"}, \texttt{"URL"} or of the form \texttt{"Wrap:myname"} or any string \texttt{"mytype"} (which then corresponds to entry fields \texttt{{\textless}other type="mytype"{\textgreater}}). The string \texttt{"Finish"} has an exceptional meaning, see below.42214222\mbox{\texttt{\mdseries\slshape restype}} is a string describing the result type for which the handler is installed, see \texttt{RecBibXMLEntry} (\ref{RecBibXMLEntry}).42234224For both arguments, \mbox{\texttt{\mdseries\slshape elementname}} and \mbox{\texttt{\mdseries\slshape restype}}, it is also possible to give lists of the described ones for installing4225several handler at once.42264227The argument \mbox{\texttt{\mdseries\slshape handler}} must be a function with five arguments of the form \mbox{\texttt{\mdseries\slshape handler}}\texttt{(entry, r, restype, strings, options)}. Here \mbox{\texttt{\mdseries\slshape entry}} is a parse tree of a BibXMLext \texttt{{\textless}entry{\textgreater}}-element, \mbox{\texttt{\mdseries\slshape r}} is a node in this tree for an element \mbox{\texttt{\mdseries\slshape elementname}}, and \mbox{\texttt{\mdseries\slshape restype}}, \mbox{\texttt{\mdseries\slshape strings}} and \mbox{\texttt{\mdseries\slshape options}} are as explained in \texttt{RecBibXMLEntry} (\ref{RecBibXMLEntry}). The function should return a string representing the content of the node \mbox{\texttt{\mdseries\slshape r}}. If \mbox{\texttt{\mdseries\slshape elementname}} is of the form \texttt{"Wrap:myname"} the handler is used for elements of form \texttt{{\textless}Wrap Name="myname"{\textgreater}...{\textless}/Wrap{\textgreater}}.42284229If \mbox{\texttt{\mdseries\slshape elementname}} is \texttt{"Finish"} the handler should look like above except that now \mbox{\texttt{\mdseries\slshape r}} is the record generated by \texttt{RecBibXMLEntry} (\ref{RecBibXMLEntry}) just before it is returned. Here the handler should return nothing. It can be4230used to manipulate the record \mbox{\texttt{\mdseries\slshape r}}, for example for changing the encoding of the strings or for adding some more4231components.42324233The installed handler is called by \texttt{BuildRecBibXMLEntry(}\mbox{\texttt{\mdseries\slshape entry}}, \mbox{\texttt{\mdseries\slshape r}}, \mbox{\texttt{\mdseries\slshape restype}}, \mbox{\texttt{\mdseries\slshape strings}}, \mbox{\texttt{\mdseries\slshape options}}\texttt{)}. The string for the whole content of an element can be generated by \texttt{ContentBuildRecBibXMLEntry(}\mbox{\texttt{\mdseries\slshape entry}}, \mbox{\texttt{\mdseries\slshape r}}, \mbox{\texttt{\mdseries\slshape restype}}, \mbox{\texttt{\mdseries\slshape strings}}, \mbox{\texttt{\mdseries\slshape options}}\texttt{)}.42344235We continue the example from \texttt{RecBibXMLEntry} (\ref{RecBibXMLEntry}) and install a handler for the \texttt{{\textless}Wrap Name="Package"{\textgreater}}-element such that {\LaTeX} puts its content in a sans serif font.4236\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4237!gapprompt@gap>| !gapinput@AddHandlerBuildRecBibXMLEntry("Wrap:Package", "BibTeX",|4238!gapprompt@>| !gapinput@function(entry, r, restype, strings, options)|4239!gapprompt@>| !gapinput@ return Concatenation("\\textsf{", ContentBuildRecBibXMLEntry(|4240!gapprompt@>| !gapinput@ entry, r, restype, strings, options), "}");|4241!gapprompt@>| !gapinput@end);|4242!gapprompt@gap>| !gapinput@|4243!gapprompt@gap>| !gapinput@Print(RecBibXMLEntry(e, "BibTeX", strs).title, "\n");|4244The \textsf{ {F}ritz} package for the4245formula $x^y - l_{{i+1}} \rightarrow \mathbb{R}$4246!gapprompt@gap>| !gapinput@Print(RecBibXMLEntry(e, "Text", strs).title, "\n"); |4247The Fritz package for the4248formula x^y - l_{i+1} -> R4249!gapprompt@gap>| !gapinput@AddHandlerBuildRecBibXMLEntry("Wrap:Package", "BibTeX", "Ignore");|4250\end{Verbatim}4251}4252425342544255\subsection{\textcolor{Chapter }{StringBibXMLEntry}}4256\logpage{[ 7, 3, 9 ]}\nobreak4257\hyperdef{L}{X790A295680F7CD24}{}4258{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{StringBibXMLEntry({\mdseries\slshape entry[, restype][, strings][, options]})\index{StringBibXMLEntry@\texttt{StringBibXMLEntry}}4259\label{StringBibXMLEntry}4260}\hfill{\scriptsize (function)}}\\4261\textbf{\indent Returns:\ }4262a string4263426442654266The arguments of this function have the same meaning as in \texttt{RecBibXMLEntry} (\ref{RecBibXMLEntry}) but the return value is a string representing the bibliography entry in a4267format specified by \mbox{\texttt{\mdseries\slshape restype}} (default is \texttt{"BibTeX"}).42684269Currently, the following cases for \mbox{\texttt{\mdseries\slshape restype}} are supported:4270\begin{description}4271\item[{\texttt{"BibTeX"}}] A string with Bib{\TeX} source code is generated.4272\item[{\texttt{"Text"}}] A text representation of the text is returned. If \texttt{options.ansi} is bound it must be a record. The components must have names \texttt{Bib{\textunderscore}Label}, \texttt{Bib{\textunderscore}author}, and so on for all fieldnames. The value of each component is a pair of4273strings which will enclose the content of the field in the result or the first4274of these strings in which case the default for the second is \texttt{TextAttr.reset} (see \texttt{TextAttr} (\ref{TextAttr})). If you give an empty record here, some default ANSI color markup will be4275used.4276\item[{\texttt{"HTML"}}] An HTML representation of the bibliography entry is returned. The text from4277each field is enclosed in markup (mostly \texttt{{\textless}span{\textgreater}}-elements) with the \texttt{class} attribute set to the field name. This allows a detailed layout of the code via4278a style sheet file. If \texttt{options.MathJax} is bound and has the value \texttt{true} then formulae are encoded for display on pages with \textsf{MathJax} support.4279\end{description}4280We use again the file shown in the example for \texttt{ParseBibXMLextFiles} (\ref{ParseBibXMLextFiles}).4281\begin{Verbatim}[commandchars=!|C,fontsize=\small,frame=single,label=Example]4282!gapprompt|gap>C !gapinput|bib := ParseBibXMLextFiles("doc/testbib.xml");;C4283!gapprompt|gap>C !gapinput|e := bib.entries[1];; strs := bib.strings;;C4284!gapprompt|gap>C !gapinput|ebib := StringBibXMLEntry(e, "BibTeX", strs);;C4285!gapprompt|gap>C !gapinput|PrintFormattedString(ebib);C4286@article{ AB2000,4287author = {First, F. A. and Sec{\H o}nd, X. Y.},4288title = {The {F}ritz package for the formula $x^y -4289l_{{i+1}} \rightarrow \mathbb{R}$},4290journal = {Important Journal},4291number = {13},4292year = {2000},4293pages = {13{\textendash}25},4294note = {Online data at \href4295{http://www.publish.com/~ImpJ/123#data} {Bla4296Bla Publisher}},4297mycomment = {very useful},4298printedkey = {FS00}4299}4300!gapprompt|gap>C !gapinput|etxt := StringBibXMLEntry(e, "Text", strs);; C4301!gapprompt|gap>C !gapinput|etxt := SimplifiedUnicodeString(Unicode(etxt), "latin1", "single");;C4302!gapprompt|gap>C !gapinput|etxt := Encode(etxt, GAPInfo.TermEncoding);; C4303!gapprompt|gap>C !gapinput|PrintFormattedString(etxt);C4304[FS00] First, F. A. and Second, X. Y., The Fritz package for the4305formula x^y - l_{i+1} ? R, Important Journal, 13 (2000), 13-25,4306(Online data at Bla Bla Publisher4307(http://www.publish.com/~ImpJ/123#data)).4308!gapprompt|gap>C !gapinput|ehtml := StringBibXMLEntry(e, "HTML", strs, rec(MathJax := true));;C4309!gapprompt|gap>C !gapinput|ehtml := Encode(Unicode(ehtml), GAPInfo.TermEncoding);;C4310!gapprompt|gap>C !gapinput|PrintFormattedString(ehtml);C4311<p class='BibEntry'>4312[<span class='BibKey'>FS00</span>]4313<b class='BibAuthor'>First, F. A. and Second, X. Y.</b>,4314<i class='BibTitle'>The Fritz package for the4315formula \(x^y - l_{{i+1}} \rightarrow \mathbb{R}\)</i>,4316<span class='BibJournal'>Important Journal</span>4317(<span class='BibNumber'>13</span>)4318(<span class='BibYear'>2000</span>),4319<span class='BibPages'>13-25</span><br />4320(<span class='BibNote'>Online data at4321<a href="http://www.publish.com/~ImpJ/123#data">Bla Bla4322Publisher</a></span>).4323</p>43244325\end{Verbatim}4326}43274328The following command may be useful to generate completly new bibliography4329entries in BibXMLext format. It also informs about the supported entry types4330and field names.43314332\subsection{\textcolor{Chapter }{TemplateBibXML}}4333\logpage{[ 7, 3, 10 ]}\nobreak4334\hyperdef{L}{X7C6FF57087016019}{}4335{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{TemplateBibXML({\mdseries\slshape [type]})\index{TemplateBibXML@\texttt{TemplateBibXML}}4336\label{TemplateBibXML}4337}\hfill{\scriptsize (function)}}\\4338\textbf{\indent Returns:\ }4339list of types or string4340434143424343Without an argument this function returns a list of the supported entry types4344in BibXMLext documents.43454346With an argument \mbox{\texttt{\mdseries\slshape type}} of one of the supported types the function returns a string which is a4347template for a corresponding BibXMLext entry. Optional field elements have a \texttt{*} appended. If an element has the word \texttt{OR} appended, then either this element or the next must/can be given, not both. If \texttt{AND/OR} is appended then this and/or the next can/must be given. Elements which can4348appear several times have a \texttt{+} appended. Places to fill are marked by an \texttt{X}.4349\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4350!gapprompt@gap>| !gapinput@TemplateBibXML();|4351[ "article", "book", "booklet", "conference", "inbook",4352"incollection", "inproceedings", "manual", "mastersthesis", "misc",4353"phdthesis", "proceedings", "techreport", "unpublished" ]4354!gapprompt@gap>| !gapinput@Print(TemplateBibXML("inbook"));|4355<entry id="X"><inbook>4356<author>4357<name><first>X</first><last>X</last></name>+4358</author>OR4359<editor>4360<name><first>X</first><last>X</last></name>+4361</editor>4362<title>X</title>4363<chapter>X</chapter>AND/OR4364<pages>X</pages>4365<publisher>X</publisher>4366<year>X</year>4367<volume>X</volume>*OR4368<number>X</number>*4369<series>X</series>*4370<type>X</type>*4371<address>X</address>*4372<edition>X</edition>*4373<month>X</month>*4374<note>X</note>*4375<key>X</key>*4376<annotate>X</annotate>*4377<crossref>X</crossref>*4378<abstract>X</abstract>*4379<affiliation>X</affiliation>*4380<contents>X</contents>*4381<copyright>X</copyright>*4382<isbn>X</isbn>*OR4383<issn>X</issn>*4384<keywords>X</keywords>*4385<language>X</language>*4386<lccn>X</lccn>*4387<location>X</location>*4388<mrnumber>X</mrnumber>*4389<mrclass>X</mrclass>*4390<mrreviewer>X</mrreviewer>*4391<price>X</price>*4392<size>X</size>*4393<url>X</url>*4394<category>X</category>*4395<other type="X">X</other>*+4396</inbook></entry>4397\end{Verbatim}4398}43994400}440144024403\section{\textcolor{Chapter }{Getting Bib{\TeX} entries from \textsf{MathSciNet}}}\label{MathSciNet}4404\logpage{[ 7, 4, 0 ]}4405\hyperdef{L}{X842336AF7B20048E}{}4406{4407We provide utilities to access the \href{http://www.ams.org/mathscinet/} {\textsf{ MathSciNet}} data base from within GAP. One condition for this to work is that the \textsf{IO}-package \cite{IO} is available. The other is, of course, that you use these functions from a4408computer which has access to \textsf{MathSciNet}.44094410Please note, that the usual license for \textsf{MathSciNet} access does not allow for automated searches in the database. Therefore, only4411use the \texttt{SearchMR} (\ref{SearchMR}) function for single queries, as you would do using your webbrowser.4412441344144415\subsection{\textcolor{Chapter }{SearchMR}}4416\logpage{[ 7, 4, 1 ]}\nobreak4417\hyperdef{L}{X8009F8A17DDFF9AF}{}4418{\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SearchMR({\mdseries\slshape qurec})\index{SearchMR@\texttt{SearchMR}}4419\label{SearchMR}4420}\hfill{\scriptsize (function)}}\\4421\noindent\textcolor{FuncColor}{$\triangleright$\enspace\texttt{SearchMRBib({\mdseries\slshape bib})\index{SearchMRBib@\texttt{SearchMRBib}}4422\label{SearchMRBib}4423}\hfill{\scriptsize (function)}}\\4424\textbf{\indent Returns:\ }4425a list of strings, a string or \texttt{fail}4426442744284429The first function \texttt{SearchMR} provides the same functionality as the Web interface \href{http://www.ams.org/mathscinet/} {\textsf{ MathSciNet}}. The query strings must be given as a record, and the following components of4430this record are recognized: \texttt{Author}, \texttt{AuthorRelated}, \texttt{Title}, \texttt{ReviewText}, \texttt{Journal}, \texttt{InstitutionCode}, \texttt{Series}, \texttt{MSCPrimSec}, \texttt{MSCPrimary}, \texttt{MRNumber}, \texttt{Anywhere}, \texttt{References} and \texttt{Year}.44314432Furthermore, the component \texttt{type} can be specified. It can be one of \texttt{"bibtex"} (the default if not given), \texttt{"pdf"}, \texttt{"html"} and probably others. In the last cases the function returns a string with the4433correspondig PDF-file or web page from \textsf{MathSciNet}. In the first case the \textsf{MathSciNet} interface returns a web page with Bib{\TeX} entries, for convenience this function returns a list of strings, each4434containing the Bib{\TeX} text for a single result entry.44354436The format of a \texttt{.Year} component can be either a four digit number, optionally preceded by one of the4437characters \texttt{'{\textless}'}, \texttt{'{\textgreater}'} or \texttt{'='}, or it can be two four digit numbers separated by a \texttt{-} to specify a year range.44384439The function \texttt{SearchMRBib} gets a record of a parsed Bib{\TeX} entry as input as returned by \texttt{ParseBibFiles} (\ref{ParseBibFiles}) or \texttt{ParseBibStrings} (\ref{ParseBibStrings}). It tries to generate some sensible input from this information for \texttt{SearchMR} and calls that function.444044414442\begin{Verbatim}[commandchars=!@|,fontsize=\small,frame=single,label=Example]4443!gapprompt@gap>| !gapinput@ll := SearchMR(rec(Author:="Gauss", Title:="Disquisitiones"));;|4444!gapprompt@gap>| !gapinput@ll2 := List(ll, HeuristicTranslationsLaTeX2XML.Apply);;|4445!gapprompt@gap>| !gapinput@bib := ParseBibStrings(Concatenation(ll2));;|4446!gapprompt@gap>| !gapinput@bibxml := List(bib[1], StringBibAsXMLext);;|4447!gapprompt@gap>| !gapinput@bib2 := ParseBibXMLextString(Concatenation(bibxml));;|4448!gapprompt@gap>| !gapinput@for b in bib2.entries do |4449!gapprompt@>| !gapinput@ PrintFormattedString(StringBibXMLEntry(b, "Text")); od; |4450[Gau95] Gauss, C. F., Disquisitiones arithmeticae, Academia4451Colombiana de Ciencias Exactas, F�sicas y Naturales, Bogot�,4452Colecci�n Enrique P�rez Arbel�ez [Enrique P�rez Arbel�ez4453Collection], 10 (1995), xliv+495 pages, (Translated from the Latin4454by Hugo Barrantes Campos, Michael Josephy and �ngel Ruiz Z��iga,4455With a preface by Ruiz Z��iga).44564457[Gau86] Gauss, C. F., Disquisitiones arithmeticae, Springer-Verlag,4458New York (1986), xx+472 pages, (Translated and with a preface by4459Arthur A. Clarke, Revised by William C. Waterhouse, Cornelius4460Greither and A. W. Grootendorst and with a preface by Waterhouse).44614462[Gau66] Gauss, C. F., Disquisitiones arithmeticae, Yale University4463Press, New Haven, Conn.-London, Translated into English by Arthur A.4464Clarke, S. J (1966), xx+472 pages.44654466\end{Verbatim}4467}44684469}44704471}4472447344744475\appendix447644774478\chapter{\textcolor{Chapter }{The File \texttt{3k+1.xml}}}\label{app:3k+1}4479\logpage{[ "A", 0, 0 ]}4480\hyperdef{L}{X830C58F97F9CD901}{}4481{4482Here is the complete source of the example \textsf{GAPDoc} document \texttt{3k+1.xml} discussed in Section{\nobreakspace}\ref{sec:3k+1expl}.4483\begin{Verbatim}[fontsize=\small,frame=single,label=3k+1.xml]4484<?xml version="1.0" encoding="UTF-8"?>44854486<!-- A complete "fake package" documentation4487-->44884489<!DOCTYPE Book SYSTEM "gapdoc.dtd">44904491<Book Name="3k+1">44924493<TitlePage>4494<Title>The <Package>ThreeKPlusOne</Package> Package</Title>4495<Version>Version 42</Version>4496<Author>Dummy Auth�r4497<Email>3kplusone@dev.null</Email>4498</Author>44994500<Copyright>©right; 2000 The Author. <P/>4501You can do with this package what you want.<P/> Really.4502</Copyright>4503</TitlePage>45044505<TableOfContents/>45064507<Body>4508<Chapter> <Heading>The <M>3k+1</M> Problem</Heading>4509<Section Label="sec:theory"> <Heading>Theory</Heading>4510Let <M>k \in &NN;</M> be a natural number. We consider the4511sequence <M>n(i, k), i \in &NN;,</M> with <M>n(1, k) = k</M> and4512else <M>n(i+1, k) = n(i, k) / 2</M> if <M>n(i, k)</M> is even4513and <M>n(i+1, k) = 3 n(i, k) + 1</M> if <M>n(i, k)</M> is odd.4514<P/> It is not known whether for any natural number <M>k \in4515&NN;</M> there is an <M>m \in &NN;</M> with <M>n(m, k) = 1</M>.4516<P/>4517<Package>ThreeKPlusOne</Package> provides the function <Ref4518Func="ThreeKPlusOneSequence"/> to explore this for given4519<M>n</M>. If you really want to know something about this4520problem, see <Cite Key="Wi98"/> or4521<URL>http://www.ku.de/mgf/mathematik/lehrstuhlstatistik/team/dr-guenther-wirsching/</URL>4522for more details (and forget this package).4523</Section>45244525<Section> <Heading>Program</Heading>4526In this section we describe the main function of this package.4527<ManSection>4528<Func Name="ThreeKPlusOneSequence" Arg="k[, max]"/>4529<Description>4530This function computes for a natural number <A>k</A> the4531beginning of the sequence <M>n(i, k)</M> defined in section4532<Ref Sect="sec:theory"/>. The sequence stops at the first4533<M>1</M> or at <M>n(<A>max</A>, k)</M>, if <A>max</A> is4534given.4535<Example>4536gap> ThreeKPlusOneSequence(101);4537"Sorry, not yet implemented. Wait for Version 84 of the package"4538</Example>4539</Description>4540</ManSection>4541</Section>4542</Chapter>4543</Body>45444545<Bibliography Databases="3k+1" />4546<TheIndex/>45474548</Book>45494550\end{Verbatim}4551}455245534554\chapter{\textcolor{Chapter }{The File \texttt{gapdoc.dtd}}}\label{GAPDocdtd}4555\logpage{[ "B", 0, 0 ]}4556\hyperdef{L}{X85366C6480D58C51}{}4557{4558For easier reference we repeat here the complete content of the file \texttt{gapdoc.dtd}.4559\begin{Verbatim}[fontsize=\small,frame=single,label=gapdoc.dtd]4560<?xml version="1.0" encoding="UTF-8"?>4561<!-- ==================================================================4562gapdoc.dtd - XML Document type definition for GAP documentation4563By Frank L�beck and Max Neunh�ffer4564================================================================== -->456545664567<!-- Note that this definition goes "bottom-up" because entities can only4568be used after their definition in the file. -->456945704571<!-- ==================================================================4572Some entities:4573================================================================== -->45744575<!-- The standard XML entities: -->45764577<!ENTITY lt "&#60;">4578<!ENTITY gt ">">4579<!ENTITY amp "&#38;">4580<!ENTITY apos "'">4581<!ENTITY quot """>458245834584<!-- The following were introduced in GAPDoc version < 1.0, it is no longer4585necessary to take care of LaTeX special characters4586(we keep the entities with simplified definitions for compatibility) -->45874588<!ENTITY tamp "&">4589<!ENTITY tlt "<">4590<!ENTITY tgt ">">4591<!ENTITY hash "#">4592<!ENTITY dollar "$">4593<!ENTITY percent "%">4594<!ENTITY tilde "~">4595<!ENTITY bslash "\\">4596<!ENTITY obrace "{">4597<!ENTITY cbrace "}">4598<!ENTITY uscore "_">4599<!ENTITY circum "^">46004601<!-- ==================================================================4602Our predefined entities:4603================================================================== -->46044605<!ENTITY nbsp " ">4606<!ENTITY ndash "–">4607<!ENTITY GAP "<Package>GAP</Package>">4608<!ENTITY GAPDoc "<Package>GAPDoc</Package>">4609<!ENTITY TeX4610"<Alt Only='LaTeX'>{\TeX}</Alt><Alt Not='LaTeX'>TeX</Alt>">4611<!ENTITY LaTeX4612"<Alt Only='LaTeX'>{\LaTeX}</Alt><Alt Not='LaTeX'>LaTeX</Alt>">4613<!ENTITY BibTeX4614"<Alt Only='LaTeX'>{Bib\TeX}</Alt><Alt Not='LaTeX'>BibTeX</Alt>">4615<!ENTITY MeatAxe "<Package>MeatAxe</Package>">4616<!ENTITY XGAP "<Package>XGAP</Package>">4617<!ENTITY copyright "©">46184619<!-- and unicode math symbols -->4620<!ENTITY CC "ℂ" > <!-- double struck -->4621<!ENTITY ZZ "ℤ" >4622<!ENTITY NN "ℕ" >4623<!ENTITY PP "ℙ" >4624<!ENTITY QQ "ℚ" >4625<!ENTITY HH "ℍ" >4626<!ENTITY RR "ℝ" >462746284629<!-- ==================================================================4630The following describes the "innermost" documentation text which4631can occur at various places in the document like for example4632section headings. It does neither contain further sectioning4633elements nor environments like Enums or Lists.4634================================================================== -->46354636<!ENTITY % InnerText "#PCDATA |4637Alt |4638Emph | E |4639Par | P | Br |4640Keyword | K | Arg | A | Quoted | Q | Code | C |4641File | F | Button | B | Package |4642M | Math | Display |4643Example | Listing | Log | Verb |4644URL | Email | Homepage | Address | Cite | Label |4645Ref | Index |4646Ignore" >464746484649<!ELEMENT Alt (%InnerText;)*> <!-- This is only to allow "Only" and4650"Not" attributes for normal text -->4651<!ATTLIST Alt Only CDATA #IMPLIED4652Not CDATA #IMPLIED>46534654<!-- The following elements declare a certain block of InnerText to4655have a certain property. They are non-terminal and can contain4656any InnerText recursively. -->46574658<!ELEMENT Emph (%InnerText;)*> <!-- Emphasize something -->4659<!ELEMENT E (%InnerText;)*> <!-- the same as shortcut -->466046614662<!-- The following is an empty element marking a paragraph boundary. -->46634664<!ELEMENT Par EMPTY> <!-- this is intentionally empty! -->4665<!ELEMENT P EMPTY> <!-- the same as shortcut -->46664667<!-- And here is an element for forcing a line break, not starting4668a new paragraph. -->46694670<!ELEMENT Br EMPTY> <!-- a forced line break -->46714672<!-- The following elements mark a word or sentence to be of a certain4673kind, such that it can be typeset differently. They are terminal4674elements that should only contain character data. But we have to4675allow Alt elements for handling special characters. For these4676elements we introduce a long name - which is easy to remember -4677and a short name - which you may prefer because of the shorter4678markup. -->46794680<!ELEMENT Keyword (#PCDATA|Alt)*> <!-- Keyword -->4681<!ELEMENT K (#PCDATA|Alt)*> <!-- Keyword (shortcut) -->46824683<!ELEMENT Arg (#PCDATA|Alt)*> <!-- Argument -->4684<!ELEMENT A (#PCDATA|Alt)*> <!-- Argument (shortcut) -->46854686<!ELEMENT Code (#PCDATA|Alt|A|Arg)*> <!-- GAP code -->4687<!ELEMENT C (#PCDATA|Alt|A|Arg)*> <!-- GAP code (shortcut) -->46884689<!ELEMENT File (#PCDATA|Alt)*> <!-- Filename -->4690<!ELEMENT F (#PCDATA|Alt)*> <!-- Filename (shortcut) -->46914692<!ELEMENT Button (#PCDATA|Alt)*> <!-- "Button" (also Menu, Key) -->4693<!ELEMENT B (#PCDATA|Alt)*> <!-- "Button" (shortcut) -->46944695<!ELEMENT Package (#PCDATA|Alt)*> <!-- A package name -->46964697<!ELEMENT Quoted (%InnerText;)*> <!-- Quoted (in quotes) text -->4698<!ELEMENT Q (%InnerText;)*> <!-- Quoted text (shortcut) -->469947004701<!-- The following elements contain mathematical formulae. They are4702terminal elements that contain character data in TeX notation. -->47034704<!-- Math with well defined translation to text output -->4705<!ELEMENT M (#PCDATA|A|Arg|Alt)*>4706<!-- Normal TeX math mode formula -->4707<!ELEMENT Math (#PCDATA|A|Arg|Alt)*>4708<!-- TeX displayed math mode formula -->4709<!ELEMENT Display (#PCDATA|A|Arg|Alt)*>4710<!-- Mode="M" causes <M>-style formatting -->4711<!ATTLIST Display Mode CDATA #IMPLIED>471247134714<!-- The following elements contain GAP related text like code,4715session logs or examples. They are all terminal elements and4716consist of character data which is normally typeset verbatim. The4717different types of the elements only control how they are4718treated. -->47194720<!ELEMENT Example (#PCDATA)> <!-- This is subject to the automatic4721example checking mechanism -->4722<!ELEMENT Log (#PCDATA)> <!-- This not -->4723<!ELEMENT Listing (#PCDATA)> <!-- This is just for code listings -->4724<!ATTLIST Listing Type CDATA #IMPLIED> <!-- a comment about the type of4725listed code, may appear in4726output -->47274728<!-- One further verbatim element, this is truely verbatim without4729any processing and intended for ASCII substitutes of complicated4730displayed formulae or tables. -->47314732<!ELEMENT Verb (#PCDATA)>47334734<!-- The following elements are for cross-referencing purposes like4735URLs, citations, references, and the index. All these elements4736are terminal and need special methods to make up the actual4737output during document generation. -->47384739<!ELEMENT URL (#PCDATA|Alt|Link|LinkText)*> <!-- Link, LinkText4740variant for case where text needs further markup -->4741<!ATTLIST URL Text CDATA #IMPLIED> <!-- This is for output formats4742that have links like HTML -->4743<!ELEMENT Link (%InnerText;)*> <!-- the URL -->4744<!ELEMENT LinkText (%InnerText;)*> <!-- text for links, can contain markup -->4745<!-- The following two are actually URLs, but the element name determines4746the type. -->4747<!ELEMENT Email (#PCDATA|Alt|Link|LinkText)*>4748<!ELEMENT Homepage (#PCDATA|Alt|Link|LinkText)*>47494750<!-- Those who still want to give postal addresses can use the following4751element. Use <Br/> for specifying typical line breaks -->47524753<!ELEMENT Address (#PCDATA|Alt|Br)*>47544755<!ELEMENT Cite EMPTY>4756<!ATTLIST Cite Key CDATA #REQUIRED4757Where CDATA #IMPLIED>47584759<!ELEMENT Label EMPTY>4760<!ATTLIST Label Name CDATA #REQUIRED>47614762<!ELEMENT Ref EMPTY>4763<!ATTLIST Ref Func CDATA #IMPLIED4764Oper CDATA #IMPLIED4765Constr CDATA #IMPLIED4766Meth CDATA #IMPLIED4767Filt CDATA #IMPLIED4768Prop CDATA #IMPLIED4769Attr CDATA #IMPLIED4770Var CDATA #IMPLIED4771Fam CDATA #IMPLIED4772InfoClass CDATA #IMPLIED4773Chap CDATA #IMPLIED4774Sect CDATA #IMPLIED4775Subsect CDATA #IMPLIED4776Appendix CDATA #IMPLIED4777Text CDATA #IMPLIED47784779Label CDATA #IMPLIED4780BookName CDATA #IMPLIED4781Style (Text|Number) #IMPLIED> <!-- normally automatic -->47824783<!-- Note that only one attribute of Ref is used normally. BookName4784and Style can be specified in addition to handle external4785references and the typesetting style of the reference. -->47864787<!-- For explicit index entries (Func and so on should cause an4788automatically generated index entry). Use the attributes Key,4789Subkey for sorting (simplified, without markup). The Subkey value4790also gets printed. Use the optional Subkey element if the printed4791version needs some markup. -->4792<!ELEMENT Index (%InnerText;|Subkey)*>4793<!ATTLIST Index Key CDATA #IMPLIED4794Subkey CDATA #IMPLIED>4795<!ELEMENT Subkey (%InnerText;)*>479647974798<!-- ==================================================================4799The following describes the normal documentation text which can4800occur at various places in the document. It does not contain4801further sectioning elements. In addition to InnerText it can contain4802environments like enumerations, lists, and such.4803================================================================== -->48044805<!ENTITY % Text "%InnerText; | List | Enum | Table">48064807<!ELEMENT Item ( %Text;)*>4808<!ELEMENT Mark ( %InnerText;)*>48094810<!ELEMENT List ( ((Mark,Item)|Item)+ )>4811<!ATTLIST List Only CDATA #IMPLIED4812Not CDATA #IMPLIED>4813<!ELEMENT Enum ( Item+ )>4814<!ATTLIST Enum Only CDATA #IMPLIED4815Not CDATA #IMPLIED>48164817<!ELEMENT Table ( Caption?, (Row | HorLine)+ )>4818<!ATTLIST Table Label CDATA #IMPLIED4819Only CDATA #IMPLIED4820Not CDATA #IMPLIED4821Align CDATA #REQUIRED> <!-- A TeX tabular string -->4822<!-- We allow | and l,c,r, nothing else -->4823<!ELEMENT Row ( Item+ )>4824<!ELEMENT HorLine EMPTY>4825<!ELEMENT Caption ( %InnerText;)*>48264827<!-- ==================================================================4828We start defining some things within the overall structure:4829================================================================== -->48304831<!-- The TitlePage consists of several sub-elements: -->48324833<!ELEMENT TitlePage (Title, Subtitle?, Version?, TitleComment?,4834Author+, Date?, Address?, Abstract?, Copyright?,4835Acknowledgements? , Colophon? )>48364837<!ELEMENT Title (%Text;)*>4838<!ELEMENT Subtitle (%Text;)*>4839<!ELEMENT Version (%Text;)*>4840<!ELEMENT TitleComment (%Text;)*>4841<!ELEMENT Author (%Text;)*> <!-- There may be more than one Author! -->4842<!ELEMENT Date (%Text;)*>4843<!ELEMENT Abstract (%Text;)*>4844<!ELEMENT Copyright (%Text;)*>4845<!ELEMENT Acknowledgements (%Text;)*>4846<!ELEMENT Colophon (%Text;)*>484748484849<!-- The following things just specify some information about the4850corresponding parts of the Book: -->48514852<!ELEMENT TableOfContents EMPTY>4853<!ELEMENT Bibliography EMPTY>4854<!ATTLIST Bibliography Databases CDATA #REQUIRED4855Style CDATA #IMPLIED>4856<!ELEMENT TheIndex EMPTY>48574858<!-- ==================================================================4859The Ignore element can be used everywhere to include further4860information in a GAPDoc document which is not intended for the4861standard converters (e.g., source code, not yet finished stuff,4862and so on. This information can be extracted by special converter4863routines, more precise information about the content of an Ignore4864element can be given by the "Remark" attribute.4865================================================================== -->48664867<!ELEMENT Ignore (%Text;| Chapter | Section | Subsection | ManSection |4868Heading)*>4869<!ATTLIST Ignore Remark CDATA #IMPLIED>48704871<!-- ==================================================================4872Now we go on with the overall structure by defining the sectioning4873structure, which includes the Synopsis element:4874================================================================== -->487548764877<!ELEMENT Subsection (%Text;| Heading)*>4878<!ATTLIST Subsection Label CDATA #IMPLIED> <!-- For reference purposes -->48794880<!ELEMENT ManSection ( Heading?,4881((Func, Returns?) | (Oper, Returns?) |4882(Meth, Returns?) | (Filt, Returns?) |4883(Prop, Returns?) | (Attr, Returns?) |4884(Constr, Returns?) |4885Var | Fam | InfoClass)+, Description )>4886<!ATTLIST ManSection Label CDATA #IMPLIED> <!-- For reference purposes -->48874888<!ELEMENT Returns (%Text;)*>4889<!ELEMENT Description (%Text;)*>489048914892<!-- Note that the ManSection element is actually a subsection with4893respect to labelling, referencing, and counting of sectioning4894elements. -->48954896<!ELEMENT Func EMPTY>4897<!ATTLIST Func Name CDATA #REQUIRED4898Label CDATA #IMPLIED4899Arg CDATA #REQUIRED4900Comm CDATA #IMPLIED>49014902<!-- Note that Arg contains the full list of arguments, including4903optional parts, which are denoted by square brackets [].4904Arguments are separated by whitespace, commas count as4905whitespace. -->49064907<!-- Note further that although Name and Label are CDATA (and not ID)4908Label must make up a unique identifier. -->49094910<!ELEMENT Oper EMPTY>4911<!ATTLIST Oper Name CDATA #REQUIRED4912Label CDATA #IMPLIED4913Arg CDATA #REQUIRED4914Comm CDATA #IMPLIED>49154916<!ELEMENT Constr EMPTY>4917<!ATTLIST Constr Name CDATA #REQUIRED4918Label CDATA #IMPLIED4919Arg CDATA #REQUIRED4920Comm CDATA #IMPLIED>49214922<!ELEMENT Meth EMPTY>4923<!ATTLIST Meth Name CDATA #REQUIRED4924Label CDATA #IMPLIED4925Arg CDATA #REQUIRED4926Comm CDATA #IMPLIED>49274928<!ELEMENT Filt EMPTY>4929<!ATTLIST Filt Name CDATA #REQUIRED4930Label CDATA #IMPLIED4931Arg CDATA #IMPLIED4932Comm CDATA #IMPLIED4933Type CDATA #IMPLIED>49344935<!ELEMENT Prop EMPTY>4936<!ATTLIST Prop Name CDATA #REQUIRED4937Label CDATA #IMPLIED4938Arg CDATA #REQUIRED4939Comm CDATA #IMPLIED>49404941<!ELEMENT Attr EMPTY>4942<!ATTLIST Attr Name CDATA #REQUIRED4943Label CDATA #IMPLIED4944Arg CDATA #REQUIRED4945Comm CDATA #IMPLIED>49464947<!ELEMENT Var EMPTY>4948<!ATTLIST Var Name CDATA #REQUIRED4949Label CDATA #IMPLIED4950Comm CDATA #IMPLIED>49514952<!ELEMENT Fam EMPTY>4953<!ATTLIST Fam Name CDATA #REQUIRED4954Label CDATA #IMPLIED4955Comm CDATA #IMPLIED>49564957<!ELEMENT InfoClass EMPTY>4958<!ATTLIST InfoClass Name CDATA #REQUIRED4959Label CDATA #IMPLIED4960Comm CDATA #IMPLIED>496149624963<!ELEMENT Heading (%InnerText;)*>49644965<!ELEMENT Section (%Text;| Heading | Subsection | ManSection)*>4966<!ATTLIST Section Label CDATA #IMPLIED> <!-- For reference purposes -->496749684969<!ELEMENT Chapter (%Text;| Heading | Section)*>4970<!ATTLIST Chapter Label CDATA #IMPLIED> <!-- For reference purposes -->497149724973<!-- Note that the entity %InnerText; is documentation that contains4974neither sectioning elements nor environments like enumerations,4975but only formulae, labels, references, citations, and other4976terminal elements. -->49774978<!ELEMENT Appendix (%Text;| Heading | Section)*>4979<!ATTLIST Appendix Label CDATA #IMPLIED> <!-- For reference purposes -->49804981<!-- Note that an Appendix is exactly the same as a Chapter. They4982differ only in the numbering. -->49834984<!-- ==================================================================4985At last we define the overall structure of a gapdoc Book:4986================================================================== -->49874988<!ELEMENT Body ( %Text;| Chapter | Section )*>49894990<!ELEMENT Book (TitlePage,4991TableOfContents?,4992Body,4993Appendix*,4994Bibliography?,4995TheIndex?)>4996<!ATTLIST Book Name CDATA #REQUIRED>49974998<!-- Note that the entity %Text; is documentation that contains4999no further sectioning elements but possibly environments like5000enumerations, and formulae, labels, references, and citations.5001-->50025003<!-- ============================================================== -->500450055006\end{Verbatim}5007}500850095010\chapter{\textcolor{Chapter }{The File \texttt{bibxmlext.dtd}}}\label{bibxmlextdtd}5011\logpage{[ "C", 0, 0 ]}5012\hyperdef{L}{X7E2788757A1AA098}{}5013{5014For easier reference we repeat here the complete content of the file \texttt{bibxmlext.dtd} which is explained in \ref{BibXMLformat}.5015\begin{Verbatim}[fontsize=\small,frame=single,label=bibxmlext.dtd]5016<?xml version="1.0" encoding="UTF-8"?>5017<!--5018- (C) Frank L�beck (http://www.math.rwth-aachen.de/~Frank.Luebeck)5019-5020- The BibXMLext data format.5021-5022- This DTD expresses XML markup similar to the BibTeX language5023- specified for LaTeX, or actually its content model.5024-5025- It is a variation of a file bibxml.dtd developed by the project5026- http://bibtexml.sf.net/5027-5028- For documentation on BibTeX, see5029- http://www.ctan.org/tex-archive/biblio/bibtex/distribs/doc/5030-5031- A previous version of the code originally developed by5032- Vidar Bronken Gundersen, http://bibtexml.sf.net/5033- Reuse and repurposing is approved as long as this5034- notification appears with the code.5035-5036-->50375038<!-- ..................................................................... -->5039<!-- Main structure -->50405041<!-- key-value pairs as in BibTeX @string entries are put in empty elements5042(but here they can be used for parts of an entry field as well) -->5043<!ELEMENT string EMPTY>5044<!ATTLIST string5045key CDATA #REQUIRED5046value CDATA #REQUIRED >50475048<!-- entry may contain one of the bibliographic types. -->5049<!ELEMENT entry ( article | book | booklet |5050manual | techreport |5051mastersthesis | phdthesis |5052inbook | incollection |5053proceedings | inproceedings |5054conference |5055unpublished | misc ) >5056<!ATTLIST entry5057id CDATA #REQUIRED >50585059<!-- file is the documents top element. -->5060<!ELEMENT file ( string | entry )* >506150625063<!-- ..................................................................... -->5064<!-- Parameter entities -->50655066<!-- these are additional elements often used, but not included in the5067standard BibTeX distribution, these must be added to the5068bibliography styles, otherwise these fields will be omitted by5069the formatter, we allow an arbitrary number of 'other' elements5070to specify any further information -->50715072<!ENTITY % n.user " abstract?, affiliation?,5073contents?, copyright?,5074(isbn | issn)?,5075keywords?, language?, lccn?,5076location?, mrnumber?, mrclass?, mrreviewer?,5077price?, size?, url?, category?, other* ">50785079<!ENTITY % n.common "key?, annotate?, crossref?,5080%n.user;">50815082<!-- content model used more than once -->50835084<!ENTITY % n.InProceedings "author, title, booktitle,5085year, editor?,5086(volume | number)?,5087series?, pages?, address?,5088month?, organization?, publisher?,5089note?, %n.common;">50905091<!ENTITY % n.PHDThesis "author, title, school,5092year, type?, address?, month?,5093note?, %n.common;">50945095<!-- ..................................................................... -->5096<!-- Entries in the BibTeX database -->50975098<!-- [article] An article from a journal or magazine.5099- Required fields: author, title, journal, year.5100- Optional fields: volume, number, pages, month, note. -->5101<!ELEMENT article (author, title, journal,5102year, volume?, number?, pages?,5103month?, note?, %n.common;)5104>51055106<!-- [book] A book with an explicit publisher.5107- Required fields: author or editor, title, publisher, year.5108- Optional fields: volume or number, series, address,5109- edition, month, note. -->5110<!ELEMENT book ((author | editor), title,5111publisher, year, (volume | number)?,5112series?, address?, edition?, month?,5113note?, %n.common;)5114>51155116<!-- [booklet] A work that is printed and bound, but without a named5117- publisher or sponsoring institution5118- Required field: title.5119- Optional fields: author, howpublished, address, month, year, note. -->5120<!ELEMENT booklet (author?, title,5121howpublished?, address?, month?,5122year?, note?, %n.common;)5123>51245125<!-- [conference] The same as INPROCEEDINGS,5126- included for Scribe compatibility. -->5127<!ELEMENT conference (%n.InProceedings;)5128>51295130<!-- [inbook] A part of a book, which may be a chapter (or section or5131- whatever) and/or a range of pages.5132- Required fields: author or editor, title, chapter and/or pages,5133- publisher, year.5134- Optional fields: volume or number, series, type, address,5135- edition, month, note. -->5136<!ELEMENT inbook ((author | editor), title,5137((chapter, pages?) | pages),5138publisher, year, (volume |5139number)?, series?, type?,5140address?, edition?, month?,5141note?, %n.common;)5142>51435144<!--5145- > I want to express that the elements a and/or b are legal that is one5146- > of them or both must be present in the document instance (see the5147- > element content for BibTeX entry `InBook').5148- > How do I specify this in my DTD?5149-5150- Dave Peterson:5151- in content model: ((a , b?) | b) if order matters5152- ((a , b?) | (b , a?)) otherwise5153-->51545155<!-- [incollection] A part of a book having its own title.5156- Required fields: author, title, booktitle, publisher, year.5157- Optional fields: editor, volume or number, series, type,5158- chapter, pages, address, edition, month, note. -->5159<!ELEMENT incollection (author, title,5160booktitle, publisher, year,5161editor?, (volume | number)?,5162series?, type?, chapter?,5163pages?, address?, edition?,5164month?, note?,5165%n.common;)5166>51675168<!-- [inproceedings] An article in a conference proceedings.5169- Required fields: author, title, booktitle, year.5170- Optional fields: editor, volume or number, series, pages,5171- address, month, organization, publisher, note. -->5172<!ELEMENT inproceedings (%n.InProceedings;)5173>51745175<!-- [manual] Technical documentation5176- Required field: title.5177- Optional fields: author, organization, address,5178- edition, month, year, note. -->5179<!ELEMENT manual (author?, title,5180organization?, address?, edition?,5181month?, year?, note?, %n.common;)5182>51835184<!-- [mastersthesis] A Master's thesis.5185- Required fields: author, title, school, year.5186- Optional fields: type, address, month, note. -->5187<!ELEMENT mastersthesis (%n.PHDThesis;)5188>51895190<!-- [misc] Use this type when nothing else fits.5191- Required fields: none.5192- Optional fields: author, title, howpublished, month, year, note. -->5193<!ELEMENT misc (author?, title?,5194howpublished?, month?, year?, note?,5195%n.common;)5196>51975198<!-- [phdthesis] A PhD thesis.5199- Required fields: author, title, school, year.5200- Optional fields: type, address, month, note. -->5201<!ELEMENT phdthesis (%n.PHDThesis;)5202>52035204<!-- [proceedings] The proceedings of a conference.5205- Required fields: title, year.5206- Optional fields: editor, volume or number, series,5207- address, month, organization, publisher, note. -->5208<!ELEMENT proceedings (editor?, title, year,5209(volume | number)?, series?,5210address?, month?, organization?,5211publisher?, note?, %n.common;)5212>52135214<!-- [techreport] A report published by a school or other institution,5215- usually numbered within a series.5216- Required fields: author, title, institution, year.5217- Optional fields: type, number, address, month, note. -->5218<!ELEMENT techreport (author, title,5219institution, year, type?, number?,5220address?, month?, note?, %n.common;)5221>52225223<!-- [unpublished] A document having an author and title, but not5224- formally published.5225- Required fields: author, title, note.5226- Optional fields: month, year. -->5227<!ELEMENT unpublished (author, title, note,5228month?, year?, %n.common;)5229>52305231<!-- ..................................................................... -->5232<!-- Fields from the standard bibliography styles -->52335234<!--5235- Below is a description of all fields recognized by the standard5236- bibliography styles. An entry can also contain other fields, which5237- are ignored by those styles.5238-5239- [address] Usually the address of the publisher or other type of5240- institution For major publishing houses, van~Leunen recommends5241- omitting the information entirely. For small publishers, on the other5242- hand, you can help the reader by giving the complete address.5243-5244- [annote] An annotation It is not used by the standard bibliography5245- styles, but may be used by others that produce an annotated5246- bibliography.5247-5248- [author] The name(s) of the author(s), here *not* in the format5249- described in the LaTeX book. Contains elements <name> which in turn5250- contains elements <first>, <last> for the first name (or first names,5251- fully written or as initials, and including middle initials) and5252- the last name.5253-5254- [booktitle] Title of a book, part of which is being cited. See the5255- LaTeX book for how to type titles. For book entries, use the title5256- field instead.5257-5258- [chapter] A chapter (or section or whatever) number.5259-5260- [crossref] The database key of the entry being cross referenced.5261-5262- [edition] The edition of a book-for example, ``Second''. This5263- should be an ordinal, and should have the first letter capitalized, as5264- shown here; the standard styles convert to lower case when necessary.5265-5266- [editor] Name(s) of editor(s), typed as indicated in the LaTeX book.5267- If there is also an author field, then the editor field gives the5268- editor of the book or collection in which the reference appears.5269-5270- [howpublished] How something strange has been published. The first5271- word should be capitalized.5272-5273- [institution] The sponsoring institution of a technical report.5274-5275- [journal] A journal name. Abbreviations are provided for many5276- journals; see the Local Guide.5277-5278- [key] Used for alphabetizing, cross referencing, and creating a label5279- when the ``author'' information (described in Section [ref: ] is5280- missing. This field should not be confused with the key that appears5281- in the \cite command and at the beginning of the database entry.5282-5283- [month] The month in which the work was published or, for an5284- unpublished work, in which it was written. You should use the5285- standard three-letter abbreviation, as described in Appendix B.1.3 of5286- the LaTeX book.5287-5288- [note] Any additional information that can help the reader. The first5289- word should be capitalized.5290-5291- [number] The number of a journal, magazine, technical report, or of a5292- work in a series. An issue of a journal or magazine is usually5293- identified by its volume and number; the organization that issues a5294- technical report usually gives it a number; and sometimes books are5295- given numbers in a named series.5296-5297- [organization] The organization that sponsors a conference or that5298- publishes a manual.5299-5300- [pages] One or more page numbers or range of numbers, such as 42-1115301- or 7,41,73-97 or 43+ (the `+' in this last example indicates pages5302- following that don't form a simple range). To make it easier to5303- maintain Scribe-compatible databases, the standard styles convert a5304- single dash (as in 7-33) to the double dash used in TeX to denote5305- number ranges (as in 7-33). Here, we suggest to use the entity5306- – for a dash in page ranges.5307-5308- [publisher] The publisher's name.5309-5310- [school] The name of the school where a thesis was written.5311-5312- [series] The name of a series or set of books. When citing an entire5313- book, the the title field gives its title and an optional series field5314- gives the name of a series or multi-volume set in which the book is5315- published.5316-5317- [title] The work's title. For mathematical formulae use the <M> or5318- <Math> elements explained below (and LaTeX code in the content, without5319- surrounding '$').5320-5321- [type] The type of a technical report-for example, ``Research5322- Note''.5323-5324- [volume] The volume of a journal or multivolume book.5325-5326- [year] The year of publication or, for an unpublished work, the year5327- it was written. Generally it should consist of four numerals, such as5328- 1984, although the standard styles can handle any year whose last four5329- nonpunctuation characters are numerals, such as `(about 1984)'.5330-->53315332<!-- Here is the main extension compared to the original BibXML definition5333from which is DTD is derived: We want to allow more markup in some5334elements such that we can use the bibliography for high quality5335output in other formats than LaTeX.53365337- <M> and <Math>, mathematical formulae: Specify LaTeX code for "simple"5338formulae as content of <M> elements; "simple" means that they can be5339translated to a fairly readable ASCII representation as explained in5340the GAPDoc documentation on "<M>".5341More complicated formulae are given as content of <Math> elements.5342(Think about an <Alt> alternative for text or HTML representations.)53435344- <URL>: use these elements to specify URLs, they can be properly5345converted to links if possible in an output format (in that case5346the Text attribute is used for the visible text).53475348- <value key="..."/>: substituted by the value-attribute specified5349in a <string key="..." value="..."/> element. Can be used anywhere,5350not only for complete fields as in BibTeX.53515352- <C> protect case changes: should be used instead of {}'s which are5353used in BibTeX title fields to protect the case of letters from5354changes.53555356- <Alt Only="...">, <Alt Not="...">, alternatives for different5357output formats: Use this to specify alternatives, the GAPDoc5358utilities will do some special handling for "Text", "HTML",5359and "BibTeX" as output type.53605361- <Wrap Name="...">, generic wrapper for other markup:5362Use this for any other type of markup you are interested in. The5363GAPDoc utilities will ignore the markup, but provide a hook5364to do install handler functions for them.5365-->5366<!ELEMENT M (#PCDATA | Alt)* > <!-- math with simple text5367representation, in LaTeX -->5368<!ELEMENT Math (#PCDATA | Alt)* > <!-- other math in LaTeX -->5369<!ELEMENT URL (#PCDATA | Alt | Link | LinkText)* > <!-- an URL -->5370<!ATTLIST URL Text CDATA #IMPLIED> <!-- text to be printed5371(default is content) -->5372<!ELEMENT value EMPTY > <!-- placeholder for value given .. -->5373<!ATTLIST value key CDATA #REQUIRED > <!-- .. by key, defined in a string5374element -->5375<!ELEMENT C (#PCDATA | value | Alt |5376M | Math | Wrap | URL)* > <!-- protect from case changes -->5377<!ELEMENT Alt (#PCDATA | value | C | Alt |5378M | Math | Wrap | URL)* > <!-- specify alternatives for5379various types of output -->5380<!ATTLIST Alt Only CDATA #IMPLIED5381Not CDATA #IMPLIED > <!-- specify output types in comma and5382whitespace separated list (use exactly one of Only or Not) -->53835384<!ENTITY % withMURL "(#PCDATA | value | M | Math | Wrap | URL | C | Alt )*" >53855386<!ELEMENT Wrap %withMURL; > <!-- a generic wrapper -->5387<!ATTLIST Wrap Name CDATA #REQUIRED > <!-- needs a 'Name' attribute -->53885389<!ELEMENT address %withMURL; >5390<!-- here we don't want the complicated definition from the LaTeX book,5391use markup for first/last name(s): a <name> element for each5392author which contains <first> (optional), <last> elements: -->5393<!ELEMENT author (name)* >5394<!ELEMENT name (first?, last) >5395<!ELEMENT first (#PCDATA) >5396<!ELEMENT last (#PCDATA) >53975398<!ELEMENT booktitle %withMURL; >5399<!ELEMENT chapter %withMURL; >5400<!ELEMENT edition %withMURL; >5401<!-- same as for author field -->5402<!ELEMENT editor (name)* >5403<!ELEMENT howpublished %withMURL; >5404<!ELEMENT institution %withMURL; >5405<!ELEMENT journal %withMURL; >5406<!ELEMENT month %withMURL; >5407<!ELEMENT note %withMURL; >5408<!ELEMENT number %withMURL; >5409<!ELEMENT organization %withMURL; >5410<!ELEMENT pages %withMURL; >5411<!ELEMENT publisher %withMURL; >5412<!ELEMENT school %withMURL; >5413<!ELEMENT series %withMURL; >5414<!ELEMENT title %withMURL; >5415<!ELEMENT type %withMURL; >5416<!ELEMENT volume %withMURL; >5417<!ELEMENT year (#PCDATA) >54185419<!-- These were not listed in the documentation for entry content, but5420- appeared in the list of fields in the BibTeX documentation -->54215422<!ELEMENT annotate %withMURL; >5423<!ELEMENT crossref %withMURL; >5424<!ELEMENT key (#PCDATA) >542554265427<!-- ..................................................................... -->5428<!-- Other popular fields5429-5430- From: http://www.ecst.csuchico.edu/~jacobsd/bib/formats/bibtex.html5431- BibTeX is extremely popular, and many people have used it to store5432- information. Here is a list of some of the more common fields:5433-5434- [affiliation] The authors affiliation.5435- [abstract] An abstract of the work.5436- [contents] A Table of Contents5437- [copyright] Copyright information.5438- [ISBN] The International Standard Book Number.5439- [ISSN] The International Standard Serial Number.5440- Used to identify a journal.5441- [keywords] Key words used for searching or possibly for annotation.5442- [language] The language the document is in.5443- [location] A location associated with the entry,5444- such as the city in which a conference took place.5445- [LCCN] The Library of Congress Call Number.5446- I've also seen this as lib-congress.5447- [mrnumber] The Mathematical Reviews number.5448- [mrclass] The Mathematical Reviews class.5449- [mrreviewer] The Mathematical Reviews reviewer.5450- [price] The price of the document.5451- [size] The physical dimensions of a work.5452- [URL] The WWW Universal Resource Locator that points to the item being5453- referenced. This often is used for technical reports to point to the5454- ftp site where the postscript source of the report is located.5455-5456- When using BibTeX with LaTeX you need5457- BibTeX style files to print these data.5458-->54595460<!ELEMENT abstract %withMURL; >5461<!ELEMENT affiliation %withMURL; >5462<!ELEMENT contents %withMURL; >5463<!ELEMENT copyright %withMURL; >5464<!ELEMENT isbn (#PCDATA) >5465<!ELEMENT issn (#PCDATA) >5466<!ELEMENT keywords %withMURL; >5467<!ELEMENT language %withMURL; >5468<!ELEMENT lccn (#PCDATA) >5469<!ELEMENT location %withMURL; >5470<!ELEMENT mrnumber %withMURL; >5471<!ELEMENT mrclass %withMURL; >5472<!ELEMENT mrreviewer %withMURL; >5473<!ELEMENT price %withMURL; >5474<!ELEMENT size %withMURL; >5475<!ELEMENT url %withMURL; >547654775478<!-- Added by Zeger W. Hendrikse5479- [category] Category of this bibitem5480-->5481<!ELEMENT category %withMURL; >54825483<!-- A container element [other] for any further information, a description5484- of the type of data must be given in the attribute 'type'5485-->5486<!ELEMENT other %withMURL; >5487<!ATTLIST other5488type CDATA #REQUIRED >548954905491<!-- ..................................................................... -->5492<!-- Predefined/reserved character entities -->54935494<!ENTITY amp "&#38;">5495<!ENTITY lt "&#60;">5496<!ENTITY gt ">">5497<!ENTITY apos "'">5498<!ENTITY quot """>549955005501<!-- Some more generally useful entities -->5502<!ENTITY nbsp " ">5503<!ENTITY copyright "©">5504<!ENTITY ndash "–">550555065507<!-- ..................................................................... -->5508<!-- End of BibXMLext dtd -->55095510\end{Verbatim}5511}55125513\def\bibname{References\logpage{[ "Bib", 0, 0 ]}5514\hyperdef{L}{X7A6F98FD85F02BFE}{}5515}55165517\bibliographystyle{alpha}5518\bibliography{gapdocbib.xml}55195520\addcontentsline{toc}{chapter}{References}55215522\def\indexname{Index\logpage{[ "Ind", 0, 0 ]}5523\hyperdef{L}{X83A0356F839C696F}{}5524}55255526\cleardoublepage5527\phantomsection5528\addcontentsline{toc}{chapter}{Index}552955305531\printindex55325533\newpage5534\immediate\write\pagenrlog{["End"], \arabic{page}];}5535\immediate\closeout\pagenrlog5536\end{document}553755385539