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: 4183461[1X1 [33X[0;0YIntroduction and Example[133X[101X23[33X[0;0YThe main purpose of the [5XGAPDoc[105X package is to define a file format for4documentation of [5XGAP[105X-programs and -packages (see [GAP06]). The problem is5that such documentation should be readable in several output formats. For6example it should be possible to read the documentation inside the terminal7in which [5XGAP[105X is running (a text mode) and there should be a printable8version in high typesetting quality (produced by some version of TeX). It is9also popular to view [5XGAP[105X's online help with a Web-browser via an10HTML-version of the documentation. Nowadays one can use LaTeX and standard11viewer programs to produce and view on the screen [10Xdvi[110X- or [10Xpdf[110X-files with12full support of internal and external hyperlinks. Certainly there will be13other interesting document formats and tools in this direction in the14future.[133X1516[33X[0;0YOur aim is to find a [13Xformat for writing[113X the documentation which allows a17relatively easy translation into the output formats just mentioned and which18hopefully makes it easy to translate to future output formats as well.[133X1920[33X[0;0YTo make documentation written in the [5XGAPDoc[105X format directly usable, we also21provide a set of programs, called converters, which produce text-,22hyperlinked LaTeX- and HTML-output versions of a [5XGAPDoc[105X document. These23programs are developed by the first named author. They run completely inside24[5XGAP[105X, i.e., no external programs are needed. You only need [10Xlatex[110X and [10Xpdflatex[110X25to process the LaTeX output. These programs are described in Chapter [14X5[114X.[133X262728[1X1.1 [33X[0;0YXML[133X[101X2930[33X[0;0YThe definition of the [5XGAPDoc[105X format uses XML, the [21XeXtendible Markup31Language[121X. This is a standard (defined by the W3C consortium, see32[7Xhttp://www.w3c.org[107X) which lays down a syntax for adding markup to a document33or to some data. It allows to define document structures via introducing34markup [13Xelements[113X and certain relations between them. This is done in a35[13Xdocument type definition[113X. The file [11Xgapdoc.dtd[111X contains such a document type36definition and is the central part of the [5XGAPDoc[105X package.[133X3738[33X[0;0YThe easiest way for getting a good idea about this is probably to look at an39example. The Appendix [14XA[114X contains a short but complete [5XGAPDoc[105X document for a40fictitious share package. In the next section we will go through this41document, explain basic facts about XML and the [5XGAPDoc[105X document type, and42give pointers to more details in later parts of this documentation.[133X4344[33X[0;0YIn the last Section [14X1.3[114X of this introductory chapter we try to answer some45general questions about the decisions which lead to the [5XGAPDoc[105X package.[133X464748[1X1.2 [33X[0;0YA complete example[133X[101X4950[33X[0;0YIn this section we recall the lines from the example document in Appendix [14XA[114X51and give some explanations.[133X5253[4X[32X from 3k+1.xml [32X[104X54[4X<?xml version="1.0" encoding="UTF-8"?> [104X55[4X[32X[104X5657[33X[0;0YThis line just tells a human reader and computer programs that the file is a58document with XML markup and that the text is encoded in the UTF-8 character59set (other common encodings are ASCII or ISO-8895-X encodings).[133X6061[4X[32X from 3k+1.xml [32X[104X62[4X<!-- A complete "fake package" documentation [104X63[4X-->[104X64[4X[32X[104X6566[33X[0;0YEverything in a XML file between [21X[10X<!--[110X[121X and [21X[10X-->[110X[121X is a comment and not part of67the document content.[133X6869[4X[32X from 3k+1.xml [32X[104X70[4X<!DOCTYPE Book SYSTEM "gapdoc.dtd">[104X71[4X[32X[104X7273[33X[0;0YThis line says that the document contains markup which is defined in the74system file [11Xgapdoc.dtd[111X and that the markup obeys certain rules defined in75that file (the ending [11Xdtd[111X means [21Xdocument type definition[121X). It further says76that the actual content of the document consists of an element with name77[21XBook[121X. And we can really see that the remaining part of the file is enclosed78as follows:[133X7980[4X[32X from 3k+1.xml [32X[104X81[4X<Book Name="3k+1">[104X82[4X [...] (content omitted)[104X83[4X</Book>[104X84[4X[32X[104X8586[33X[0;0YThis demonstrates the basics of the markup in XML. This part of the document87is an [21Xelement[121X. It consists of the [21Xstart tag[121X [10X<Book Name="3k+1">[110X, the [21Xelement88content[121X and the [21Xend tag[121X [10X</Book>[110X (end tags always start with [10X</[110X). This89element also has an [21Xattribute[121X [10XName[110X whose [21Xvalue[121X is [10X3k+1[110X.[133X9091[33X[0;0YIf you know HTML, this will look familiar to you. But there are some92important differences: The element name [10XBook[110X and attribute name [10XName[110X are93[13Xcase sensitive[113X. The value of an attribute must [13Xalways[113X be enclosed in quotes.94In XML [13Xevery[113X element has a start and end tag (which can be combined for95elements defined as [21Xempty[121X, see for example [10X<TableOfContents/>[110X below).[133X9697[33X[0;0YIf you know LaTeX, you are familiar with quite different types of markup,98for example: The equivalent of the [10XBook[110X element in LaTeX is [10X\begin{document}99... \end{document}[110X. The sectioning in LaTeX is not done by explicit start100and end markup, but implicitly via heading commands like [10X\section[110X. Other101markup is done by using braces [10X{}[110X and putting some commands inside. And for102mathematical formulae one can use the [10X$[110X for the start [13Xand[113X the end of the103markup. In XML [13Xall[113X markup looks similar to that of the [10XBook[110X element.[133X104105[33X[0;0YThe content of the book starts with a title page.[133X106107[4X[32X from 3k+1.xml [32X[104X108[4X<TitlePage>[104X109[4X <Title>The <Package>ThreeKPlusOne</Package> Package</Title>[104X110[4X <Version>Version 42</Version>[104X111[4X <Author>Dummy Authör[104X112[4X <Email>[email protected]</Email>[104X113[4X </Author>[104X114[4X[104X115[4X <Copyright>©right; 2000 The Author. <P/>[104X116[4X You can do with this package what you want.<P/> Really.[104X117[4X </Copyright>[104X118[4X</TitlePage>[104X119[4X[32X[104X120121[33X[0;0YThe content of the [10XTitlePage[110X element consists again of elements. In122Chapter [14X3[114X we describe which elements are allowed within a [10XTitlePage[110X and that123their ordering is prescribed in this case. In the (stupid) name of the124author you see that a German umlaut is used directly (in ISO-latin1125encoding).[133X126127[33X[0;0YContrary to LaTeX- or HTML-files this markup does not say anything about the128actual layout of the title page in any output version of the document. It129just adds information about the [13Xmeaning[113X of pieces of text.[133X130131[33X[0;0YWithin the [10XCopyright[110X element there are two more things to learn about XML132markup. The [10X<P/>[110X is a complete element. It is a combined start and end tag.133This shortcut is allowed for elements which are defined to be always [21Xempty[121X,134i.e., to have no content. You may have already guessed that [10X<P/>[110X is used as135a paragraph separator. Note that empty lines do not separate paragraphs136(contrary to LaTeX).[133X137138[33X[0;0YThe other construct we see here is [10X©right;[110X. This is an example of an139[21Xentity[121X in XML and is a macro for some substitution text. Here we use an140entity as a shortcut for a complicated expression which makes it possible141that the term [13Xcopyright[113X is printed as some text like [10X(C)[110X in text terminal142output and as a copyright character in other output formats. In [5XGAPDoc[105X we143predefine some entities. Certain [21Xspecial characters[121X must be typed via144entities, for example [21X<[121X, [21X>[121X and [21X&[121X to avoid a misinterpretation as XML markup.145It is possible to define additional entities for your document inside the146[10X<!DOCTYPE ...>[110X declaration, see [14X2.2-3[114X.[133X147148[33X[0;0YNote that elements in XML must always be properly nested, as in this149example. A construct like [10X<a><b>...</a></b>[110X is [13Xnot[113X allowed.[133X150151[4X[32X from 3k+1.xml [32X[104X152[4X<TableOfContents/>[104X153[4X[32X[104X154155[33X[0;0YThis is another example of an [21Xempty element[121X. It just means that a table of156contents for the whole document should be included into any output version157of the document.[133X158159[33X[0;0YAfter this the main text of the document follows inside certain sectioning160elements:[133X161162[4X[32X from 3k+1.xml [32X[104X163[4X<Body>[104X164[4X <Chapter> <Heading>The <M>3k+1</M> Problem</Heading>[104X165[4X <Section Label="sec:theory"> <Heading>Theory</Heading>[104X166[4X [...] (content omitted)[104X167[4X </Section>[104X168[4X <Section> <Heading>Program</Heading>[104X169[4X [...] (content omitted) [104X170[4X </Section>[104X171[4X </Chapter>[104X172[4X</Body>[104X173[4X[32X[104X174175[33X[0;0YThese elements are used similarly to [21X\chapter[121X and [21X\section[121X in LaTeX. But176note that the explicit end tags are necessary here.[133X177178[33X[0;0YThe sectioning commands allow to assign an optional attribute [21XLabel[121X. This179can be used for referring to a section inside the document.[133X180181[33X[0;0YThe text of the first section starts as follows. The whitespace in the text182is unimportant and the indenting is not necessary.[133X183184[4X[32X from 3k+1.xml [32X[104X185[4X[104X186[4X Let <M>k \in &NN;</M> be a natural number. We consider the[104X187[4X sequence <M>n(i, k), i \in &NN;,</M> with <M>n(1, k) = k</M> and[104X188[4X else [104X189[4X[32X[104X190191[33X[0;0YHere we come to the interesting question how to type mathematical formulae192in a [5XGAPDoc[105X document. We did not find any alternative for writing formulae193in TeX syntax. (There is MATHML, but even simple formulae contain a lot of194markup, become quite unreadable and they are cumbersome to type. Furthermore195there seem to be no tools available which translate such formulae in a nice196way into TeX and text.) So, formulae are essentially typed as in LaTeX.197(Actually, it is also possible to type unicode characters of some198mathematical symbols directly, or via an entity like the [10X&NN;[110X above.) There199are three types of elements containing formulae: [21XM[121X, [21XMath[121X and [21XDisplay[121X. The200first two are for in-text formulae and the third is for displayed formulae.201Here [21XM[121X and [21XMath[121X are equivalent, when translating a [5XGAPDoc[105X document into202LaTeX. But they are handled differently for terminal text (and HTML) output.203For the content of an [21XM[121X-element there are defined rules for a translation204into well readable terminal text. More complicated formulae are in [21XMath[121X or205[21XDisplay[121X elements and they are just printed as they are typed in text output.206So, to make a section well readable inside a terminal window you should try207to put as many formulae as possible into [21XM[121X-elements. In our example text we208used the notation [10Xn(i, k)[110X instead of [10Xn_i(k)[110X because it is easier to read in209text mode. See Sections [14X2.2-2[114X and [14X3.9[114X for more details.[133X210211[33X[0;0YA few lines further on we find two non-internal references.[133X212213[4X[32X from 3k+1.xml [32X[104X214[4X problem, see <Cite Key="Wi98"/> or[104X215[4X <URL>http://mathsrv.ku-eichstaett.de/MGF/homes/wirsching/</URL>[104X216[4X[32X[104X217218[33X[0;0YThe first within the [21XCite[121X-element is the citation of a book. In [5XGAPDoc[105X we219use the widely used BibTeX database format for reference lists. This does220not use XML but has a well documented structure which is easy to parse. And221many people have collections of references readily available in this format.222The reference list in an output version of the document is produced with the223empty element[133X224225[4X[32X from 3k+1.xml [32X[104X226[4X<Bibliography Databases="3k+1" />[104X227[4X[32X[104X228229[33X[0;0Yclose to the end of our example file. The attribute [21XDatabases[121X give the230name(s) of the database ([11X.bib[111X) files which contain the references.[133X231232[33X[0;0YPutting a Web-address into an [21XURL[121X-element allows one to create a hyperlink233in output formats which allow this.[133X234235[33X[0;0YThe second section of our example contains a special kind of subsection236defined in [5XGAPDoc[105X.[133X237238[4X[32X from 3k+1.xml [32X[104X239[4X <ManSection> [104X240[4X <Func Name="ThreeKPlusOneSequence" Arg="k[, max]"/>[104X241[4X <Description>[104X242[4X This function computes for a natural number <A>k</A> the[104X243[4X beginning of the sequence <M>n(i, k)</M> defined in section[104X244[4X <Ref Sect="sec:theory"/>. The sequence stops at the first[104X245[4X <M>1</M> or at <M>n(<A>max</A>, k)</M>, if <A>max</A> is[104X246[4X given.[104X247[4X<Example>[104X248[4Xgap> ThreeKPlusOneSequence(101);[104X249[4X"Sorry, not yet implemented. Wait for Version 84 of the package"[104X250[4X</Example>[104X251[4X </Description>[104X252[4X </ManSection>[104X253[4X[32X[104X254255[33X[0;0YA [21XManSection[121X contains the description of some function, operation, method,256filter and so on. The [21XFunc[121X-element describes the name of a [13Xfunction[113X (there257are also similar elements [21XOper[121X, [21XMeth[121X, [21XFilt[121X and so on) and names for its258arguments, optional arguments enclosed in square brackets. See Section [14X3.4[114X259for more details.[133X260261[33X[0;0YIn the [21XDescription[121X we write the argument names as [21XA[121X-elements. A good262description of a function should usually contain an example of its use. For263this there are some verbatim-like elements in [5XGAPDoc[105X, like [21XExample[121X above264(here, clearly, whitespace matters which causes a slightly strange265indenting).[133X266267[33X[0;0YThe text contains an internal reference to the first section via the268explicitly defined label [10Xsec:theory[110X.[133X269270[33X[0;0YThe first section also contains a [21XRef[121X-element which refers to the function271described here. Note that there is no explicit label for such a reference.272The pair [10X<Func Name="ThreeKPlusOneSequence" Arg="k[, max]"/>[110X and [10X<Ref273Func="ThreeKPlusOneSequence"/>[110X does the cross referencing (and hyperlinking274if possible) implicitly via the name of the function.[133X275276[33X[0;0YHere is one further element from our example document which we want to277explain.[133X278279[4X[32X from 3k+1.xml [32X[104X280[4X<TheIndex/>[104X281[4X[32X[104X282283[33X[0;0YThis is again an empty element which just says that an output version of the284document should contain an index. Many entries for the index are generated285automatically because the [21XFunc[121X and similar elements implicitly produce such286entries. It is also possible to include explicit additional entries in the287index.[133X288289290[1X1.3 [33X[0;0YSome questions[133X[101X291292[8XAre those XML files too ugly to read and edit?[108X293[33X[0;6YJust have a look and decide yourself. The markup needs more characters294than most TeX or LaTeX markup. But the structure of the document is295easier to see. If you configure your favorite editor well, you do not296need more key strokes for typing the markup than in LaTeX.[133X297298[8XWhy do we not use LaTeX alone?[108X299[33X[0;6YLaTeX is good for writing books. But LaTeX files are generally300difficult to parse and to process to other output formats like text301for browsing in a terminal window or HTML (or new formats which may302become popular in the future). [5XGAPDoc[105X markup is one step more abstract303than LaTeX insofar as it describes meaning instead of appearance of304text. The inner workings of LaTeX are too complicated to learn without305pain, which makes it difficult to overcome problems that occur306occasionally.[133X307308[8XWhy XML and not a newly defined markup language?[108X309[33X[0;6YXML is a well defined standard that is more and more widely used. Lots310of people have thought about it. Years of experience with SGML went311into the design. It is easy to explain, easy to parse and lots of312tools are available, there will be more in the future.[133X313314315316