Skip to content

Commit 436e185

Browse files
GAPgap
authored andcommitted
Now allowing unicode characters for certain mathematical symbols
in mathematical formulae (and outside of them). Adjusted code, documentation, examples. Introduced entities &NN;, &ZZ;, and some more for \mathbb characters as a start. git-svn-id: path/gapdoc/trunk@185
1 parent 15dd621 commit 436e185

File tree

13 files changed

+144
-140
lines changed

13 files changed

+144
-140
lines changed

3k+1/3k+1.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<!-- A complete "fake package" documentation
4-
$Id: 3k+1.xml,v 1.3 2007-09-25 09:30:35 gap Exp $
4+
$Id: 3k+1.xml,v 1.4 2007-10-04 22:02:12 gap Exp $
55
-->
66

77
<!DOCTYPE Book SYSTEM "gapdoc.dtd">
@@ -25,14 +25,12 @@
2525
<Body>
2626
<Chapter> <Heading>The <M>3k+1</M> Problem</Heading>
2727
<Section Label="sec:theory"> <Heading>Theory</Heading>
28-
Let <M>k \in {\mathbb N}</M> be a natural number. We consider
29-
the sequence <M>n(i, k), i \in {\mathbb N},</M> with <M>n(1, k)
30-
= k</M> and else <M>n(i+1, k) = n(i, k) / 2</M> if <M>n(i,
31-
k)</M> is even and <M>n(i+1, k) = 3 n(i, k) + 1</M> if <M>n(i,
32-
k)</M> is odd. <P/>
33-
It is not known whether for any natural number <M>k \in {\mathbb
34-
N}</M> there is an <M>m \in {\mathbb N}</M> with <M>n(m, k) =
35-
1</M>.
28+
Let <M>k \in &NN;</M> be a natural number. We consider the
29+
sequence <M>n(i, k), i \in &NN;,</M> with <M>n(1, k) = k</M> and
30+
else <M>n(i+1, k) = n(i, k) / 2</M> if <M>n(i, k)</M> is even
31+
and <M>n(i+1, k) = 3 n(i, k) + 1</M> if <M>n(i, k)</M> is odd.
32+
<P/> It is not known whether for any natural number <M>k \in
33+
&NN;</M> there is an <M>m \in &NN;</M> with <M>n(m, k) = 1</M>.
3634
<P/>
3735
<Package>ThreeKPlusOne</Package> provides the function <Ref
3836
Func="ThreeKPlusOneSequence"/> to explore this for given

CHANGES

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22

33
1.0 -> 1.1
44

5+
- We allow unicode characters which have useful translations to
6+
LaTeX and as simplified string (with one character, for the moment)
7+
in mathematical formulae. Introduced entities &CC;, &ZZ;, &NN;, &PP;,
8+
&QQ;, &HH;, &RR; for \mathbb characters.
9+
10+
- Now chapter numbers in references to chapters are without trailing
11+
dot in text and HTML converters.
12+
13+
- Fixed bug with vertical spacing for <Verb> in text converter.
14+
515
- GAPDoc can now be used with other languages than English, see
616
'SetGapDocLanguage' for details.
717

18+
- Various documentation improvements.
19+
820
- New options "utf8" and "nopslatex" for LaTeX converter, see
921
'SetGapDocLaTeXOptions'.
1022

1123
- Introduced "LaTeXUTF8" encoding (uses known translations but leaves
1224
other characters as they are).
1325

1426
- Removed support of '\N, \Z, ...' for '{\mathbb N}, {\mathbb Z}, ...
15-
(was not documented before).
27+
(was not documented before). But see &NN; above.
1628

1729
- Introduced 'WrapTextAttribute' which takes care of existing escape
1830
sequences in the text to wrap. Use it for the text converter to handle

doc/app3k1.xml

Lines changed: 0 additions & 78 deletions
This file was deleted.

doc/enter.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: enter.xml,v 1.13 2007-09-27 16:40:03 gap Exp $ -->
1+
<!-- $Id: enter.xml,v 1.14 2007-10-04 22:02:12 gap Exp $ -->
22
<Chapter Label="HowEnter">
33
<Heading>How To Type a &GAPDoc; Document</Heading>
44

@@ -360,7 +360,10 @@ In &GAPDoc; there are some more predefined entities:
360360
Here <C>&amp;nbsp;</C> is a non-breakable space character.
361361
<P/>
362362

