File: gapmacro.tex

package info (click to toggle)
gap 4.15.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 110,212 kB
  • sloc: ansic: 97,261; xml: 48,343; cpp: 13,946; sh: 4,900; perl: 1,650; javascript: 255; makefile: 252; ruby: 9
file content (1095 lines) | stat: -rw-r--r-- 40,835 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%A  gapmacro.tex                GAP manual                       Frank Celler
%A                                                             Heiko Theissen
%A                                                           Alexander Hulpke
%A                                                           Burkhard Höfling
%%
%%
%%  DO NOT RELY ON MACRO DEFINITIONS IN THIS FILE!
%%  The official definition of the manual style is to be found in the file
%%  `gapmacrodoc.tex'.
%%
%%  The following macros are defined in this file.
%%
%%  `text'   set text in typewriter style (use `\<' instead of `<')
%%  <text>   set text in italics (use $\<$ instead of $<$ for less than)
%%  *text*   set text in emphasized style (i.e. slanted)
%%  $a.b$    same as $a \cdot b$ (use $\.$ instead of $.$ for full stop)
%%  "ref"    refer to a label (like "function!for category")
%%  \pif     sets a single '
%%  \cite{.} make a citation
%%  \index{.} \indextt{.} make index entry (\indextt in typewriter style)
%%
%%  \beginitems         produce itemized texts with 3pc hanging indentation
%%    item & text
%%
%%    item & text ...
%%  \enditems
%%
%%  \begintt            verbatim text in typewriter style
%%    verbatim material
%%  \endtt
%%  \beginexample     verbatim text in typewriter style
%%    verbatim material
%%  \endexample
%%
%%  \Input{file}  includes file `file.tex'
%%  \Chapter{title} followed by a blank line
%%  \Section{title} followed by a blank line
%%      make  chapter  or section   title. Automatically  generates  table of
%%      contents. \null after \Section{...} inhibits indexing.
%%  \>function( arguments )!{ index subentry }
%%  \>`a binop b'{binary operation}!{ index subentry }
%%      make a  heading for a subsection   explaining a function  or a binary
%%      operation. This automatically generates   a label and an  index entry
%%      (with optional subentry).
%%  \){\fmark ...}
%%      the same without label and index entry
%%
%%  \URL{url}
%%  \Mailto{}
%%
%%  \BeginningOfBook
%%  \FrontMatter, \Chapters, \Appendices, \EndMatter     parts of the book
%%  \Bibliography, \Index, \TableOfContents  make these chapters (w/o head)
%%  \EndOfBook
%%
%%  The following macros can be used just after inputting gapmacro.tex to control
%%  the layout.
%%    \casesensitivetrue makes labels case sensitive (this is still experimental
%%     and not currently supported by the html converter)
%%  \casesensitivefalse & (default) labels are case insensitive
%%
%%  \addlinks (default) This inserts pdf links within the document, so
%%    that you can click on a reference or citation. This will only work
%%    with pdftex, otherwise this has no effect.
%%
%%  \nolinks This switches off additional pdf links within the document.
%%
%%  \citebookstrue References to external books will be
%%     "GAP Reference Manual, 2.7.12" instead of just "2.7.12", similarly
%%     for the GAP tutorial. If you cite other books, you have to define
%%     macros \xxxManual which must expand to the text which you want to
%%     be inserted before the number for package xxx (lower case).
%%  \citebooksfalse (default) just print the number
%%
%%  \usepsfonts (default) use the standard Postscript fonts for typesetting
%%  \usecmfonts use the TeX standard fonts
%%
%%  \biblitemfalse (default) In the bibliography, print abbreviations for
%%    papers right-aligned (as in gapmacro.tex)
%%  \biblitemtrue print abbreviations left-aligned
%%  \bibindent (default: 3 pc) indentation used in the bibliography -
%%    depending
%%    on the abbreviations you use, you may need more (this is not very
%%    obvious if you use \biblitemfalse because long abbreviations will
%%    protrude into the left margin only, but will cause overfull hboxes
%%    when using \biblitemtrue

\input amssym.tex

\catcode`@=11

% Page dimensions and double column output.
\hsize 39pc
\vsize 52pc

\gdef\nolinks{
    \gdef\nameddest##1{}%
    \gdef\startlink##1{}%
    \gdef\endlink{}%
}

