-
Notifications
You must be signed in to change notification settings - Fork 8
/
macros.tex
2533 lines (2188 loc) · 67 KB
/
macros.tex
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
% -*- coding: utf-8 -*-
% This is part of the book TeX for the Impatient.
% Copyright (C) 2003 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry.
% See file fdl.tex for copying conditions.
%
% Macros for typesetting TeX for the Impatient.
%
% These macros are being distributed without any warranty whatsoever.
% The level of commentary is that which we, the authors, found necessary
% for our own purposes.
%
% ==========================================================================
%
% The macros use the term `chapter' for what in the book is called
% a `section', `section' for the book's `subsection', etc. For purposes of
% defining macros it's convenient to think of the book as divided into
% chapters, but because of the nonsequential nature of the book we don't
% want to tell the readers that they are reading chapters.
% An embedded file should end with \byebye.
%
\begingroup
\ifx \macsin\relax
% In frontm.tex, we do \input macros several times, and we still want
% the \byebye at the end to end the job.
% So we \input inside a group in frontm, and make the assignment to
% \endinput local.
\aftergroup\let\aftergroup\byebye\aftergroup\endinput
\aftergroup\endinput % Don't read this file again.
\else
\global\let\byebye = \end
\global\let\macsin = \relax
\fi
\endgroup
% This must come before config.tex.
\input eplain3
% Define configuration switches and then read their values.
%
\newif\ifcenterpage \centerpagetrue
\newif\ifcompletebook
\newif\iffinal % true for the 2000dpi copy
\newif\ifmsdos
\newif\ifedgetabs \edgetabstrue
\newif\ifdvi \dvitrue % true if we want a .dvi file
\newif\iftrimpage \trimpagetrue
%\xrefwarningfalse
% The config file contains settings for flags, e.g.,
% \completebookfalse
% It can be empty as long as it exists.
\input config
\ifcompletebook \else\rewritetocfilefalse \fi
\edef\tempfile{\ifmsdos g:temp \else x \fi}
\ifx\setmodes\undefined\else\setmodes\fi % modify from command line input
% Certain defaults are forced by certain others.
%
\iffinal \centerpagetrue \edgetabstrue\fi
% Initial definitions. (These should come before \input fonts.)
%
\catcode`\@ = \letter % For the macro file only.
% Some hacks for eplain 2.0+
\let\oldxrdef = \xrdef
\def\xrdef#1{\oldxrdef{\tokstostring{#1}}}%
\let\oldxrefn = \xrefn
\def\xrefn#1{\oldxrefn{\tokstostring{#1}}}%
\let\old@definelabel = \@definelabel
\def\@definelabel#1{\old@definelabel{\tokstostring{#1}}}
\def\LaTeX{L\kern -.26em \raise .6ex \hbox{\sevenrm A}\kern -.15em \TeX}%
% setup hyperlinks
\ifpdf
\enablehyperlinks[pdftex]
\else
\enablehyperlinks[dvipdfm]
\fi
%% may cause an error with xetex.def before version v4.03
%% please see http://tex.stackexchange.com/q/191489/8956
\beginpackages\usepackage{color}\endpackages
\definecolor{teal}{rgb}{0,0.5,0.5}
\hlopts{colormodel=,color=teal}
\hlopts{bwidth=0}
% We don't want register allocation information in the log,
% so we redefine the relevant macro from plain.tex.
\def\alloc@#1#2#3#4#5{\global\advance\count1#1 by 1
\ch@ck#1#4#2%
\allocationnumber=\count1#1 \global#3#5=\allocationnumber
}
% The fonts. This should come before defining the new character control
% sequences that follow.
%
\input fonts
\hyphenation{script-script base-line-skip no-base-line-skip line-skip
line-skip-limit max-dead-cycles output-penalty no-inter-line-skip
show-box-depth show-box-breadth if-hmode if-vmode if-mmode
back-spaces back-space par-indent tracing-on-line}
{
\catcode`\| = 0
\catcode`\\ = \other
|global|let|bsc = \ % \bsc is a true backslash character.
}
\let\\ = \bsc
\def\bslash{$\backslash$} % backslash suitable for printing
\let\shriek = !
\let\vbar = |
{
\catcode `\[ = 1 \catcode `\] = 2
\catcode `\{ = \other \catcode `\} = \other
\global\let\lbracechar = {
\global\let\rbracechar = }
]
\def\blbrace{{\bt \{}}
\def\brbrace{{\bt \}}}
{
\catcode`\ =\other% Notice no spaces at beginning of next line.
\gdef\otherspace{ }
}
\let\mathlbrace = \{ \let\mathrbrace = \}
{
\catcode `\[ = 1 \catcode `\] = 2
\catcode `\{ = \other \catcode `\} = \other
\gdef\{[\ifmmode\mathlbrace\else [\bt {]\fi]
\gdef\}[\ifmmode\mathrbrace\else [\bt }]\fi]
]
% These are for debugging (less drastically than \tracingall or \loggingall).
%
\def\tron{\tracingmacros=2 \tracingcommands=2 \tracingonline=1}
\def\troff{\tracingmacros=0 \tracingcommands=0}
% \pagebreak should always cause a break, even if the resulting
% page is empty.
%
\def\pagebreak{\null\vfill\eject}
% \linebreak causes a line break in chapter headings, but outside of that
% context we don't want it to do anything.
%
\let\linebreak = \relax
% Parameters.
%
\baselineskip = 14pt
\parskip = 0pt plus 0.3pt
\newdimen\codefuzz \codefuzz = 10pt % for \csdisplay, \example
\hbadness = 4000
\vbadness = 8000
\hfuzz = 0.1pt % as in plain TeX
\vfuzz = 0.1pt % as in plain TeX
\exhyphenpenalty = 0 % we don't mind these
\widowpenalty = 10000 % these are very bad
\clubpenalty = 10000 % these are very bad too
% Page margins.
%
% Note that the \newdimens can't be within an \if or a \def
% because \newdimen is an \outer macro (thanks to DEK).
%
\newdimen\insidemargin \newdimen\outsidemargin
\newdimen\topmargin \newdimen\bottommargin
\newdimen\headmargin
\newdimen\totalwidth \newdimen\totalheight
\newdimen\oddoffset \newdimen\evenoffset
\newif\ifnoheadline
% \totalwidth and \totalheight are the actual trim size of the book.
% \insidemargin, \outsidemargin, \topmargin, and \bottommargin are margins
% with respect to the pages of the book, not the draft 8 1/2 x 11 pages.
%
% This makes it so that we only have to cut twice on a page.
% 8.5" = 51.19125pc exactly.
% \totalwidth should = \outsidemargin + \insidemargin + \hsize.
%
\totalwidth = 7.375in % 44.4159375pc = 7 3/8".
\outsidemargin = 8pc
\insidemargin = 10pc
\hsize = \totalwidth
\advance \hsize by -\outsidemargin
\advance \hsize by -\insidemargin
% \hsize should now be 26.4159375pc
% Now that we know \hsize, we can set \parfillskip to eliminate (most)
% widows.
%
\parfillskip = .75\hsize plus .06\hsize minus .75\hsize
% \oddoffset and \evenoffset are the \hoffset values needed to
% align the left edge of the virtual page with the left edge of the
% draft paper (not the left edge of the book pages).
%
% The -1in below comes from the default margin, which the DVI driver must
% set at 1in. Odd pages are on the left, even on the right.
%
% First, align the left edge of the virtual page with the left edge of the
% draft page.
%
\oddoffset = -1in
\advance\oddoffset by \insidemargin
%
\evenoffset = -1in
\advance\evenoffset by \outsidemargin
% For centered pages, move the virtual page right by half the trim width.
%
\ifcenterpage
\dimen0 = 8.5in
\advance\dimen0 by -\totalwidth
\divide\dimen0 by 2
\advance\oddoffset by \dimen0
\advance\evenoffset by \dimen0
% For uncentered even-numbered pages, align the right edge of the virtual
% page with the right edge of the draft paper so that we can remove the trim
% of two-sided pages with a single cut.
%
\else
\advance\evenoffset by 8.5in
\advance\evenoffset by -\totalwidth
\fi
\hoffset = \oddoffset % First page is numbered one.
% Now for the vertical, which is simpler, since it doesn't vary from
% page to page.
% 11" = 66.2475pc exactly.
% \totalheight should = \topmargin + \bottommargin + \vsize.
%
\totalheight = 9.25in % 9 1/4" = 55.708125pc
\topmargin = 6pc % Distance from top of page to baseline of text line 1
\bottommargin = 6pc % Distance from last line to bottom of page.
\topskip = 2pc % Distance from top of \box255 to baseline of text line 1
% \vsize Distance from top of \box255 to last line of text.
% \headmargin Distance from top of \box255 to top of page
% We'll place the headline just above \box255
\headmargin = \topmargin \advance \headmargin by -\topskip
\vsize = \totalheight
\advance \vsize by -\headmargin
\advance \vsize by -\bottommargin
% \vsize should now be 46.708125pc
\voffset = -1in % align top of logical page with top of physical page
\advance \voffset by \headmargin
\ifcenterpage
\dimen0 = 11in
\advance\dimen0 by -\totalheight
\divide\dimen0 by 2
\advance\voffset by \dimen0
\fi
\topskip = 2pc % Distance from headline to first line of text.
\iftrimpage
\ifx\pdfpagewidth\undefined
\special{papersize=7.375in,9.25in}%
\else
\pdfpagewidth=7.375in \pdfpageheight=9.25in
\fi
%\hsize=7.375in \vsize=9.25in
%\advance \hsize by -18pc
%\advance \vsize by -10pc
\outsidemargin = 9pc \insidemargin = 9pc
\oddoffset = -1in \advance\oddoffset by \insidemargin
\evenoffset = -1in \advance\evenoffset by \outsidemargin
\hoffset = \oddoffset
\voffset = -1in \advance \voffset by 4pc
\fi
% Other formatting parameters.
%
% The basic increments we'll use in the layout.
%
\def\setskip#1 = #2 {%
\dimen0 = #2\baselineskip
\csname #1skipamount\endcsname =
\dimen0 plus .33\dimen0 minus .25\dimen0
\ignorespaces
}
\newskip\greaterskipamount
\newskip\greatskipamount
\newskip\biggerskipamount
\newskip\medbigskipamount
\newskip\medsmallskipamount
\newskip\tinyskipamount
\setskip greater = 2.5
\setskip great = 2.0
\setskip bigger = 1.5
\setskip big = 1.0
\setskip medbig = .75
\setskip med = .5
\setskip medsmall = .375
\setskip small = .25
\setskip tiny = .125
\parindent = 2em
\newdimen\normalindent \normalindent = \parindent
\footnotemarkseparation = .16666em
\abovelistskipamount = \smallskipamount
\interitemskipamount = \tinyskipamount
\belowlistskipamount = \smallskipamount
\listleftindent = 0pt
% Displays involve text and math. We don't want as much flexibility in
% the glue as plain.tex sets.
%
\abovedisplayskip = \medsmallskipamount
\abovedisplayshortskip = 0pt plus 2pt
\belowdisplayskip = \medsmallskipamount
\belowdisplayshortskip = \belowdisplayskip
\newskip\intercapsuleskip \intercapsuleskip = .75\tinyskipamount plus 0.4pt
\newdimen\capsulehangindent \capsulehangindent = 2pc
\newskip\aboveconceptskip \aboveconceptskip = \bigskipamount
\newskip\abovesectionskip \abovesectionskip = \greaterskipamount
% No stretch or shrink below heads, according to A-W.
\newskip\belowsectionskip \belowsectionskip = 1\biggerskipamount
\newskip\abovesubsectionskip \abovesubsectionskip = \greatskipamount
\newskip\belowsubsectionskip \belowsubsectionskip = 1\bigskipamount
\newskip\abovedescriptionskip \abovedescriptionskip = \biggerskipamount
\newskip\belowdescriptionskip \belowdescriptionskip = \medskipamount
\newskip\explainskip \explainskip = \tinyskipamount
\newskip\exampleskip \exampleskip = \smallskipamount
\def\interexampleskip{\vskip\medsmallskipamount}
\def\tinyskip{\vskip\tinyskipamount}
% Space in which a symbol is shown in a columnated list of commands.
\newdimen\symbolspace \symbolspace = 14pt
% \colsindent is the indentation before material arranged in columns and
% displayed, as in the list of Greek letters.
\newskip\colsindent \colsindent = \parindent
% The indentation for page lists in the index that don't fit on one line.
\newdimen\indexpageindent \indexpageindent = 1pc
% The indentation for subsidiary entries in the index. (Should be less
% than \indexpageindent.)
\newdimen\indexlevelindent \indexlevelindent = .5pc
\newskip\codebaselineskip \codebaselineskip = \baselineskip
% Fill the previous page with blank space before a command.
%
\def\cmdbreak{\par\nobreak\vfil\penalty 1000\vfilneg\par}
% Penalties.
%
\newcount\conceptpenalty \conceptpenalty = -1500
\newcount\intercmdnamepenalty \intercmdnamepenalty = 300
\newcount\@intercmdnamepenalty \@intercmdnamepenalty = \intercmdnamepenalty
% The output routine.
%
\output = {%
\onepageout
%
% Odd pages are right-hand pages.
%
% Note \pageno has been incremented when we get here -- it now refers
% to the page number of the page about to be typeset, not the page
% that we just shipped out.
%
\ifodd\pageno % \onepageout advances \pageno.
\global\hoffset = \oddoffset
\global\intercmdnamepenalty = 10000
\else
\global\hoffset = \evenoffset
\global\intercmdnamepenalty = \@intercmdnamepenalty
\fi
}
\ifdvi\else\output={%
\setbox0=\box255\deadcycles=0
\advancepageno
\global\advance \truepage by 1
\ifnum\outputpenalty>-20000\else \dosupereject \fi
}
\fi
\def\onepageout{%
\shipout\vbox{%
\let\@plainmakeheadline\relax %% fixed for new eplain by qingkuan !!
\makeheadline %% fixed for new eplain by qingkuan !!
\offinterlineskip % The page should have vertically abutting boxes.
\ifodd\pageno
\cropmargin = \insidemargin
\else
\cropmargin = \outsidemargin
\fi
\addcropmarks % Does not affect the position.
\ifcenterpage \addtruepage \fi
%
\ifedgetabs \ifodd\pageno \ifnoheadline\else
\edgetabs % Does not affect the position.
\fi\fi\fi
%
\vbox to 0pt{\vskip-\headmargin \vskip-3.5pc
\rightline{\sevenrm\timestamp}\vss}%
%
\smash{\line{\the\headline}}% Simplified \makeheadline.
\pagebody
\vskip 2\normalbaselineskip
% The footline is needed on one page (for an example).
\line{\the\footline}%
}%
% Now the rest from \plainoutput:
\advancepageno
\global\advance\truepage by 1
\ifnum\outputpenalty>-20000\else \dosupereject \fi
}
\footline = {\hfil}
% The headline always includes the name of the current chapter. This
% goes on the inside. If more information, such as the concept we're
% explaining, is included, it goes on the outside.
%
\headline = {%
% Produce the timestamp
\ifnoheadline
\hfil
\global\noheadlinefalse
\else
\let\\ = \ignorespaces
\ifodd \pageno % Right-hand page.
{\tenit \firstmark}\hfil {\tenbf \folio}%
\else % Left-hand page.
{\tenbf \folio}%
\hfil
{\tenit
\chaptername
\ifnum\pageno>0\ifback\else
\quad $\backslash$\quad\S\the\chapterno
\fi\fi
}%
\fi
\fi
}
% Sizes for cropmarks:
%
\newdimen\cropthick \cropthick = 0.4pt
\newdimen\crophsize \crophsize = 1pc
\newdimen\cropvsize \cropvsize = 1pc
\newdimen\cropoffset \cropoffset = .0625in
% Each of the following macros generates a quarter of a cropmark as
% a zero-size box at the center point of the cropmark.
% We want the cropmarks to be centered with respect to their thicknesses.
\def\vcropdown {\hbox to 0pt{%
\kern -.5\cropthick
\vbox to 0pt{%
\vskip \cropoffset
\hrule width\cropthick depth\cropvsize height0pt
\vss}%
\kern -.5\cropthick}%
}
\def\vcropup {\hbox to 0pt{%
\kern -.5\cropthick
\vbox to 0pt{%
\vss
\hrule width\cropthick depth\cropvsize height0pt
\vskip \cropoffset}%
\kern -.5\cropthick}%
}
\def\hcropright{\rlap{\kern\cropoffset\smash{%
\vrule width\crophsize depth .5\cropthick height .5\cropthick}}}
\def\hcropleft{\llap{\smash{%
\vrule width\crophsize depth .5\cropthick height .5\cropthick}%
\kern\cropoffset}}
% \cropmargin will be set to the left margin on the current page.
%
\newdimen\cropmargin
\def\cropline#1{\moveleft\cropmargin\hbox to \totalwidth{#1}}
% \addcropmarks adds the cropmarks to a page while leaving everything else
% alone. It assumes we're positioned at the top of the page.
\def\addcropmarks{%
\vbox to 0pt{%
\offinterlineskip % contextually redundant but precautionary
\vskip -\headmargin % to get to logical top of page
\ifcenterpage
\cropline{\hcropleft\vcropup \hfil \vcropup\hcropright}
\else
\cropline{\hfil \vcropdown}%
\fi
\vskip\totalheight
\ifcenterpage
\cropline{\hcropleft\vcropdown \hfil \vcropdown\hcropright}%
\else
\cropline{\hcropright\hfil\hcropleft\vcropup\vcropdown\hcropright}%
\fi
\vss
}}
% \addtruepage adds a small page number near the upper right cropmark.
%
\newcount\truepage \truepage = 1
\def\addtruepage{%
\vbox to 0pt{\vskip -\headmargin\vskip -2pc
\moveleft\cropmargin\hbox to \totalwidth{%
\twelvebf
\quad\TeX\ 急就帖\hss
N\raise 3.3pt\hbox{o} \the\truepage\quad}%
\vss}%
}
% The mark information is output by \markinfo.
%
% We can use a different mark, e.g., a shorter heading, by calling
% \changemark.
%
\newtoks\shortmark \shortmark = {}
\newif\ifchangemark
\def\markinfo#1{%
\ifchangemark
\mark{\the\shortmark}\changemarkfalse
\else
\mark{#1}%
\fi
}
\def\changemark#1{\shortmark = {#1}\changemarktrue}
% ``Tabs'' down the side of the book.
% Say \nextedgetab to move the thing down to the next.
% Say \edgetabsfalse to turn them off.
%
\newcount\numtabs \numtabs = 7
\newdimen\edgetabjump \edgetabjump = 0pt
\def\nextedgetab{%
\advance\edgetabjump by \edgetabdepth
}
\def\settabdepth#1{%
\edgetabdepth = #1
\setbox\tabbox = \vbox to \edgetabdepth{%
\leaders
\vbox{\vskip \edgespacing
\hrule width\edgetabwidth height0pt depth\edgethick}%
\vfil}
}
\newskip\bigtab \newskip\smalltab
\newskip\edgetabdepth
\newbox\tabbox
\bigtab = \totalheight \divide\bigtab by \numtabs
\smalltab = .4\bigtab % five smalls make two bigs
\newdimen\edgetabin \edgetabin = .25in
\newdimen\edgetabbleed \edgetabbleed = .25in
\newdimen\edgetabwidth
\edgetabwidth = \edgetabin
\advance \edgetabwidth by \edgetabbleed
\newdimen\edgethick \edgethick = .3pt % line thickness
\newdimen\edgespacing \edgespacing = .9pt % line spacing
\def\edgetabs{\vbox to 0pt{%
\vskip-\headmargin
\vskip\edgetabjump
\hbox{%
\hskip \hsize
\hskip\outsidemargin
\hskip-\edgetabin
\copy\tabbox
}%
\vss
}}
% We can simplify \pagecontents (which is called by \pagebody) somewhat,
% since we don't have \topinserts.
%
\def\pagecontents{%
\unvbox255 % The main page contents.
%
\ifvoid\footins\else % Footnotes are present.
\vskip\skip\footins
\footnoterule
\unvbox\footins
\fi
}
% The command chapters had a mini-index at the bottom of right-hand
% pages. These definitions are the way to put entries into it.
%
% \minref generates a reference for the mini-index, and prints the
% reference on the page, also.
%
\def\minref#1{%
#1% Print it on the page.
% That's it, now.
}
% Mini-index entry without printing the argument on the page.
% Just ignore the argument now.
%
\def\minrefs#1{%
\ignorespaces
}
% This is used for producing the concept mini-index.
%
\def\minrefsdelim#1\endmark{\minrefs{#1}}
% One last insertion-oriented thing:
% we always want numbered footnotes, as defined in eplain.
% We'll do them in 8-point type.
%
\let\@plainfootnote = \footnote
\let\footnote = \numberedfootnote
\everyfootnote = {\footnotefonts}
% The \margin macro produces a marginal note at the same level as its call.
% It should only be used in a paragraph or in the main vertical list.
% It is nullified when we're printing the final copy.
%
\def\margin#1{%
\ifhmode
\vadjust{\printmarginnote{#1}}%
\else
\dimen0 = \prevdepth
\prevdepth = -1000pt
\printmarginnote{#1}%
\prevdepth = \dimen0
\fi
\ignorespaces
}
\def\printmarginnote#1{%
\hbox to 0pt{%
\hskip 1.1\hsize
\vbox to 0pt{%
\everypar = {}% Don't inherit hanging indentation.
\hsize = 1in \rightskip = 0pt plus 1fil \noindent \sevenrm
\let\tt = \eighttt
\parfillskip = 0pt plus 1fil
\baselineskip = 8pt #1%
\vss
}%
\hss
}%
}
%\iffinal
\iftrue
\def\margin#1{\ignorespaces}
\fi
% Stuff to preserve page breaks inserted for the 2nd printing.
% This macro takes one ``argument''.
%
\def\secondprinting{\afterassignment\finishsecondprinting \toks0 = }
\def\finishsecondprinting{\the\toks0}
% add pdf bookmarks for xetex
%
\special{pdf: docview << /PageMode /UseOutlines >>}
\def\bookmark#1#2{%
\begingroup%
\def\linebreak{}\def\TeX{TeX}\def\vtop##1{##1}\def\noindent{}\def\\{}\def\hfil{}\def\quad{}%
\ifpdf
\if1#1%
\count255=\pageno\advance\count255 by 22%
\pdfoutline goto page \the\count255 {/Fit} count 0 {#2}%
\fi
\else
\special{pdf:out #1 << /Title (#2) /Dest [ @thispage /FitH @ypos ] >>}%
\fi
\endgroup%
}
% for including artwork images
%
\newdimen\oldhoffset
\newdimen\oldvoffset
\newdimen\oldparindent
\def\includeartwork#1{%
\oldhoffset=\hoffset
\oldvoffset=\voffset
\oldparindent=\parindent
\hoffset=-1in\voffset=-1in\parindent=0pt%
\def\imgfile{artwork/#1\iftrimpage-l\fi.png}%
\def\imgsize{\iftrimpage width 7.375in height 0in depth 9.25in%
\else width 210mm height 0mm depth 297mm\fi}%
\ifpdf
\pdfimage \imgsize {\imgfile}%
\else
\special{pdf:image \imgsize (\imgfile)}%
\fi
\pagebreak
\hoffset=\oldhoffset
\voffset=\oldvoffset
\parindent=\oldparindent
}
% Parts of the book.
%
%
% Chapters.
%
\let\chaptername = \empty
\newcount\chapterno
\def\chaprule{\vrule depth3\baselineskip height1.5pc width1pt}
% Chapter openings should not have headlines.
% The text of each chapter starts on a right-hand page in the final
% book. The facing page has an illustration. This means that if the
% previous chapter ended on a left-hand (i.e., even) page, we have to
% eject an extra blank page.
%
\outer\def\chapter#1 \par{%
\ifcompletebook % Don't do the blank pages for proof copies.
\blankpage % the illustration page
% The first real chapter starts on page 1.
\ifnum\pageno < 0 \pageno = 1 \fi
\fi
%
\def\chaptername{#1}%
\advance\chapterno by 1
%
\bookmark{1}{\ifback\else\the\chapterno\ \fi\chaptername}
%
\setbox0 = \hbox{\chapternumeralfont
\kern1pt
\expandafter\kernchapno\the\chapterno\empty
\kern3pt}%
\vglue 0pt % But we get a \topskip of 2pc now.
\nointerlineskip
\leftline{%
\ifback\else
\vtop{%
\copy0
\vskip6pt
\hrule width\wd0 height2.2pc
}%
\kern 16pt
\fi
\chapterfonts % to get \baselineskip now
\chaprule
\kern 6pt
\vtop{%
\def\linebreak{\hfil\break}%
\noindent \chaptername}%
}%
\vskip 6pc plus.5pc minus.5pc
\noheadlinetrue
\toks0=\expandafter{\chaptername}
\edef\writechaptertoc{%
\noexpand\writenumberedtocentry{chapter}{\the\toks0}{\the\chapterno}%
}%
\writechaptertoc
%
% Use chaptername as first A-head (or only one).
\mark{\chaptername}%
\footnotenumber = 0 % Number footnotes from 1 in each chapter.
\beginit{CHAPTER}%
%\noindent
\ignorespaces
}
\def\endchapter{%
\mark{\chaptername}% Use chapter name on last blank recto page
\vfil\eject % be sure everything's out before testing for recto
\ifodd\pageno
\message{Chapter ends on a verso page.}%
\blankpage
\fi
\endit{CHAPTER}%
}
%
% \blankpage creates a blank page with no headline.
% In the final book, it just advances the page number.
% For the web edition, the blank pages serve no purpose except to keep
% the indexing correct. I didn't want to rerun the index.
%
\def\blankpage{%
\iffinal
\advancepageno
\global \advance \truepage by 1
\else
\noheadlinetrue\pagebreak
\fi
}
% This hokey little macro kerns between the numerals in the chapter
% number. We want to kern more between `11' then otherwise; also, we
% want to remove the extra space before the chapter number, and after
% `11'.
%
\def\kernchapno#1#2{%
\ifx\empty#2\else \kern-3pt \fi
#1%
\ifx\empty#2\else
\if1#2%
\kern-.1em
\else
\kern-.05em
\fi
\fi
#2%
\if 1#2\kern-.1em\fi
}
% Sections.
%
\newif\ifheading % Avoid breaking after a heading.
% get section numbers for the fdl only, since it has internal references.
\let\fdlkludge=\empty
% The heading flag is turned on by headings and turned off
% at the start of a description.
%
\outer\def\section#1 \par{%
\bookmark{2}{#1}%
\par % be sure we're in vertical mode
\saveskip = \lastskip % will be 0 if no skip
\cmdbreak
\combineskips\abovesectionskip
\dimen0 = 2.5\baselineskip \advance\dimen0 by -\topskip
\vskip -\dimen0
\vglue \dimen0
%
{\sectionfonts \leftline{\fdlkludge #1}}%
%
\markinfo{#1}%
\writetocentry{section}{#1}%
\nobreak
% Don't go into horizontal mode within the command descriptions.
%
\vskip\belowsectionskip
%\ifcommands \else \noindent \fi
\headingtrue
\everypar = {\headingfalse \global\everypar = {}}%
% only gets executed for \par in horizontal mode
\ignorespaces
}
% Subsections. We don't want a break at the glue if we were preceded by
% a \nobreak.
%
\def\subsection#1 \par{%
\bookmark{3}{#1}%
\par % be sure we're in vertical mode
\saveskip = \lastskip % will be 0 if no skip
\ifheading % Did we just have \section?
\nobreak
\fi
\combineskips\abovesubsectionskip
\dimen0 = 2.5\baselineskip \advance\dimen0 by -\topskip
\vskip -\dimen0
\vglue \dimen0
%
{\subsectionfonts
\leftline{\vrule width.5em height1.2ex depth.2ex \enspace #1}}%
\writetocentry{subsection}{#1}%
\nobreak
% Don't go into horizontal mode within the command descriptions.
\vskip\belowsubsectionskip
%\ifcommands \else \noindent \fi
\headingtrue
\everypar = {\headingfalse \global\everypar = {}}%
% only gets executed for \par in horizontal mode
\ignorespaces
}
% \combineskips combines the current skip (#1) with the previous skip
% (which must be in \saveskip), and effectively skips by the larger of
% the two.
%
\newskip\saveskip
\def\combineskips#1{\ifdim\saveskip<#1\vskip-\saveskip \vskip#1\fi}
% List macros.
%
% We want to use different names than eplain.
%
\let\ulist = \unorderedlist
\let\endulist = \endunorderedlist
%
\let\olist = \numberedlist
\let\endolist = \endnumberedlist
\let\compact = \listcompact
% The \noindent here keeps us from getting indentation on the first line.
% It also makes the display into a `short' display, FYI.
% The \belowdisplayskip and \abovedisplayskip glue are inserted by the
% display.
%
\long\def\display#1{%
\ifvmode \noindent \fi
$$\vtop{\everypar = {}\hsize = \displaywidth
\parfillskip = 0pt plus 1fil % don't worry about widows
\noindent #1\par\global\savedepth = \prevdepth}$$%
\endgraf
\prevdepth = \savedepth
}
% \vdisplay is like \display, except it's for vertical mode material. Use it
% to avoid an unwanted initial lineskip.
%
\long\def\vdisplay#1{%
\ifvmode \noindent \fi
$$\vtop{\everypar = {}\hsize = \displaywidth
\parfillskip = 0pt plus 1fil % don't worry about widows
#1\par\global\savedepth = \prevdepth}$$%
\endgraf
\prevdepth = \savedepth
}
% Indexing.
% Derived from Knuth's manmac macros.
%
\newwrite\index
\immediate\openout\index = \jobname.idx
\newif\ifsilent
% We need ^ to be active temporarily, while we define it.
%
{ \catcode`\^ = \active
%
\gdef^{%
\ifmmode
\let \nextaction = \sp
\else
\let \nextaction = \beginindexref
\begingroup
\catcode `| = \other \catcode `^ = \other
\fi
\nextaction
}}
\def\beginindexref{\futurelet\next\checksilence}
{% And for here, we need ^ to be deactivated
\catcode `^ = \other
\gdef\checksilence{%
\if ^\next
\silenttrue \let\nextaction = \secondhat
\else
\silentfalse \let\nextaction = \checkbar
\fi
\nextaction