363-
One can define further local entities right inside the head (see&nbsp;<Ref
363+
Additional entities are defined for some mathematical symbols, see <Ref
364+
Sect="MathForm"/> for more details.
365+
<P/>
366+
One can define further local entities right inside the head (see&nbsp;<Ref
364367
Subsect="XMLhead"/>) of a &GAPDoc; XML document as in the following example.
365368

366369
<Listing Type="Example">

doc/gapdoc.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!DOCTYPE Book SYSTEM "gapdoc.dtd">
44

5-
<!-- $Id: gapdoc.xml,v 1.11 2007-05-31 12:27:30 gap Exp $ -->
5+
<!-- $Id: gapdoc.xml,v 1.12 2007-10-04 22:02:12 gap Exp $ -->
66

77
<!-- The documentation to the GAPDoc system.
88
Copyright 2000-2007 by Frank Lübeck and Max Neunhöffer
@@ -57,7 +57,14 @@ gap> SizeScreen([72,40]);;
5757

5858
</Body>
5959

60-
<#Include SYSTEM "app3k1.xml">
60+
<Appendix Label="app:3k+1"><Heading>The File <F>3k+1.xml</F></Heading>
61+
62+
Here is the complete source of the example &GAPDoc; document <F>3k+1.xml</F>
63+
discussed in Section&nbsp;<Ref Sect="sec:3k+1expl" />.
64+
65+
<Listing Type="3k+1.xml">
66+
<![CDATA[<#Include SYSTEM "../3k+1/3k+1.xml">]]></Listing>
67+
</Appendix>
6168

6269
<Appendix Label="GAPDocdtd">
6370
<Heading>The File <F>gapdoc.dtd</F></Heading>

doc/intro.xml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: intro.xml,v 1.12 2007-09-27 16:40:03 gap Exp $ -->
1+
<!-- $Id: intro.xml,v 1.13 2007-10-04 22:02:12 gap Exp $ -->
22
<Chapter Label="ch:intro"><Heading>Introduction and Example</Heading>
33

44
The main purpose of the &GAPDoc; package is to define a file format for
@@ -67,7 +67,7 @@ character set (other common encodings are ASCII or ISO-8895-X encodings).
6767

6868
<Listing Type="from 3k+1.xml">
6969
<![CDATA[<!-- A complete "fake package" documentation
70-
$Id: intro.xml,v 1.12 2007-09-27 16:40:03 gap Exp $
70+
$Id: intro.xml,v 1.13 2007-10-04 22:02:12 gap Exp $
7171
-->
7272
]]></Listing>
7373

@@ -203,31 +203,34 @@ The text of the first section starts as follows. The whitespace in the text
203203
is unimportant and the indenting is not necessary.
204204

205205
<Listing Type="from 3k+1.xml">
206-
<![CDATA[ Let <M>k \in {\mathbb N}</M> be a natural number. We consider
207-
the sequence <M>n(i, k), i \in {\mathbb N},</M> with <M>n(1, k)
208-
= k</M> and else
206+
207+
<![CDATA[ Let <M>k \in &NN;</M> be a natural number. We consider the
208+
sequence <M>n(i, k), i \in &NN;,</M> with <M>n(1, k) = k</M> and
209+
else
209210
]]></Listing>
210211

211212
Here we come to the interesting question how to type mathematical formulae
212213
in a &GAPDoc; document. We did not find any alternative for writing formulae
213-
in &TeX; syntax. (There is MATHML, but even simple formulae contain a lot of
214-
markup, become quite unreadable and they are cumbersome to type. Furthermore
215-
there seem to be no tools available which translate such formulae in a nice
216-
way into &TeX; and text.) So, formulae are typed as in &LaTeX;. There are
217-
three types of elements containing formulae: <Q>M</Q>, <Q>Math</Q> and
218-
<Q>Display</Q>. The first two are for in-text formulae and the third is
219-
for displayed formulae. Here <Q>M</Q> and <Q>Math</Q> are equivalent,
220-
when translating a &GAPDoc; document into &LaTeX;. But they are handled
221-
differently for terminal text (and HTML) output. For the content of an
222-
<Q>M</Q>-element there are defined rules for a translation into well
223-
readable terminal text. More complicated formulae are in <Q>Math</Q> or
224-
<Q>Display</Q> elements and they are just printed as they are typed in text
225-
output. So, to make a section well readable inside a terminal window you
226-
should try to put as many formulae as possible into <Q>M</Q>-elements.
227-
In our example text we used the notation <C>n(i, k)</C> instead of
228-
<C>n_i(k)</C> because it is easier to read in text mode. See
214+
in &TeX; syntax. (There is MATHML, but even simple formulae contain a lot
215+
of markup, become quite unreadable and they are cumbersome to type.
216+
Furthermore there seem to be no tools available which translate such
217+
formulae in a nice way into &TeX; and text.) So, formulae are essentially
218+
typed as in &LaTeX;. (Actually, it is also possible to type unicode
219+
characters of some mathematical symbols directly, or via an entity like the
220+
<C>&amp;NN;</C> above.) There are three types of elements containing
221+
formulae: <Q>M</Q>, <Q>Math</Q> and <Q>Display</Q>. The first two are for
222+
in-text formulae and the third is for displayed formulae. Here <Q>M</Q> and
223+
<Q>Math</Q> are equivalent, when translating a &GAPDoc; document into
224+
&LaTeX;. But they are handled differently for terminal text (and HTML)
225+
output. For the content of an <Q>M</Q>-element there are defined rules for a
226+
translation into well readable terminal text. More complicated formulae are
227+
in <Q>Math</Q> or <Q>Display</Q> elements and they are just printed as they
228+
are typed in text output. So, to make a section well readable inside a
229+
terminal window you should try to put as many formulae as possible into
230+
<Q>M</Q>-elements. In our example text we used the notation <C>n(i, k)</C>
231+
instead of <C>n_i(k)</C> because it is easier to read in text mode. See
229232
Sections&nbsp;<Ref Sect="GDformulae"/> and&nbsp;<Ref Sect="sec:misc" /> for
230-
more details. <P/>
233+
more details. <P/>
231234

232235
A few lines further on we find two non-internal references.
233236

doc/refdtd.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Id: refdtd.xml,v 1.24 2007-09-27 16:40:03 gap Exp $ -->
1+
<!-- $Id: refdtd.xml,v 1.25 2007-10-04 22:02:12 gap Exp $ -->
22
<Chapter Label="DTD">
33
<Heading>The Document Type Definition</Heading>
44

@@ -1376,6 +1376,14 @@ using the corresponding entities or by enclosing the formula between
13761376
<Q><C>&lt;![CDATA[</C></Q> and <Q><C>]]&gt;</C></Q>. (The main reference
13771377
for &LaTeX; is <Cite Key="La85" />.)<P/>
13781378

1379+
It is also possible to use some unicode characters for mathematical
1380+
symbols directly, provided that it can be translated by <Ref Func="Encode" /> into <C>"LaTeX"</C> encoding and that <Ref Func="SimplifiedUnicodeString"/> with arguments <C>"latin1"</C> and <C>"single"</C> returns something sensible.
1381+
Currently, we support entities <C>&amp;CC;</C>, <C>&amp;ZZ;</C>,
1382+
<C>&amp;NN;</C>, <C>&amp;PP;</C>, <C>&amp;QQ;</C>, <C>&amp;HH;</C>,
1383+
<C>&amp;RR;</C> for the corresponding black board bold letters
1384+
&CC;, &ZZ;, &NN;,&PP;, &QQ;, &HH; and &RR;, respectively.
1385+
<P/>
1386+
13791387
The only element type that is allowed within the formula elements is the
13801388
<C>Arg</C> or <C>A</C> element (see <Ref Subsect="Arg"/>), which is used to
13811389
typeset identifiers that are arguments to &GAP; functions or operations.<P/>

example/example.xml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- $Id: example.xml,v 1.16 2007-05-31 12:27:30 gap Exp $ -->
3+
<!-- $Id: example.xml,v 1.17 2007-10-04 22:02:12 gap Exp $ -->
44

55
<!DOCTYPE Book SYSTEM "gapdoc.dtd"
6-
[ <!ENTITY see '<Alt Only="LaTeX">$\to$</Alt><Alt Not="LaTeX">--&gt;</Alt>'>]>
6+
[ <!ENTITY see '<Alt Only="LaTeX">$\to$</Alt><Alt Not="LaTeX">--&gt;</Alt>'>
7+
]>
78

89
<Book Name="GAPDoc Example">
910

@@ -46,7 +47,6 @@
4647
<Body>
4748
Text before chapter <Ref Chap="First"/>. (&see; <Ref Sect="Two"/>)
4849

49-
5050
<Chapter Label="First"><Heading>Sectioning Elements</Heading>
5151

5252
Text before the section <Ref Sect="FirstSect"/>. (&see; <Ref Sect="Two"/>)
@@ -431,7 +431,10 @@ Here is a <E>table</E>:
431431

432432
[&see; <Ref Sect="Ten"/>]<P/>
433433

434-
Here is the table of special characters:
434+
Here is a table of special characters, the first two are special for
435+
XML and must be typed in by entities in &GAPDoc; documents. The other
436+
characters are special for &LaTeX; but in &GAPDoc; they can be typed
437+
directly.
435438

436439
<Table Align="|c|c|c|c|c|c|c|c|c|c|c|c|c|" Label="charsInCDATA">
437440
<Caption>Special characters in character data</Caption>
@@ -475,6 +478,8 @@ And here are the predefined entities in &GAPDoc;:
475478
<HorLine/>
476479
</Table>
477480

481+
And some more for mathematical symbols:
482+
&CC;, &ZZ;, &NN;, &PP;, &QQ;, &HH;, &RR;.
478483

479484
</Section>
480485

@@ -949,10 +954,16 @@ Here is a <E>table</E>:
949954

950955
<Listing>
951956
<![CDATA[<Section><Heading>Entities and Special Characters</Heading>
957+
<Label Name="TenBack"/>
952958
953-
Here is the table of special characters:
959+
[&see; <Ref Sect="Ten"/>]<P/>
954960
955-
<Table Align="|c|c|c|c|c|c|c|c|c|c|c|c|c|c|" Label="charsInCDATA">
961+
Here is a table of special characters, the first two are special for
962+
XML and must be typed in by entities in &GAPDoc; documents. The other
963+
characters are special for &LaTeX; but in &GAPDoc; they can be typed
964+
directly.
965+
966+
<Table Align="|c|c|c|c|c|c|c|c|c|c|c|c|c|" Label="charsInCDATA">
956967
<Caption>Special characters in character data</Caption>
957968
<HorLine/> <Row>
958969
<Item><C>&amp;</C></Item>
@@ -994,6 +1005,8 @@ And here are the predefined entities in &GAPDoc;:
9941005
<HorLine/>
9951006
</Table>
9961007
1008+
And some more for mathematical symbols:
1009+
&CC;, &ZZ;, &NN;, &PP;, &QQ;, &HH;, &RR;.
9971010
9981011
</Section>
9991012

gapdoc.dtd

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
By Frank Lübeck and Max Neunhöffer
55
================================================================== -->
66

7-
<!-- $Id: gapdoc.dtd,v 1.15 2007-05-21 22:07:18 gap Exp $ -->
7+
<!-- $Id: gapdoc.dtd,v 1.16 2007-10-04 22:02:12 gap Exp $ -->
88

99
<!-- Note that this definition goes "bottom-up" because entities can only
1010
be used after their definition in the file. -->
@@ -58,6 +58,15 @@
5858
<!ENTITY XGAP "<Package>XGAP</Package>">
5959
<!ENTITY copyright "&#169;">
6060

61+
<!-- and unicode math symbols -->
62+
<!ENTITY CC "&#x2102;" > <!-- double struck -->
63+
<!ENTITY ZZ "&#x2124;" >
64+
<!ENTITY NN "&#x2115;" >
65+
<!ENTITY PP "&#x2119;" >
66+
<!ENTITY QQ "&#x211a;" >
67+
<!ENTITY HH "&#x210d;" >
68+
<!ENTITY RR "&#x211d;" >
69+
6170

6271
<!-- ==================================================================
6372
The following describes the "innermost" documentation text which

init.g

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##
33
#A init.g GAPDoc Frank Lübeck / Max Neunhöffer
44
##
5-
#H @(#)$Id: init.g,v 1.16 2007-06-13 16:02:50 gap Exp $
5+
#H @(#)$Id: init.g,v 1.17 2007-10-04 22:02:12 gap Exp $
66
##
77
#Y Copyright (C) 2000, Frank Lübeck and Max Neunhöffer,
88
#Y Lehrstuhl D für Mathematik, RWTH Aachen
@@ -28,7 +28,10 @@ ReadPackage("GAPDoc", "lib/HelpBookHandler.g");
2828
# try to find terminal encoding
2929
GAPInfo.tmpfunc := function()
3030
local env, pos, enc, a;
31-
if not IsBound(GAPInfo.TermEncoding) then
31+
# we leave the GAPInfo.TermEncodingOverwrite for .gaprc
32+
# for a moment, but don't document it - doesn't work with
33+
# loaded workspaces
34+
if not IsBound(GAPInfo.TermEncodingOverwrite) then
3235
if IsList(GAPInfo.SystemEnvironment) then
3336
# for compatibility with GAP 4.4.
3437
env := rec();
@@ -58,6 +61,8 @@ GAPInfo.tmpfunc := function()
5861
# default is latin1
5962
GAPInfo.TermEncoding := "ISO-8859-1";
6063
fi;
64+
else
65+
GAPInfo.TermEncoding := GAPInfo.TermEncodingOverwrite;
6166
fi;
6267
end;
6368
GAPInfo.tmpfunc();

0 commit comments

Comments
 (0)