\gdef\addlinks{
    \gdef\nameddest##1{%
      \ifx\debuglabels\undefined\else\immediate\write16{nameddest ##1 defined}\fi
       \ifvmode \pdfdest name{##1} xyz%
      \else\vbox to 0pt{\vss\pdfdest name{##1} xyz%
      \vskip\baselineskip}\fi}%
    \gdef\startlink##1{\begingroup{%
      \ifx\debuglabels\undefined\else\immediate\write16{link ##1 inserted}\fi
      \pdfstartlink attr{/Border [0 0 0]} goto name{##1}}\pdfliteral{\linkcolor}}%
    \gdef\endlink{\pdfliteral{0 0 0 rg}\pdfendlink\endgroup}%
}

% do we run pdftex?
\ifx\pdfdest\undefined
    \immediate\write16{Running TeX}
    % no: define dummy bookmarking functions
    \global\def\setbookmarkind#1#2{}
    \global\def\setbookmark#1#2{}
    \global\def\indexbookmark#1#2{}
    \nolinks
    \let\addlinks\relax
\else
    \def\linkcolor{0 0.1 0.6 rg}
    \immediate\write16{Running PDFTeX}
    % yes: define macros to do pdf stuff and set some parameters
    \global\def\setbookmarkind#1#2{%
      \setindent{\chapterlen{\the\chapno}}
      \pdfoutline goto name{#1} count -\indentno {#2}}
    \global\def\setbookmark#1#2{%
      \setindent{\chapterlen{\the\chapno}}
      \pdfoutline goto name{#1} count 0 {#2}}
    % special treatment for the index to get proper indentation
    \global\def\indexbookmark#1#2{%
      \pdfoutline goto name{#1} count -27 {#2}}
    \addlinks
    \pdfinfo{
    /Subject (GAP Manual)
    /Author (The GAP Group)
    }
    \pdfcatalog{
    /URI (https://www.gap-system.org)
%    /PageMode /UseOutlines}
    /PageMode /UseNone}
    \pdfcompresslevel 9
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Generic double column output.
%
%    Modified from a routine written by Donald Knuth (The TeXBook, App. E)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  The user may modify the following to his tastes:
%
%      \pagewidth     vertical length of page.
%      \pageheight    horizontal width of page.
%      \colwidth      column width
%      \separator     macro to generate column separator. Default is nothing.
%                     \rulesep sets it to \vrule. \norulesep doesn't.
%      \makepage      default is what is contained in plain.
% Create and initialize new dimensions.
\newdimen\pagewidth  \newdimen\pageheight  \newdimen\colwidth
\pagewidth=\hsize    \pageheight=\vsize    \colwidth=3.2truein

\def\draft{\hsize 42pc\vsize 63pc\pagewidth=\hsize \pageheight=\vsize}

\def\pif{\char39}

\def\tron{\tracingmacros 1\tracingcommands 1\tracingonline 1}

% This routine is used by \output ; this is different from
%   the one found in App. E.
\def\onepageout#1{{\setbox255=\vbox{#1}
  \hsize=\pagewidth \vsize=\pageheight \plainoutput}}
\def\normaloutput{\onepageout{\unvbox255}}
\maxdeadcycles=100 % \output is called quite often

\output={\normaloutput}
\newbox\partialpage \newdimen\origvsize \newif\ifrigid
\def\begindoublecolumns{\global\origvsize=\vsize \begingroup
  \output={\global\setbox\partialpage=\vbox{\unvbox255\kern0pt}}\eject
  \output={\doublecolumnout} \hsize=\colwidth \dimen@=\pageheight
  \advance\dimen@ by-\ht\partialpage \multiply\dimen@ by2
  \ifdim\dimen@<2\baselineskip \dimen@=2\baselineskip\fi
  \vsize=\dimen@}
\def\enddoublecolumns{\output={\balancecolumns}\eject
  \endgroup \global\vsize=\origvsize \pagegoal=\vsize}
\def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth
  \setbox0=\vsplit255 to.46\vsize \setbox2=\vsplit255 to.46\vsize
  %\setbox0=\vbox{A\unvbox0B\vfill}\setbox2=\vbox{C\unvbox2D\vfill}%
  \onepageout\pagesofar \global\vsize=2\pageheight
  \unvbox255 \penalty\outputpenalty}
\def\pagesofar{\unvbox\partialpage
  \wd0=\hsize \wd2=\hsize
  %\hbox to\pagewidth{\box0\hfil\separator\hfil\box2}}
  \hbox to\pagewidth{\valign{##\vfill\cr%
  \vbox{\unvbox0}\cr\noalign{\hfil\separator\hfil}\vbox{\unvbox2}\cr}}}
\def\norulesep{\let\separator=\relax}
\def\rulesep{\let\separator=\vrule}
\let\separator=\relax
\def\balancecolumns{\setbox0=\vbox{\unvbox255} \dimen@=\ht0
  \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
  \divide\dimen@ by2 \splittopskip=\topskip
  {\vbadness=10000 \loop \global\setbox3=\copy0
    \global\setbox1=\vsplit3 to\dimen@
    \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat}
  \ifrigid
    \setbox0=\vtop{\unvbox1}
    \setbox2=\vtop{\unvbox3}
  \else
    \setbox0=\vbox to\dimen@{\unvbox1}
    \setbox2=\vbox to\dimen@{\dimen2=\dp3 \unvbox3\kern-\dimen2 \vfil}
  \fi
  \global\vsize=\origvsize \pagesofar}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\colwidth 19pc
\newdimen\manindent      \manindent 3pc
\newdimen\smallmanindent \smallmanindent 1pc
\parskip 1ex plus 0.5ex minus 0.5ex
\parindent 0pt

\outer\def\usepsfonts{%
    % change standard TeX fonts, from plain.tex
    \font\tenrm=ptmr7t at 10pt % roman text
    \font\sevenrm=ptmr7t at 7pt
    \font\fiverm=ptmr7t at 5pt
    \font\tenr=zptmcm7t at 10pt % math roman
    \font\sevenr=zptmcm7t at 7pt
    \font\fiver=zptmcm7t at 5pt
    \font\teni=zptmcm7m at 10pt % math italic
    \font\seveni=zptmcm7m at 7pt
    \font\fivei=zptmcm7m at 5pt
    \font\tensy=zptmcm7y at 10pt % math symbols
    \font\sevensy=zptmcm7y at 7pt
    \font\fivesy=zptmcm7y at 5pt
    \font\tenex=zptmcm7v at 10pt % math extension
    \font\tenbf=ptmb7t at 10pt % boldface extended
    \font\sevenbf=ptmb7t at 7pt
    \font\fivebf=ptmb7t at 5pt
    % additional fonts needed by gapmacro.tex
    \font\tentt=cmtt10 % typewriter
    \font\tensl=ptmro7t at 10pt
    \font\tenit=ptmri7t at 10pt % text italic
    % Additional fonts needed by gapmacro.tex
    \font\inchhigh=phvb7t at 96pt
    \font\titlefont=phvb7t at 36pt
    \font\subtitlefont=phvb7t at 20pt
    \font\secfont=phvb7t at 13pt
    \font\sf=phvr7t at 10 pt
    \font\bsf=phvb7t at 10 pt
    \font\smallrom=ptmr7t at 8pt
    \font\sevenit=ptmri7t at 7pt
    \font\fiveit=ptmri7t at 5pt
    \inst@allfonts
}
\outer\def\usecmfonts{
    % standard TeX fonts, from plain.tex
    \font\tenrm=cmr10 % roman text
    \font\sevenrm=cmr7
    \font\fiverm=cmr5
    \font\tenr=cmr10 % math roman
    \font\sevenr=cmr7
    \font\fiver=cmr5
    \font\teni=cmmi10 % math italic
    \font\seveni=cmmi7
    \font\fivei=cmmi5
    \font\tensy=cmsy10 % math symbols
    \font\sevensy=cmsy7
    \font\fivesy=cmsy5
    \font\tenex=cmex10 % math extension
    \font\tenbf=cmbx10 % boldface extended
    \font\sevenbf=cmbx7
    \font\fivebf=cmbx5
    \font\tentt=cmtt10 % typewriter
    \font\tensl=cmsl10 % slanted roman
    \font\tenit=cmti10 % text italic
    % Additional fonts needed by gapmacro.tex
    \font\inchhigh=cminch
    \font\titlefont=cmssdc10 at 40pt
    \font\subtitlefont=cmssdc10 at 24pt
    \font\secfont=cmssdc10 at 14pt
    \font\sf=cmss10
    \font\bsf=cmssdc10
    \font\smallrom=cmr8
    \font\sevenit=cmti10 at 7pt
    \font\fiveit=cmti10 at 5pt
    \inst@allfonts
}

\def\inst@allfonts{
    \skewchar\teni='177 \skewchar\seveni='177 \skewchar\fivei='177
    \skewchar\tensy='60 \skewchar\sevensy='60 \skewchar\fivesy='60

    \textfont0=\tenr \scriptfont0=\sevenr \scriptscriptfont0=\fiver
    \textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei
    \textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
    \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
    \textfont\itfam=\tenit \scriptfont\itfam=\sevenit \scriptscriptfont\itfam=\fiveit
    \textfont\slfam=\tensl
    \textfont\bffam=\tenbf \scriptfont\bffam=\sevenbf
    \scriptscriptfont\bffam=\fivebf
    \textfont\ttfam=\tentt
    \tenrm
}
\def\rm{\fam0\tenrm}
\def\mit{\fam1} \def\oldstyle{\fam\@ne\teni}
\def\cal{\fam2}
% fam 3 contains the large symbols, cannot be used for ordinary math
\newfam\itfam \def\it{\fam\itfam\tenit} % \it is family 4
\newfam\slfam \def\sl{\fam\slfam\tensl} % \sl is family 5
\newfam\bffam \def\bf{\fam\bffam\tenbf} % \bf is family 6
\newfam\ttfam \def\tt{\fam\ttfam\tentt} % \tt is family 7

% If you don't have `msb' fonts, replace the next 4 lines by `\let\Bbb=\bf'.
\newfam\msbfam \def\Bbb{\fam\msbfam}
\font\tenmsb=msbm10         \textfont\msbfam=\tenmsb
\font\sevenmsb=msbm7        \scriptfont\msbfam=\sevenmsb
\font\fivemsb=msbm5         \scriptscriptfont\msbfam=\fivemsb
\font\sevenmsa=msam7

% the dark triangle
\def\darktriangleright{\raise.4ex\hbox{\sevenmsa\char"49}}

% Math mode should use text italic.
{\count0=\itfam \advance\count0 by-1 \multiply\count0 by"100
 \count1=`A
 \loop \count2=\mathcode\count1 \advance\count2 by\count0
       \global\mathcode\count1=\count2
      {\advance\count1 by'040
       \count2=\mathcode\count1 \advance\count2 by\count0
       \global\mathcode\count1=\count2}
 \ifnum\count1<`Z \advance\count1 by1\repeat}

\usepsfonts

% macros for verbatim scanning (almost copied from `The TeXbook')
\chardef\other=12
\def\undocatcodespecials{\catcode`\\=\other     \catcode`\{=\other
  \catcode`\}=\other     \catcode`\<=\other     \catcode`\$=\other
  \catcode`\%=\other     \catcode`\~=\other     \catcode`\^=\other
  \catcode`\_=\other     \catcode`\*=\other     \catcode`\`=\other
  \catcode`\!=\other     \catcode`\"=\other     \catcode`\&=\other
  \catcode`\#=\other     \catcode`\|=\other}
\newdimen\ttindent \ttindent=5mm % indentation amount of verbatim examples
\def\kernttindent{\hskip\ttindent\relax} % for use in %\begintt
{\obeyspaces\global\let =\ }
{\obeylines\gdef\obeylines{\catcode`^^M=\active}\gdef^^M{\par}%
\catcode`#=\active \catcode`&=6 \gdef#{\char35}%
%\catcode`#=\active \catcode`&=6 \gdef#&1^^M{\hbox{\char35 &1}^^M}%
 \gdef\ttverbatim{\begingroup\undocatcodespecials \catcode`\#=\active%
   \parindent 0pt \def\_^^M{\allowbreak}\def\${$}\def\`{`}%
   \def\par{\ifvmode\allowbreak\vskip 1pc plus 1pt\else\endgraf\penalty100\relax\fi}%
   \obeyspaces \obeylines \tt}}
\outer\def\begintt{\par
  \begingroup\advance\leftskip by \ttindent
  \ttverbatim \parskip=0pt \catcode`\|=0 \rightskip-5pc \ttfinish}
{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  |obeylines % end of line is active
  |gdef||{|char124} %
  |gdef|ttfinish^^M#1\endtt{|medskip{#1}|endgroup %
  |endgroup%
  |vskip-|parskip|medskip|noindent|ignorespaces}}
\def\unstableoutput{}
\outer\def\beginexample{\par
  \begingroup\advance\leftskip by \ttindent
  \ttverbatim \parskip=0pt \catcode`\|=0 \rightskip-5pc \catcode`\#=\other\examplefinish}
{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  |obeylines % end of line is active
  |gdef||{|char124} %
  |gdef|examplefinish^^M#1^^M\endexample{%
      |iftestexample%
         |ifexamplefileopen%
         |else|immediate|openout|exampleout=|jobname.example-|the|chapno.tst%
         |global|examplefileopentrue%
         |fi%
        {|def^^M{^^J}|immediate|write|exampleout{#1}}%
      |fi%
      |global|testexampletrue%
      |medskip{#1}|endgroup%
  |vskip-|parskip|medskip|endgroup%
  |noindent|ignorespaces}}

% Input/output streams. Chapter and section counters.
\newwrite\labelout \newwrite\indexout \newwrite\secindout
\newwrite\tocout   \newwrite\citeout  \newwrite\ans
\newwrite\exampleout
\newif\ifexamplefileopen
\newif\iftestexample\global\testexampletrue
\newread \labelin  \newread \indexin  \newread \tocin  \newread \citein
\countdef\chapno=1 \newcount\secno    \newcount\subsecno \newcount\exno
\newcount\indentno
\newcount\chapnum  %GG \chapnum is a numerical \chapno for the .six file
\def\chapterno{{\edef\tempa{\thechapter}\tempa}}
%\def\folio{\ifnum\pageno<0 \romannumeral-\pageno \else
%  \chapterno\ifx\thechapter\emptychapter\else--\fi \number\pageno\fi}
%\def\doindex#1#2#3{\write\indexout{\noexpand\indexentry{#1#2#3}%
%  {\ifnum\pageno<0 \romannumeral-\pageno \else
%   \thechapter\ifx\thechapter\emptychapter\else--\fi \number\pageno\fi}}%
%  \ifvmode\nobreak\fi}

%AH
\def\folio{\ifnum\pageno<0 \romannumeral-\pageno \else
  \number\pageno\fi}

%\def\doindex#1#2#3{\protectedwrite\indexout{\noexpand\indexentry{#1#2#3}%
%  {\ifnum\pageno<0\romannumeral-\pageno\else%
%   \number\pageno\fi}}%
%  \ifvmode\nobreak\else\unskip\fi}

{\catcode`<=\active \catcode`_=\active \catcode`!=\active \catcode`*=\active
\catcode``=\active

\global\let\n@exp\noexpand

\gdef\doindex#1#2#3{\begingroup
  %\let_\underscore\let`\lq\let<\<\let!\excl
  \def\noexpand{}% this kills noexpands from some index entries
  \def\protect{\n@exp\n@exp\n@exp}%
  \def_{\protect_}\def*{\protect*}\def`{\protect `}\def<{\protect <}\def!{\protect!}%
  \edef\tmp{\n@exp\n@exp\n@exp\indexentry{#1#2#3}}%
  \expandafter\write\expandafter\indexout\expandafter{\tmp{\folio}}%
  %{\scrollmode\errorcontextlines 1\show\tmp\errorstopmode}%
  \ifvmode\nobreak\else\unskip\fi\endgroup}%
}

% Additional active characters and their default meanings.
\mathcode`.="2201 \mathchardef\.="702E
\def\undoquotes{\catcode`'=12 \catcode``=12 \def\"##1{{\accent127 ##1}}}
\def\excl{!} \chardef\lqq=`\\ \let\underscore=\_
\chardef\<=`<
\catcode`!=\active \let!=\excl
\catcode`^=\active \def^{\ifmmode\sp\else{\char`\^}\fi}
\catcode`_=\active \def\activeusc{\ifmmode\sb\else\_\fi}
                   \let_=\activeusc                     \let\_=\underscore
\catcode`*=\active \def*{\ifmmode\let\next=\*\else\let\next=\bold\fi\next}
                   \def\bold#1*{{\bf #1\/}}             \chardef\*=`*
\catcode`<=\active \def<#1>{{\chardef*=`*\let_=\_\it#1\/}}

\catcode`"=\active \def"{\begingroup\undoquotes\doref}  \chardef\"=`"
                                                        \chardef\\=`\\

\def\refManual{{\GAP} Reference Manual}
\def\tutManual{{\GAP} Tutorial}

{\catcode`|=0 \catcode`\\=12 |gdef|bs{\}}
% Labels (which are automatically generated by ``\Section'' and ``\>'').
%\newif\iflabmultdef
\newif\iflabundef
\newif\iflabchanged
\newif\ifcasesensitive
\newif\ifcitebooks

\def\doref#1"{\bookref#1:"}
\def\bookref#1:#2"{\def\tempa{#2}\ifx\tempa\empty\printref{\book:#1}\else
  \printbookref#1:#2"\fi}
\def\printbookref#1:#2:"{\printref{#1:#2}}

% Macros which write labels, citations and index entries on auxiliary files.
%
% 1. Some code was moved around so that all the labels and indexing stuff
%    would be together.
% 2. Modified \makelabel, \printref and \label to be more like the LaTeX
%    commands \newlabel, \ref and \label, respectively. The commands:
%    \@xp, \@firstoftwo, \@secondoftwo, \namedef, \@ifundefined
%    \protectedwrite are adapted pieces of LaTeX code (\@xp is actually
%    AmSLaTeX's abbreviation of \expandafter).
% 3. The upshot of 2. is that now underscore is allowed in labels and
%    index-entries and that the \makelabel commands written to the
%    manual.lab files have arguments that are no longer put in lowercase.
%    The labels formed inside TeX from the \makelabel commands maps
%    underscores to | (needed to be a non-active character) and then
%    converts to lowercase.
% 4. Since GapDoc uses < and > in some of its labels a temporary re-defintion
%    of <#1> was necessary, inside \@xplowr.
% - GG 2001/06/11, 2001/09/02

\let\@xp\expandafter
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
\def\namedef#1{\expandafter\def\csname #1\endcsname}
\def\@ifundefined#1{\@xplowr{#1}%
  \@xp\ifx\csname \xpandlowr\endcsname\relax%
    \@xp\@firstoftwo%
  \else%
    \@xp\@secondoftwo%
  \fi}
\def\protectedwrite#1#2{\begingroup\let_\relax\immediate\write#1{#2}\endgroup}
\def\@xplowr#1{\begingroup\def_{|}\def<##1>{|##1|}\let\next=\relax%
  \expandafter\edef\next{\gdef\noexpand\xpandlowr{#1}}%
  \ifcasesensitive\next\else\lowercase\expandafter{\next}\fi\endgroup}
\def\m@kelabel#1#2#3{\@xplowr{r@#1}%
  \@ifundefined{\xpandlowr}%
    \relax%
    {\let_\activeusc}%\protectedwrite{16}{Label `#1' multiply defined.}}%
  \let_\activeusc%\protectedwrite{16}{Defined label `#1'.}%
  \begingroup\edef_{|}\global\namedef{\xpandlowr}{#2}\endgroup}
\let\makelabel\undefined
\gdef\printref#1{\@xplowr{#1}%
  \@xp\ifx\csname r@\xpandlowr\endcsname\relax\lqq\xpandlowr''%
  \protectedwrite{16}{Label `#1' undefined.}\global\labundeftrue%
  \else\expandafter\printpdflink\xpandlowr\relax\fi\endgroup\let_\activeusc}
\gdef\printpdflink#1:#2\relax{\edef\next{#1}\ifx\next\book
       \startlink{#2}\csname r@\xpandlowr\endcsname\endlink\else
       \ifcitebooks\expandafter\csname\next Manual\endcsname,\space\fi
       \csname r@\xpandlowr\endcsname\fi}

\newif\ifnewlab

% Macros which write labels, citations and index entries on auxiliary files.
\gdef\label#1{\@xplowr{#1}%
  \ifnum\secno=0 \edef\@currentlabel{\thechapter}\else
  \ifnum\subsecno=0 \edef\@currentlabel{\thechapter.\the\secno}\else
  \edef\@currentlabel{\thechapter.\the\secno.\the\subsecno}\fi\fi
  \@xp\ifx\csname r@\book:\xpandlowr\endcsname\@currentlabel\else%
  \immediate\write16{Label `\book:#1' has changed.}%
  \global\labchangedtrue\fi%
  \expandafter\ifx\csname pdfdest@\xpandlowr\endcsname\relax
  \nameddest{\xpandlowr}%
  \expandafter\gdef\csname pdfdest@\xpandlowr\endcsname{#1}%
  \fi%
  \ifnewlab\def\next{{\xpandlowr}}%
  \else
  \def\next{}%
  \fi
  \protectedwrite\labelout{\string\makelabel{\book:#1}{\@currentlabel}\next}%
  \let_\activeusc}

\def\litem#1{% left aligned item
 \par\hang\noindent\hbox to \parindent{#1\enspace\hfill}}

\newif\ifbiblitem

 \gdef\sigel#1{[\expandafter\ifx\csname c@#1\endcsname\relax
  \immediate\write16{Reference `#1' undefined.}\global\labundeftrue
  #1\else \csname c@#1\endcsname\fi]}
 \gdef\bibitem[#1]#2{\expandafter\gdef\csname c@#2\endcsname{#1}%
  \nameddest{citation@#2}\ifbiblitem\litem{\sigel{#2}}\else\item{\sigel{#2}}\fi
  \immediate\write\labelout{\noexpand\setcitlab{#2}\noexpand{#1}}\ignorespaces}
 \gdef\setcitlab#1#2{\expandafter\gdef\csname c@#1\endcsname{#2}}

\def\cite#1{\write\citeout{\bs citation{#1}}\startlink{citation@#1}\sigel{#1}\endlink}
\def\dosecindex#1#2#3{\ifchapter{\let\ =\space%
   \protectedwrite\secindout{#1 \the\chapno.\the\secno. #2#3}}\fi}
\def\bothindex#1#2#3#4{\doindex{#2}{#3}{#4}\dosecindex{#1}{#2}{#4}}
\def\index#1{\bothindex I{#1}{}{}}
\def\atindex#1#2{\doindex{\scrubafterexcl#1!\end}{#2}{}\dosecindex I{#1}{}}
{\catcode64=12
\gdef\indextt#1{\doindex{\scrubafterexcl#1!\end}%
   {@`\scrubafterexcl#1!\end'\scrubbeforeexcl#1!\end}{}\dosecindex I{#1}{}}
}
%\def\indextt#1{\atindex{#1}{@`#1'}}
\def\indexit#1{{\it #1}}

% Macros for generating the table of contents.
\newif\iffirstsec \firstsectrue
\def\dotsfill{\leaders\hbox to12pt{\hss.\hss}\hfill}

\def\appcontents#1#2#3{}

\def\chapcontents#1#2#3{%
   %\iffirstsec\firstsecfalse\else\line{}\fi% empty line
   \par\penalty-5\medskip
   \line{\@xplowr{#2}\startlink{\xpandlowr}\bf\kern\manindent\vbox{\advance\hsize by-\manindent
   \advance\hsize by-1.5em
   \rightskip 0pt plus1fil \emergencystretch 3em
   \noindent\llap{\hbox to\manindent{\hss #1\kern\smallmanindent}}\strut
   #2~\hfill \strut\rlap{\hbox to1.5em{\hss #3}}}\hfil\endlink}}

\def\seccontents#1#2#3{
   \par\penalty-5\medskip
   \setchapterlen#1.
   \line{\@xplowr{#2}\startlink{\xpandlowr}\kern\manindent\vbox{\advance\hsize by-\manindent
   \advance\hsize by-1.5em
   \rightskip 0pt plus1fil \emergencystretch 3em
   \noindent\llap{\hbox to\manindent{\hss #1\kern\smallmanindent}}\strut
   #2~\dotsfill \strut\rlap{\hbox to1.5em{\hss #3}}}\hfil\endlink}}

% GG ... the idea of \ors is to put the right no. of \or s in the \appno
%        macro so that for an appendix:
%         1. \the\chapno gives the number needed in the .six file, and
%         2. \appno\chapno gives the right letter A, B, ... for the .lab file
\newtoks\ortoks
\long\def\addor{\begingroup\ortoks\expandafter{\ors\or}
   \xdef\ors{\the\ortoks}\endgroup}
\def\setors{{\xdef\ors{} \count0=\chapno
   \loop\ifnum\count0>0 \addor \advance\count0 by -1\repeat}}
\def\appno#1{\expandafter\ifcase\expandafter#1\ors\or A\or B\or C\or D\or E\or
   F\or G\or H\or I\or J\or K\or L\or M\or N\or O\or P\or Q\or R\or S\or T\or
   U\or V\or W\or X\or Y\or Z\else\immediate\write16{Counter too large} \fi}

% Macros for chapter and section headings.
\def\filename{appendix}
\def\tocstrut{{\setbox0=\hbox{1}\vrule width 0pt height\ht0}}
\outer\def\Input#1{\def\filename{#1.tex}\input #1}
\def\emptychapter{\noexpand\tocstrut}
\def\normalchapter{\the\chapno}
% GG
\def\appendixchapter{\appno\chapno} % \appno behaves like LaTeX's \Alph
\newif\ifchapter           % set to true when \thechapter = \normalchapter
                           % ... or ...  when \thechapter = \appendixchapter

{
%
\gdef\setchapterlen#1.#2.{\expandafter\gdef\csname ch@#1\endcsname{#2}}
\gdef\chapterlen#1{%
\ifchapter
\expandafter\ifx\csname ch@#1\endcsname\relax%
0%
\else\csname ch@#1\endcsname\fi
\else 0\fi}%
}
\def\setindent#1{\indentno=#1}

\outer\def\Chapter#1 \par{\doChapter{#1}{}}

\def\doChapter#1#2{\vfill\supereject \headlinefalse
%  \ifodd\pageno\else\null\vfill\eject\headlinefalse\fi
  \ifexamplefileopen\immediate\closeout\exampleout\examplefileopenfalse\fi
  \advance\chapno by1 \secno=0\subsecno=0\exno=0%\ifnum\pageno>0 \pageno=1 \fi
  \def\chapname{#1#2}\label{#1}\ifx\relax#2\relax\else\label{#1#2}\fi%
  \immediate\write16{Chapter `#1' .}%
  \write\tocout{\noexpand\chapcontents{\thechapter}{#1#2}{\the\pageno}}%
  \ifchapter
    \immediate\write\secindout{C \filename\space\the\chapno. \chapname}\fi
  \@xplowr{#1}\setbookmarkind{\xpandlowr}{#1#2}%
  \setbox0=\hbox{\inchhigh\kern-.075em \chapterno}%
  \setbox1=\vbox{\titlefont \advance\hsize by-\wd0 \advance\hsize by-1em
%    \hyphenpenalty=10000 \linepenalty=10000
    \leftskip 0pt plus\hsize \parfillskip 0pt \baselineskip 44pt\relax #1#2}%
  \line{\box0\hfil\box1}\nobreak \mark{}\vskip 40pt}

% start hack added by TB
\outer\def\PreliminaryChapter#1 \par{\doChapter{#1}{ (preliminary)}}

\outer\def\Section#1#2\par{\bigbreak \advance\secno by1
  \subsecno=0
  \ifx\thechapter\emptychapter
    \edef\tempa{\the\secno}
  \else
    \edef\tempa{\thechapter.\the\secno}%
  \fi%
  \@xplowr{#1}\setbookmark{\xpandlowr}{#1}
  \expandafter\writesecline\tempa\\{#1}
  \dosecindex S{#1}{}
  \ifx#2\nolabel\nameddest{\xpandlowr}\else{\let\ =\space\label{#1}}\fi
  \ifx#2\null\else \edef\tempb{{#1@#1}}
    \expandafter\doindex\tempb{|indexit}{}\fi
  \noindent{\baselineskip 18pt\let!=\space \mark{Section \the\secno. #1}%
  \secfont \tempa \enspace #1}\par\nobreak\medskip}

\def\writesecline#1\\#2{\write\tocout{\noexpand\seccontents{#1}{#2}
  {\the\pageno}}}
\def\letter#1{%
  \edef\tempa{LeTtEr#1}%
  \nameddest{\tempa}%
  \setbookmark{\tempa}{#1}%
  \medskip{\secfont #1}\endgraf\nobreak}

% Macros for generating paragraph headings (e.g., function descriptions).
\def\fmark{\noindent\llap{\darktriangleright\rm\enspace}}
\def\moveup#1{\leavevmode \raise.16ex\hbox{\rm #1}}
\def\fpar{\endgraf\endgroup\nobreak\smallskip\noindent\ignorespaces}
\def\>{\begingroup\undoquotes\obeylines\angle}
\def\){\begingroup\obeylines\cloparen}
{\obeylines\catcode64=12
\gdef\angle#1
  {\endgroup \ifx\par\fpar \global\def\susemarker{\fmark}\else%
  \global\advance\subsecno by1%
  \global\def\susemarker{\noindent\llap{\smallrom\the\subsecno\kern.5ex%
  \darktriangleright\rm\enspace}}%
    \ifvmode \vskip -\lastskip \fi \medskip%
    \begingroup\let\par=\fpar \parskip 0pt \fi%
  \endgraf\nobreak\oporfunc#1\end}%
\gdef\cloparen#1
  {\endgroup \ifx\par\fpar \else%
    \ifvmode \vskip -\lastskip \fi \medskip%
    \begingroup\let\par=\fpar \parskip 0pt \fi%
  \endgraf{\def\[{\moveup\lbrack}\def\]{\moveup\rbrack}\def\|{\vrule\relax}%
  \noindent\typewriter#1'}}%
\gdef\scanparen#1(#2\end{\def\tempa{#2}\ifx\tempa\empty%
  \def\next{\begingroup\cloparen\susemarker#1%
  \label{#1}\bothindex F{#1}{@`#1'}{}}%
  \else\def\next{\delparen#1(#2\end}\fi \next}%
\gdef\delparen#1(\end{\function#1}%
\gdef\oporfunc#1#2\end{\ifx#1`\def\next{\oporvalue#1#2}\else%
                             \def\next{\scanparen#1#2(\end}\fi \next}%
\long\gdef\oporvalue`#1'#2{\ifx#2V\def\next{\operation`#1'{#1}@{`#1'} V}\else%
                                 \def\next{\operation`#1'{#2}}\fi \next}%
\long\gdef\operation`#1'#2#3{{\def\[{\moveup\lbrack}\def\]{\moveup\rbrack}%
  \def\|{\vrule\relax}}%
  \susemarker\typewriter#1'%
  \ifx#3!\def\next{\suboperation{#2}}%
    \else\ifx#3@\def\next{\subatoperation{#2}}%
    \else\endheaderline \label{#2}%
    \bothindex F{#2}{}{}\let\next=#3\fi\fi\next}%
\long\gdef\function#1(#2)#3{{\def\[{\moveup\lbrack}\def\]{\moveup\rbrack}%
  \def\|{\vrule\relax}%
  \susemarker\typewriter#1(#2)'}%
  \ifx#3!\def\next{\subfunction{#1}}\else%
    \endheaderline\label{#1}\bothindex F{#1}{@`#1'}{}%
    \let\next=#3\fi\next}%
\gdef\subfunction#1#2{\endheaderline\label{#1!#2}%
  \bothindex F{#1}{@`#1'}{!#2}}%
\gdef\suboperation#1#2{\endheaderline\label{#1!#2}%
  \bothindex F{#1}{}{!#2}}%
\gdef\subatoperation#1#2{\endheaderline\label{#1}%
  \doindex{\scrubafterexcl#1!\end}{@#2}{}%
  \dosecindex F{#1}{}}%
\gdef\scrubafterexcl#1!#2\end{#1}%
\gdef\scrubbeforeexcl#1!#2\end{\if\relax#2\else!\removeendexcl#2\fi}%
\gdef\removeendexcl#1!{#1}%
\gdef\endheaderline{\hskip 0pt plus 1filll}%
}

% Macro for item lists.
\catcode`&=\active
\def\beginitems{%
  \smallskip
  \begingroup
    \advance\ttindent\manindent
    \def&{\par \nobreak \hangindent\manindent \hangafter 0
      {\parskip 0pt\noindent}\ignorespaces}
    \parindent 0pt
    \catcode`&=\active
}
\def\enditems{\par \endgroup \smallskip \noindent \ignorespaces}

% Macro for item lists.
\def\beginlist{%
  \smallskip
  \begingroup
    \parindent=2em
}
\def\endlist{\par \endgroup \smallskip \noindent \ignorespaces}
\catcode`&=4

% Macros for exercises.
\outer\def\exercise{\advance\exno by1\begingroup
  \def\par{\endgraf\endgroup\medskip\noindent}
  \medskip\noindent{\bf Exercise \chapterno.\the\exno.}\quad}
\outer\def\answer{\immediate\write\ans{}%
  \immediate\write\ans{\noexpand\answerto{\thechapter.\the\exno.}}%
  \copytoblankline}
\def\answerto#1{{\noindent\bf #1}}
\def\copytoblankline{\begingroup\setupcopy\copyans}
{\undoquotes
\gdef\setupcopy{\undocatcodespecials \obeylines \obeyspaces}
\obeylines \gdef\copyans#1
  {\def\next{#1}%
  \ifx\next\empty\let\next=\endgroup %
  \else\immediate\write\ans{\next}\let\next=\copyans\fi\next}}

% Macros for the active backquote character (`).
{\catcode`.=\active \gdef.{\char'056 \penalty0}}
\def\writetyper{\catcode`.=\active \chardef\{ =`{ \chardef\}=`}
                      \chardef*=`* \chardef"=`"   \chardef~=`~}
\catcode``=\active
\def`{\futurelet\next\backquote}
\def\typewriter#1'{\leavevmode{\writetyper \chardef`=96 \tt #1}}
\def\backquote{\ifx\next`\let\next=\doublebackquote
                    \else\let\next=\typewriter \fi \next}
\def\doublebackquote`{\lqq}

% The \Package command for argument <pkg> defines a macro \<pkg> that
% sets the text <pkg> in sans-serif i.e. a share package author should
% put a \Package{<pkg>} in their manual.tex file and then use {\<pkg>}
% when they refer to package <pkg>.

\def\Package#1{\namedef{#1}{{\sf #1}}}
\Package{GAP}
\Package{MOC}
\Package{ATLAS}

% For one-off references to a share package there is the following:

\def\package#1{{\sf #1}}

% The day

\def\Day{\number\day}

% The month in words

\def\Month{\ifcase\month\or January\or February\or March\or April\or May\or
  June\or July\or August\or September\or October\or November\or December\fi}

% The year

\def\Year{\number\year}

% The date

\def\Today{{\Day} {\Month} {\Year}}

% Miscellaneous macros.
\def\N{{\Bbb N}} \def\Z{{\Bbb Z}} \def\Q{{\Bbb Q}} \def\R{{\Bbb R}}
\def\C{{\Bbb C}} \def\F{{\Bbb F}} \def\calR{{\cal R}}

%T do we want these
%\def\stars{\bigskip\centerline{\*\qquad\*\qquad\*}\bigskip}

% Page numbers and running heads.
\newif\ifheadline
\nopagenumbers
\def\makeheadline{\vbox to0pt{\vskip-22.5pt\hbox to\pagewidth{\vbox to8.5pt
  {}\the\headline}\vss}\nointerlineskip}
\headline={\ifheadline\ifodd\pageno \righthead\hfil{\rm\folio}\else
                                    {\rm\folio}\hfil\lefthead \fi
  \else\global\headlinetrue \hfil\fi}

% Macro for inputting an auxiliary file.
\def\inputaux#1#2{\immediate\openin#1=#2
  \ifeof#1\immediate\write16{No file #2.}\else
  \immediate\closein#1 \input#2\fi}

% Macros for the parts of the manual.
\outer\def\FrontMatter{%
  \let\thechapter=\emptychapter
  \def\lefthead{\it\chapname} \let\righthead=\lefthead

  \begingroup
  \def\makelabel##1##2{\m@kelabel{##1}{##2}{}}%
  \undoquotes
  \inputaux\labelin{\jobname.lab}
  %\setbox0=\vbox{\Bibliography}
  \endgroup
  \labchangedfalse

  % Open the auxiliary files for output.
  \immediate\openout\tocout   =\jobname.toc
  \immediate\openout\labelout =\jobname.lab
  \immediate\openout\indexout =\jobname.idx
  \immediate\openout\secindout=\jobname.six
  \immediate\openout\citeout  =\jobname.aux
%  \immediate\openout\ans=answers
  \immediate\write\citeout{\bs bibstyle{alpha}}

  \ifodd\pageno\else\headlinefalse\null\vfill\eject\fi
%  \pageno=1
}

\outer\def\Chapters{\vfill\eject
  \chapno=0 \let\thechapter=\normalchapter \chaptertrue
  \def\lefthead{{\it Chapter \the\chapno. \chapname}}
  \def\righthead{\ifx\botmark\empty\lefthead\else{\it \botmark}\fi}}

% GG
% Rather than reset \chapno in \Appendices, for the .six file (which GAP's
% help uses), we number appendices as if they were chapters (via \the\chapno)
% i.e. if the last chapter was numbered 7 then for the .six file the first
% appendix would be numbered 8.
% The \setors macro puts (\number\chapno - 1) \or s in the \ors macro so that
% \appno\chapno (= \appendixchapter) numbers the appendices sequentially from A
% for the .lab file (which TeX uses).
\outer\def\Appendices{\vfill\eject
  \ifexamplefileopen\immediate\closeout\exampleout\examplefileopenfalse\fi
  \setors \let\thechapter=\appendixchapter \chaptertrue
  \def\lefthead{{\it Appendix \thechapter. \chapname}}
  \def\righthead{\ifx\botmark\empty\lefthead\else{\it \botmark}\fi}}

\def\EndMatter{\vfill\eject
  \def\thechapter{} \chapterfalse
  \def\lefthead{{\it \chapname}}
  \let\righthead=\lefthead
  \hbadness=5000\relax
  \gdef\EndMatter{}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \BeginningOfBook  . . . . . . . . . . . . . . . . . . . .  start the book
%%
\outer\def\BeginningOfBook#1{%
  \def\book{#1}%
  \pageno=-1%
  \pageno=1%
  \headlinefalse%
  \let\thechapter=\emptychapter%
  \def\lefthead{\it\chapname}%
  \let\righthead=\lefthead%
}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \UseReferences{<book-path>}	. . . use references from book in <book-path>
%%

%% /usr/share/gap/pkg/GAPDoc/doc/:
%% Added by Bill Allombert to absorb ../../.. from caller. Any pkg/*/* would do.

\outer\def\UseReferences#1{\begingroup\def\makelabel##1##2{\m@kelabel{##1}{##2}{}}\undoquotes
    \inputaux\labelin{/usr/share/gap/pkg/GAPDoc/doc/#1/manual.lab}\endgroup
}
\outer\def\UseGapDocReferences#1{\begingroup\def\makelabel##1##2##3{\m@kelabel{##1}{##2}{##3}}\undoquotes
    \inputaux\labelin{/usr/share/gap/pkg/GAPDoc/doc/#1/manual.lab}\endgroup
}
\outer\def\GAPDocLabFile#1{\def\makelabel##1##2##3{\m@kelabel{##1}{##2}{##3}}}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \EndOfBook	. . . . . . . . . . . . . . . . . . . . . . . .  end the book
%%
\outer\def\EndOfBook{\vfill\supereject
  \immediate\write16{##}
  \immediate\closeout\citeout
  \immediate\write16{## Citations for BibTeX written on \jobname.aux.}
  \immediate\closeout\indexout
  \immediate\write16{## Index entries for makeindex written on \jobname.idx.}
  \immediate\closeout\secindout
  \immediate\write16{## Section index entries written on \jobname.six.}
  \immediate\closeout\labelout
  \immediate\write16{## Label definitions written on \jobname.lab.}
  \immediate\closeout\tocout
  \immediate\write16{## Table of contents written on \jobname.toc.}
  \immediate\write16{## Examples written to \jobname.example-XX.tst.}
  %\iflabmultdef\immediate\write16{## There were multiply-defined labels.}\fi
  \iflabundef\immediate\write16{## There were undefined labels or
  references.}\fi
  \iflabchanged\immediate\write16{## Labels have changed, run again. (Or
  they were multiply defined.)}\fi
  \immediate\write16{##}
  \end
}
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \TableOfContents  . . . . . . . . . . . . . . produce a table of contents
%%
% name of the chapter containing the table of contents
\def\TOCHeader{Contents}

% explanation at the beginning of the table of contents
\def\TOCMatter{%
}

% macros for generating the table of contents
%\newif\iffirstsec\firstsectrue
\def\dotsfill{\leaders\hbox to12pt{\hss.\hss}\hfill}

% produce the chapter "Contents"
\outer\def\TableOfContents{\doChapter\TOCHeader{}%
\TOCMatter
\vskip 20pt
\begingroup
\rigidfalse
\let!=\space
\begindoublecolumns
\inputaux\tocin{\jobname.toc}\vfill\eject
\enddoublecolumns
\endgroup
}

% a one column version of \TableOfContents for short manuals
\outer\def\OneColumnTableOfContents{\doChapter\TOCHeader{}%
\TOCMatter
\vskip 20pt
\begingroup
\rigidfalse
\let!=\space
\inputaux\tocin{\jobname.toc}\vfill\eject
\endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \TitlePage{<text>}	. . . . . . . . . . . . . . . . generate a title page
%%
\outer\long\def\TitlePage#1{%
  \null\vfill#1\null\vfill\eject
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \Colophon{<text>}	. . . . . . . . . . . . . . generate a colophon page
%%
\outer\long\def\Colophon#1{\doChapter{}{}%
#1\null\vfill\eject
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \Answers  . . . . . . . . . . . . .  produce the answers to the exercises
%%
% header for the answers
\def\AnswersHeader{Answers to the Exercises}
%
% produce the chapter "Answers"
\outer\def\Answers{\doChapter\AnswersHeader{}%
  \parindent\manindent
  \parskip 1ex plus 0.5ex minus 0.5ex
  \immediate\closeout\ans
  \input answers
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \Bibliography . . . . . . . . . . . .  produce the chapter "Bibliography"
%%
% header for the bibliography
\def\BibHeader{Bibliography}
\newdimen\bibindent \bibindent=\manindent

% produce the chapter bibliography
\outer\def\Bibliography{\EndMatter\doChapter\BibHeader{}%
  \begingroup\undoquotes\frenchspacing
  \parindent\bibindent
  \pretolerance=5000 %badness allowed for hypenation
  \tolerance=5000    %badness allowed before overfull boxes appear
  \parskip 1ex plus 0.5ex minus 0.5ex
  \def\begin##1##2{} \def\end##1{}
  \let\newblock=\relax \let\em=\sl
  \inputaux\citein{\jobname.bbl}
  \endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%F  \Index  . . . . . . . . . . . . . . . . . .   produce the chapter "Index"
%%
% header for the index
\def\IndexHeader{Index}

% explanation at the beginning of the index
\def\IndexMatter{%
This index covers only this manual.
A page number in {\it italics} refers to a whole section which is devoted to
the indexed subject.  Keywords are sorted with case and spaces ignored,
e.g., ```PermutationCharacter''' comes before ``permutation group''.%
}

% kerning in full index after letter
\def\idxkern{\kern.3em}

% produce the chapter index
\outer\def\Index{\EndMatter%
  % get the proper bookmarking function
  \global\let\setbookmarkind=\indexbookmark%
  \doChapter\IndexHeader{}%
  \IndexMatter
  \bigskip
  \begindoublecolumns
  \pretolerance=5000 %badness allowed for hypenation
  \tolerance=5000    %badness allowed before overfull boxes appear
  \parindent 0pt \parskip 0pt \rightskip 0pt plus2em \emergencystretch 2em
  \everypar{\hangindent\smallmanindent}
  \def\par{\endgraf\leftskip 0pt}
  \def\sub{\advance\leftskip by\smallmanindent}
  \def\subsub{\advance\leftskip by2\smallmanindent}
  \obeylines
  \inputaux\indexin{\jobname.ind}
  \enddoublecolumns
}

% pseudo chapters used for authors, preface, copyright &c.
\def\PseudoInput#1#2#3{%
\vfill\eject% to ensure the pseudo-chapter no. doesn't get into headline
\advance\chapno by1\secno=0\subsecno=0
\immediate\write\secindout{C #1.tex \thechapter. #2}
\label{#2}\label{#3}} % we do this for the benefit of the HTML manuals

% some often-used LaTeX functions
\def\frac#1#2{{{#1}\over{#2}}}

% as the etalchar gets written out in manual.lab, better make it nonfancy
% (otherwise something breaks).
\def\etalchar#1{$^{#1}$}
\def\etalchar#1{#1}

% nasty trick to cope with the `newcommand' created by bibtex
\def\newcommand#1#2#3#4#5{}

% URL stuff
\def\URL#1{\par\kernttindent\hbox{`#1'}\ifx\EndMatter\empty\else\qquad\fi}
\def\Mailto#1{\penalty-1000\hskip 0pt plus10cm\hbox{`#1'}}

% ragged bottom will avoid large blank spaces
\raggedbottom
\frenchspacing
\vfuzz=2pt

\catcode64=12% catcode of @
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%E
%%