582
796
\newskip\exdentamount
584
798
% This defn is used inside fill environments such as @defun.
585
\def\exdent{\parsearg\exdentyyy}
586
\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
799
\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
588
801
% This defn is used inside nofill environments such as @example.
589
\def\nofillexdent{\parsearg\nofillexdentyyy}
590
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
591
\leftline{\hskip\leftskip{\rm#1}}}}
593
% @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
596
\strut\vadjust{\nobreak\kern-\strutdepth
597
\vtop to \strutdepth{\baselineskip\strutdepth\vss
598
\llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
802
\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
803
\leftline{\hskip\leftskip{\rm#1}}}}
805
% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
806
% paragraph. For more general purposes, use the \margin insertion
807
% class. WHICH is `l' or `r'.
599
809
\newskip\inmarginspacing \inmarginspacing=1cm
600
810
\def\strutdepth{\dp\strutbox}
602
%\hbox{{\rm#1}}\hfil\break}}
812
\def\doinmargin#1#2{\strut\vadjust{%
815
\vtop to \strutdepth{%
816
\baselineskip=\strutdepth
818
% if you have multiple lines of stuff to put here, you'll need to
819
% make the vbox yourself of the appropriate size.
821
\llap{\ignorespaces #2\hskip\inmarginspacing}%
823
\rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
828
\def\inleftmargin{\doinmargin l}
829
\def\inrightmargin{\doinmargin r}
831
% @inmargin{TEXT [, RIGHT-TEXT]}
832
% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
833
% else use TEXT for both).
835
\def\inmargin#1{\parseinmargin #1,,\finish}
836
\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
837
\setbox0 = \hbox{\ignorespaces #2}%
839
\def\lefttext{#1}% have both texts
842
\def\lefttext{#1}% have only one text
847
\def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
849
\def\temp{\inleftmargin\lefttext}%
604
854
% @include file insert text of that file as input.
605
% Allow normal characters that we make active in the argument (a file name).
606
\def\include{\begingroup
615
\parsearg\includezzz}
616
% Restore active chars for included file.
617
\def\includezzz#1{\endgroup\begingroup
618
% Read the included file in a group so nested @include's work.
856
\def\include{\parseargusing\filenamecatcodes\includezzz}
619
859
\def\thisfile{#1}%
862
\def\temp{\input #1 }%
867
\def\filenamecatcodes{%
879
\def\pushthisfilestack{%
880
\expandafter\pushthisfilestackX\popthisfilestack\StackTerm
882
\def\pushthisfilestackX{%
883
\expandafter\pushthisfilestackY\thisfile\StackTerm
885
\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
886
\gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
889
\def\popthisfilestack{\errthisfilestackempty}
890
\def\errthisfilestackempty{\errmessage{Internal error:
891
the stack of filenames is empty.}}
625
% @center line outputs that line, centered
627
\def\center{\parsearg\centerzzz}
628
\def\centerzzz #1{{\advance\hsize by -\leftskip
629
\advance\hsize by -\rightskip
896
% outputs that line, centered.
898
\parseargdef\center{%
904
\next{\hfil \ignorespaces#1\unskip \hfil}%
909
\advance\hsize by -\leftskip
910
\advance\hsize by -\rightskip
915
\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
632
917
% @sp n outputs n lines of vertical space
634
\def\sp{\parsearg\spxxx}
635
\def\spxxx #1{\vskip #1\baselineskip}
919
\parseargdef\sp{\vskip #1\baselineskip}
637
921
% @comment ...line which is ignored...
638
922
% @c is the same as @comment
639
923
% @ignore ... @end ignore is another way to write a comment
641
\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
642
\parsearg \commentxxx}
644
\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
925
\def\comment{\begingroup \catcode`\^^M=\other%
926
\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
928
{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
648
% @paragraphindent is defined for the Info formatting commands only.
649
\let\paragraphindent=\comment
651
% Prevent errors for section commands.
652
% Used in @ignore and in failing conditionals.
653
\def\ignoresections{%
655
\let\unnumbered=\relax
657
\let\unnumberedsec=\relax
658
\let\unnumberedsection=\relax
659
\let\unnumberedsubsec=\relax
660
\let\unnumberedsubsection=\relax
661
\let\unnumberedsubsubsec=\relax
662
\let\unnumberedsubsubsection=\relax
665
\let\subsubsec=\relax
666
\let\subsection=\relax
667
\let\subsubsection=\relax
669
\let\appendixsec=\relax
670
\let\appendixsection=\relax
671
\let\appendixsubsec=\relax
672
\let\appendixsubsection=\relax
673
\let\appendixsubsubsec=\relax
674
\let\appendixsubsubsection=\relax
676
\let\smallbook=\relax
677
\let\titlepage=\relax
680
% Used in nested conditionals, where we have to parse the Texinfo source
681
% and so want to turn off most commands, in case they are used
684
\def\ignoremorecommands{%
685
\let\defcodeindex = \relax
689
\let\defindex = \relax
690
\let\defivar = \relax
692
\let\defmethod = \relax
695
\let\defspec = \relax
697
\let\deftypefn = \relax
698
\let\deftypefun = \relax
699
\let\deftypevar = \relax
700
\let\deftypevr = \relax
706
\let\printindex = \relax
708
\let\settitle = \relax
709
\let\setchapternewpage = \relax
710
\let\setchapterstyle = \relax
711
\let\everyheading = \relax
712
\let\evenheading = \relax
713
\let\oddheading = \relax
714
\let\everyfooting = \relax
715
\let\evenfooting = \relax
716
\let\oddfooting = \relax
717
\let\headings = \relax
718
\let\include = \relax
719
\let\lowersections = \relax
721
\let\raisesections = \relax
728
% Ignore @ignore ... @end ignore.
730
\def\ignore{\doignore{ignore}}
732
% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text.
734
\def\ifinfo{\doignore{ifinfo}}
735
\def\ifhtml{\doignore{ifhtml}}
736
\def\html{\doignore{html}}
737
\def\menu{\doignore{menu}}
738
\def\direntry{\doignore{direntry}}
740
% Also ignore @macro ... @end macro. The user must run texi2dvi,
741
% which runs makeinfo to do macro expansion. Ignore @unmacro, too.
742
\def\macro{\doignore{macro}}
743
\let\unmacro = \comment
746
% @dircategory CATEGORY -- specify a category of the dir file
747
% which this file should belong to. Ignore this in TeX.
748
\let\dircategory = \comment
750
% Ignore text until a line `@end #1'.
752
\def\doignore#1{\begingroup
753
% Don't complain about control sequences we have declared \outer.
756
% Define a command to swallow text until we reach `@end #1'.
757
\long\def\doignoretext##1\end #1{\enddoignore}%
759
% Make sure that spaces turn into tokens that match what \doignoretext wants.
762
% And now expand that command.
766
% What we do to finish off ignored text.
768
\def\enddoignore{\endgroup\ignorespaces}%
770
\newif\ifwarnedobs\warnedobsfalse
772
\ifwarnedobs\relax\else
773
% We need to warn folks that they may have trouble with TeX 3.0.
774
% This uses \immediate\write16 rather than \message to get newlines.
776
\immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
777
\immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
778
\immediate\write16{If you are running another version of TeX, relax.}
779
\immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
780
\immediate\write16{ Then upgrade your TeX installation if you can.}
781
\immediate\write16{ (See ftp://ftp.gnu.ai.mit.edu/pub/gnu/TeX.README.)}
782
\immediate\write16{If you are stuck with version 3.0, run the}
783
\immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
784
\immediate\write16{ to use a workaround.}
786
\global\warnedobstrue
790
% **In TeX 3.0, setting text in \nullfont hangs tex. For a
791
% workaround (which requires the file ``dummy.tfm'' to be installed),
792
% uncomment the following line:
793
%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
795
% Ignore text, except that we keep track of conditional commands for
796
% purposes of nesting, up to an `@end #1' command.
798
\def\nestedignore#1{%
800
% We must actually expand the ignored text to look for the @end
801
% command, so that nested ignore constructs work. Thus, we put the
802
% text into a \vbox and then do nothing with the result. To minimize
803
% the change of memory overflow, we follow the approach outlined on
804
% page 401 of the TeXbook: make the current font be a dummy font.
806
\setbox0 = \vbox\bgroup
807
% Don't complain about control sequences we have declared \outer.
810
% Define `@end #1' to end the box, which will in turn undefine the
811
% @end command again.
812
\expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
814
% We are going to be parsing Texinfo commands. Most cause no
815
% trouble when they are used incorrectly, but some commands do
816
% complicated argument parsing or otherwise get confused, so we
819
% We can't do anything about stray @-signs, unfortunately;
820
% they'll produce `undefined control sequence' errors.
823
% Set the current font to be \nullfont, a TeX primitive, and define
824
% all the font commands to also use \nullfont. We don't use
825
% dummy.tfm, as suggested in the TeXbook, because not all sites
826
% might have that installed. Therefore, math mode will still
827
% produce output, but that should be an extremely small amount of
828
% stuff compared to the main input.
831
\let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont
832
\let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont
833
\let\tensf = \nullfont
834
% Similarly for index fonts (mostly for their use in
836
\let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont
837
\let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont
838
\let\indsf = \nullfont
840
% Don't complain when characters are missing from the fonts.
841
\tracinglostchars = 0
843
% Don't bother to do space factor calculations.
846
% Don't report underfull hboxes.
849
% Do minimal line-breaking.
850
\pretolerance = 10000
852
% Do not execute instructions in @tex
853
\def\tex{\doignore{tex}}
856
% @set VAR sets the variable VAR to an empty value.
857
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
859
% Since we want to separate VAR from REST-OF-LINE (which might be
860
% empty), we can't just use \parsearg; we have to insert a space of our
861
% own to delimit the rest of the line, and then take it out again if we
862
% didn't need it. Make sure the catcode of space is correct to avoid
863
% losing inside @example, for instance.
865
\def\set{\begingroup\catcode` =10
866
\catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
868
\def\setxxx#1{\setyyy#1 \endsetyyy}
869
\def\setyyy#1 #2\endsetyyy{%
871
\ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
872
\else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
876
% Can't use \xdef to pre-expand #2 and save some time, since \temp or
877
% \next or other control sequences that we've defined might get us into
878
% an infinite loop. Consider `@set foo @cite{bar}'.
879
\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
881
% @clear VAR clears (i.e., unsets) the variable VAR.
883
\def\clear{\parsearg\clearxxx}
884
\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
886
% @value{foo} gets the text saved in variable foo.
888
\def\value{\begingroup
889
\catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
892
\expandafter\ifx\csname SET#1\endcsname\relax
893
{\{No value for ``#1''\}}%
895
\csname SET#1\endcsname
899
% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
902
\def\ifset{\parsearg\ifsetxxx}
904
\expandafter\ifx\csname SET#1\endcsname\relax
905
\expandafter\ifsetfail
907
\expandafter\ifsetsucceed
910
\def\ifsetsucceed{\conditionalsucceed{ifset}}
911
\def\ifsetfail{\nestedignore{ifset}}
912
\defineunmatchedend{ifset}
914
% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
915
% defined with @set, or has been undefined with @clear.
917
\def\ifclear{\parsearg\ifclearxxx}
919
\expandafter\ifx\csname SET#1\endcsname\relax
920
\expandafter\ifclearsucceed
922
\expandafter\ifclearfail
925
\def\ifclearsucceed{\conditionalsucceed{ifclear}}
926
\def\ifclearfail{\nestedignore{ifclear}}
927
\defineunmatchedend{ifclear}
929
% @iftex always succeeds; we read the text following, through @end
930
% iftex). But `@end iftex' should be valid only after an @iftex.
932
\def\iftex{\conditionalsucceed{iftex}}
933
\defineunmatchedend{iftex}
935
% We can't just want to start a group at @iftex (for example) and end it
936
% at @end iftex, since then @set commands inside the conditional have no
937
% effect (they'd get reverted at the end of the group). So we must
938
% define \Eiftex to redefine itself to be its previous value. (We can't
939
% just define it to fail again with an ``unmatched end'' error, since
940
% the @ifset might be nested.)
942
\def\conditionalsucceed#1{%
944
% Remember the current value of \E#1.
945
\let\nece{prevE#1} = \nece{E#1}%
947
% At the `@end #1', redefine \E#1 to be its previous value.
948
\def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
953
% We need to expand lots of \csname's, but we don't want to expand the
954
% control sequences after we've constructed them.
956
\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
932
% @paragraphindent NCHARS
933
% We'll use ems for NCHARS, close enough.
934
% NCHARS can also be the word `asis' or `none'.
935
% We cannot feasibly implement @paragraphindent asis, though.
937
\def\asisword{asis} % no translation, these are keywords
940
\parseargdef\paragraphindent{%
945
\defaultparindent = 0pt
947
\defaultparindent = #1em
950
\parindent = \defaultparindent
953
% @exampleindent NCHARS
954
% We'll use ems for NCHARS like @paragraphindent.
955
% It seems @exampleindent asis isn't necessary, but
956
% I preserve it to make it similar to @paragraphindent.
957
\parseargdef\exampleindent{%
964
\lispnarrowing = #1em
969
% @firstparagraphindent WORD
970
% If WORD is `none', then suppress indentation of the first paragraph
971
% after a section heading. If WORD is `insert', then do indent at such
974
% The paragraph indentation is suppressed or not by calling
975
% \suppressfirstparagraphindent, which the sectioning commands do.
976
% We switch the definition of this back and forth according to WORD.
977
% By default, we suppress indentation.
979
\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
980
\def\insertword{insert}
982
\parseargdef\firstparagraphindent{%
985
\let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
986
\else\ifx\temp\insertword
987
\let\suppressfirstparagraphindent = \relax
990
\errmessage{Unknown @firstparagraphindent option `\temp'}%
994
% Here is how we actually suppress indentation. Redefine \everypar to
995
% \kern backwards by \parindent, and then reset itself to empty.
997
% We also make \indent itself not actually do anything until the next
1000
\gdef\dosuppressfirstparagraphindent{%
1002
\restorefirstparagraphindent
1006
\restorefirstparagraphindent
1009
\global\everypar = {%
1011
\restorefirstparagraphindent
1015
\gdef\restorefirstparagraphindent{%
1016
\global \let \indent = \ptexindent
1017
\global \let \noindent = \ptexnoindent
1018
\global \everypar = {}%
958
1022
% @asis just yields its argument. Used with @table, for example.
962
% @math means output in math mode.
963
% We don't use $'s directly in the definition of \math because control
964
% sequences like \math are expanded when the toc file is written. Then,
965
% we read the toc file back, the $'s will be normal characters (as they
966
% should be, according to the definition of Texinfo). So we must use a
967
% control sequence to switch into and out of math mode.
969
% This isn't quite enough for @math to work properly in indices, but it
970
% seems unlikely it will ever be needed there.
972
\let\implicitmath = $
973
\def\math#1{\implicitmath #1\implicitmath}
1026
% @math outputs its argument in math mode.
1028
% One complication: _ usually means subscripts, but it could also mean
1029
% an actual _ character, as in @math{@var{some_variable} + 1}. So make
1030
% _ active, and distinguish by seeing if the current family is \slfam,
1031
% which is what @var uses.
1033
\catcode\underChar = \active
1034
\gdef\mathunderscore{%
1035
\catcode\underChar=\active
1036
\def_{\ifnum\fam=\slfam \_\else\sb\fi}%
1039
% Another complication: we want \\ (and @\) to output a \ character.
1040
% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
1041
% this is not advertised and we don't care. Texinfo does not
1042
% otherwise define @\.
1044
% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
1045
\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
1050
\let\\ = \mathbackslash
1054
\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
1056
% Some active characters (such as <) are spaced differently in math.
1057
% We have to reset their definitions in case the @math was an argument
1058
% to a command which sets the catcodes (such as @item or @section).
1061
\catcode`^ = \active
1062
\catcode`< = \active
1063
\catcode`> = \active
1064
\catcode`+ = \active
975
1073
% @bullet and @minus need the same treatment as @math, just above.
976
\def\bullet{\implicitmath\ptexbullet\implicitmath}
977
\def\minus{\implicitmath-\implicitmath}
979
\def\node{\ENVcheck\parsearg\nodezzz}
980
\def\nodezzz#1{\nodexxx [#1,]}
981
\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
985
\def\donoderef{\ifx\lastnode\relax\else
986
\expandafter\expandafter\expandafter\setref{\lastnode}\fi
987
\global\let\lastnode=\relax}
989
\def\unnumbnoderef{\ifx\lastnode\relax\else
990
\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
991
\global\let\lastnode=\relax}
993
\def\appendixnoderef{\ifx\lastnode\relax\else
994
\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
995
\global\let\lastnode=\relax}
1074
\def\bullet{$\ptexbullet$}
1077
% @dots{} outputs an ellipsis using the current font.
1078
% We do .5em per period so that it has the same spacing in a typewriter
1079
% font as three actual period characters.
1084
\hskip 0pt plus 0.25fil
1086
\hskip 0pt plus 0.5fil
1090
% @enddots{} is an end-of-sentence ellipsis.
1097
% @comma{} is so commas can be inserted into text without messing up
1098
% Texinfo's parsing.
997
1102
% @refill is a no-op.
998
1103
\let\refill=\relax
1105
% If working on a large document in chapters, it is convenient to
1106
% be able to disable indexing, cross-referencing, and contents, for test runs.
1107
% This is done with @novalidate (before @setfilename).
1109
\newif\iflinks \linkstrue % by default we want the aux files.
1110
\let\novalidate = \linksfalse
1000
1112
% @setfilename is done at the beginning of every texinfo file.
1001
1113
% So open here the files we need to have open while reading the input.
1002
1114
% This makes it possible to make a .fmt file for texinfo.
1003
1115
\def\setfilename{%
1116
\fixbackslash % Turn off hack to swallow `\input texinfo'.
1119
% Open the new aux file. TeX will close it automatically at exit.
1120
\immediate\openout\auxfile=\jobname.aux
1121
\fi % \openindices needs to do some work in any case.
1007
\fixbackslash % Turn off hack to swallow `\input texinfo'.
1008
\global\let\setfilename=\comment % Ignore extra @setfilename cmds.
1123
\let\setfilename=\comment % Ignore extra @setfilename cmds.
1125
% If texinfo.cnf is present on the system, read it.
1126
% Useful for site-wide @afourpaper, etc.
1127
\openin 1 texinfo.cnf
1128
\ifeof 1 \else \input texinfo.cnf \fi
1009
1131
\comment % Ignore the actual filename.
1134
% Called from \setfilename.
1013
1146
\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1015
% \def\macro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\macroxxx}
1016
% \def\macroxxx#1#2 \end macro{%
1017
% \expandafter\gdef\macrotemp#1{#2}%
1020
%\def\linemacro#1{\begingroup\ignoresections\catcode`\#=6\def\macrotemp{#1}\parsearg\linemacroxxx}
1021
%\def\linemacroxxx#1#2 \end linemacro{%
1022
%\let\parsearg=\relax
1023
%\edef\macrotempx{\csname M\butfirst\expandafter\string\macrotemp\endcsname}%
1024
%\expandafter\xdef\macrotemp{\parsearg\macrotempx}%
1025
%\expandafter\gdef\macrotempx#1{#2}%
1150
% adobe `portable' document format
1154
\newcount\filenamelength
1163
\newif\ifpdfmakepagedest
1165
% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1166
% can be set). So we test for \relax and 0 as well as \undefined,
1167
% borrowed from ifpdf.sty.
1168
\ifx\pdfoutput\undefined
1170
\ifx\pdfoutput\relax
1181
\pdfcatalog{/PageMode /UseOutlines}%
1182
\def\dopdfimage#1#2#3{%
1183
\def\imagewidth{#2}%
1184
\def\imageheight{#3}%
1185
% without \immediate, pdftex seg faults when the same image is
1186
% included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
1187
\ifnum\pdftexversion < 14
1190
\immediate\pdfximage
1192
\ifx\empty\imagewidth\else width \imagewidth \fi
1193
\ifx\empty\imageheight\else height \imageheight \fi
1194
\ifnum\pdftexversion<13
1199
\ifnum\pdftexversion < 14 \else
1200
\pdfrefximage \pdflastximage
1203
% We have to set dummies so commands such as @code in a section title
1206
\normalturnoffactive
1207
\pdfdest name{#1} xyz%
1210
\let\linkcolor = \Blue % was Cyan, but that seems light?
1211
\def\endlink{\Black\pdfendlink}
1212
% Adding outlines to PDF; macros for calculating structure of outlines
1213
% come from Petr Olsak
1214
\def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1215
\else \csname#1\endcsname \fi}
1216
\def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1217
\advance\tempnum by 1
1218
\expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1220
% #1 is the section text. #2 is the pdf expression for the number
1221
% of subentries (or empty, for subsubsections). #3 is the node
1222
% text, which might be empty if this toc entry had no
1223
% corresponding node. #4 is the page number.
1225
\def\dopdfoutline#1#2#3#4{%
1226
% Generate a link to the node text if that exists; else, use the
1227
% page number. We could generate a destination for the section
1228
% text in the case where a section has no node, but it doesn't
1229
% seem worthwhile, since most documents are normally structured.
1230
\def\pdfoutlinedest{#3}%
1231
\ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}\fi
1233
\pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{#1}%
1236
\def\pdfmakeoutlines{%
1238
% Thanh's hack / proper braces in bookmarks
1239
\edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
1240
\edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
1242
% Read toc silently, to get counts of subentries for \pdfoutline.
1243
\def\numchapentry##1##2##3##4{%
1244
\def\thischapnum{##2}%
1245
\let\thissecnum\empty
1246
\let\thissubsecnum\empty
1248
\def\numsecentry##1##2##3##4{%
1249
\advancenumber{chap\thischapnum}%
1250
\def\thissecnum{##2}%
1251
\let\thissubsecnum\empty
1253
\def\numsubsecentry##1##2##3##4{%
1254
\advancenumber{sec\thissecnum}%
1255
\def\thissubsecnum{##2}%
1257
\def\numsubsubsecentry##1##2##3##4{%
1258
\advancenumber{subsec\thissubsecnum}%
1260
\let\thischapnum\empty
1261
\let\thissecnum\empty
1262
\let\thissubsecnum\empty
1264
% use \def rather than \let here because we redefine \chapentry et
1265
% al. a second time, below.
1266
\def\appentry{\numchapentry}%
1267
\def\appsecentry{\numsecentry}%
1268
\def\appsubsecentry{\numsubsecentry}%
1269
\def\appsubsubsecentry{\numsubsubsecentry}%
1270
\def\unnchapentry{\numchapentry}%
1271
\def\unnsecentry{\numsecentry}%
1272
\def\unnsubsecentry{\numsubsecentry}%
1273
\def\unnsubsubsecentry{\numsubsubsecentry}%
1276
% Read toc second time, this time actually producing the outlines.
1277
% The `-' means take the \expnumber as the absolute number of
1278
% subentries, which we calculated on our first read of the .toc above.
1280
% We use the node names as the destinations.
1281
\def\numchapentry##1##2##3##4{%
1282
\dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1283
\def\numsecentry##1##2##3##4{%
1284
\dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1285
\def\numsubsecentry##1##2##3##4{%
1286
\dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1287
\def\numsubsubsecentry##1##2##3##4{% count is always zero
1288
\dopdfoutline{##1}{}{##3}{##4}}%
1290
% PDF outlines are displayed using system fonts, instead of
1291
% document fonts. Therefore we cannot use special characters,
1292
% since the encoding is unknown. For example, the eogonek from
1293
% Latin 2 (0xea) gets translated to a | character. Info from
1294
% Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1296
% xx to do this right, we have to translate 8-bit characters to
1297
% their "best" equivalent, based on the @documentencoding. Right
1298
% now, I guess we'll just let the pdf reader have its way.
1305
\def\makelinks #1,{%
1306
\def\params{#1}\def\E{END}%
1308
\let\nextmakelinks=\relax
1310
\let\nextmakelinks=\makelinks
1311
\ifnum\lnkcount>0,\fi
1313
\startlink attr{/Border [0 0 0]}
1314
goto name{\pdfmkpgn{\the\pgn}}%
1316
\advance\lnkcount by 1%
1321
\def\picknum#1{\expandafter\pn#1}
1332
\def\ppn#1{\pgn=#1\gobble}
1333
\def\ppnn{\pgn=\first}
1334
\def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
1335
\def\skipspaces#1{\def\PP{#1}\def\D{|}%
1336
\ifx\PP\D\let\nextsp\relax
1337
\else\let\nextsp\skipspaces
1338
\ifx\p\space\else\addtokens{\filename}{\PP}%
1339
\advance\filenamelength by 1
1343
\def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
1344
\ifnum\pdftexversion < 14
1345
\let \startlink \pdfannotlink
1347
\let \startlink \pdfstartlink
1351
\normalturnoffactive\def\@{@}%
1352
\makevalueexpandable
1354
\startlink attr{/Border [0 0 0]}%
1355
user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1357
\def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1358
\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1359
\def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1360
\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1362
\expandafter\poptoks\the\toksA|ENDTOKS|\relax
1364
\else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1365
\else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1366
\else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1368
\ifnum0=\countA\else\makelink\fi
1369
\ifx\first.\let\next=\done\else
1371
\addtokens{\toksB}{\the\toksD}
1372
\ifx\first,\addtokens{\toksB}{\space}\fi
1374
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1376
\def\makelink{\addtokens{\toksB}%
1377
{\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1379
\startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1380
\linkcolor #1\endlink}
1381
\def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1383
\let\pdfmkdest = \gobble
1384
\let\pdfurl = \gobble
1385
\let\endlink = \relax
1386
\let\linkcolor = \relax
1387
\let\pdfmakeoutlines = \relax
1388
\fi % \ifx\pdfoutput
1031
1391
\message{fonts,}
1033
% Font-change commands.
1035
% Texinfo supports the sans serif font style, which plain TeX does not.
1036
% So we set up a \sf analogous to plain's \rm, etc.
1393
% Change the current font style to #1, remembering it in \curfontstyle.
1394
% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1395
% italics, not bold italics.
1397
\def\setfontstyle#1{%
1398
\def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1399
\csname ten#1\endcsname % change the current font
1402
% Select #1 fonts with the current style.
1404
\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1406
\def\rm{\fam=0 \setfontstyle{rm}}
1407
\def\it{\fam=\itfam \setfontstyle{it}}
1408
\def\sl{\fam=\slfam \setfontstyle{sl}}
1409
\def\bf{\fam=\bffam \setfontstyle{bf}}
1410
\def\tt{\fam=\ttfam \setfontstyle{tt}}
1412
% Texinfo sort of supports the sans serif font style, which plain TeX does not.
1413
% So we set up a \sf.
1038
\def\sf{\fam=\sffam \tensf}
1415
\def\sf{\fam=\sffam \setfontstyle{sf}}
1039
1416
\let\li = \sf % Sometimes we call it \li, not \sf.
1041
% We don't need math for this one.
1044
%% Try out Computer Modern fonts at \magstephalf
1045
\let\mainmagstep=\magstephalf
1418
% We don't need math for this font style.
1419
\def\ttsl{\setfontstyle{ttsl}}
1422
\newdimen\textleading \textleading = 13.2pt
1424
% Set the baselineskip to #1, and the lineskip and strut size
1425
% correspondingly. There is no deep meaning behind these magic numbers
1426
% used as factors; they just match (closely enough) what Knuth defined.
1428
\def\lineskipfactor{.08333}
1429
\def\strutheightpercent{.70833}
1430
\def\strutdepthpercent {.29167}
1433
\normalbaselineskip = #1\relax
1434
\normallineskip = \lineskipfactor\normalbaselineskip
1436
\setbox\strutbox =\hbox{%
1437
\vrule width0pt height\strutheightpercent\baselineskip
1438
depth \strutdepthpercent \baselineskip
1047
1442
% Set the font macro #1 to the font named #2, adding on the
1048
1443
% specified font prefix (normally `cm').
2185
3022
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2186
3023
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
3025
% Take care of Texinfo commands that can appear in an index entry.
3026
% Since there are some commands we want to expand, and others we don't,
3027
% we have to laboriously prevent expansion for those that we don't.
2188
3029
\def\indexdummies{%
2189
% Take care of the plain tex accent commands.
2190
\def\"{\realbackslash "}%
2191
\def\`{\realbackslash `}%
2192
\def\'{\realbackslash '}%
2193
\def\^{\realbackslash ^}%
2194
\def\~{\realbackslash ~}%
2195
\def\={\realbackslash =}%
2196
\def\b{\realbackslash b}%
2197
\def\c{\realbackslash c}%
2198
\def\d{\realbackslash d}%
2199
\def\u{\realbackslash u}%
2200
\def\v{\realbackslash v}%
2201
\def\H{\realbackslash H}%
2202
% Take care of the plain tex special European modified letters.
2203
\def\oe{\realbackslash oe}%
2204
\def\ae{\realbackslash ae}%
2205
\def\aa{\realbackslash aa}%
2206
\def\OE{\realbackslash OE}%
2207
\def\AE{\realbackslash AE}%
2208
\def\AA{\realbackslash AA}%
2209
\def\o{\realbackslash o}%
2210
\def\O{\realbackslash O}%
2211
\def\l{\realbackslash l}%
2212
\def\L{\realbackslash L}%
2213
\def\ss{\realbackslash ss}%
2214
% Take care of texinfo commands likely to appear in an index entry.
2215
% (Must be a way to avoid doing expansion at all, and thus not have to
2216
% laboriously list every single command here.)
2217
\def\@{@}% will be @@ when we switch to @ as escape char.
2218
%\let\{ = \lbracecmd
2219
%\let\} = \rbracecmd
2220
\def\_{{\realbackslash _}}%
2221
\def\w{\realbackslash w }%
2222
\def\bf{\realbackslash bf }%
2223
%\def\rm{\realbackslash rm }%
2224
\def\sl{\realbackslash sl }%
2225
\def\sf{\realbackslash sf}%
2226
\def\tt{\realbackslash tt}%
2227
\def\gtr{\realbackslash gtr}%
2228
\def\less{\realbackslash less}%
2229
\def\hat{\realbackslash hat}%
2230
%\def\char{\realbackslash char}%
2231
\def\TeX{\realbackslash TeX}%
2232
\def\dots{\realbackslash dots }%
2233
\def\copyright{\realbackslash copyright }%
2234
\def\tclose##1{\realbackslash tclose {##1}}%
2235
\def\code##1{\realbackslash code {##1}}%
2236
\def\dotless##1{\realbackslash dotless {##1}}%
2237
\def\samp##1{\realbackslash samp {##1}}%
2238
\def\,##1{\realbackslash ,{##1}}%
2239
\def\t##1{\realbackslash t {##1}}%
2240
\def\r##1{\realbackslash r {##1}}%
2241
\def\i##1{\realbackslash i {##1}}%
2242
\def\b##1{\realbackslash b {##1}}%
2243
\def\sc##1{\realbackslash sc {##1}}%
2244
\def\cite##1{\realbackslash cite {##1}}%
2245
\def\key##1{\realbackslash key {##1}}%
2246
\def\file##1{\realbackslash file {##1}}%
2247
\def\var##1{\realbackslash var {##1}}%
2248
\def\kbd##1{\realbackslash kbd {##1}}%
2249
\def\dfn##1{\realbackslash dfn {##1}}%
2250
\def\emph##1{\realbackslash emph {##1}}%
2254
% If an index command is used in an @example environment, any spaces
2255
% therein should become regular spaces in the raw index file, not the
2256
% expansion of \tie (\\leavevmode \penalty \@M \ ).
2258
\gdef\unsepspaces{\obeyspaces\let =\space}}
2260
% \indexnofonts no-ops all font-change commands.
2261
% This is used when outputting the strings to sort the index by.
2262
\def\indexdummyfont#1{#1}
2263
\def\indexdummytex{TeX}
2264
\def\indexdummydots{...}
3030
\def\@{@}% change to @@ when we switch to @ as escape char in index files.
3031
\def\ {\realbackslash\space }%
3032
% Need these in case \tex is in effect and \{ is a \delimiter again.
3033
% But can't use \lbracecmd and \rbracecmd because texindex assumes
3034
% braces and backslashes are used only as delimiters.
3038
% \definedummyword defines \#1 as \realbackslash #1\space, thus
3039
% effectively preventing its expansion. This is used only for control
3040
% words, not control letters, because the \space would be incorrect
3041
% for control characters, but is needed to separate the control word
3042
% from whatever follows.
3044
% For control letters, we have \definedummyletter, which omits the
3047
% These can be used both for control words that take an argument and
3048
% those that do not. If it is followed by {arg} in the input, then
3049
% that will dutifully get written to the index (or wherever).
3051
\def\definedummyword##1{%
3052
\expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}%
3054
\def\definedummyletter##1{%
3055
\expandafter\def\csname ##1\endcsname{\realbackslash ##1}%
3058
% Do the redefinitions.
3062
% For the aux file, @ is the escape character. So we want to redefine
3063
% everything using @ instead of \realbackslash. When everything uses
3064
% @, this will be simpler.
3069
\let\{ = \lbraceatcmd
3070
\let\} = \rbraceatcmd
3072
% (See comments in \indexdummies.)
3073
\def\definedummyword##1{%
3074
\expandafter\def\csname ##1\endcsname{@##1\space}%
3076
\def\definedummyletter##1{%
3077
\expandafter\def\csname ##1\endcsname{@##1}%
3080
% Do the redefinitions.
3084
% Called from \indexdummies and \atdummies. \definedummyword and
3085
% \definedummyletter must be defined first.
3087
\def\commondummies{%
3089
\normalturnoffactive
3091
\commondummiesnofonts
3093
\definedummyletter{_}%
3095
% Non-English letters.
3096
\definedummyword{AA}%
3097
\definedummyword{AE}%
3098
\definedummyword{L}%
3099
\definedummyword{OE}%
3100
\definedummyword{O}%
3101
\definedummyword{aa}%
3102
\definedummyword{ae}%
3103
\definedummyword{l}%
3104
\definedummyword{oe}%
3105
\definedummyword{o}%
3106
\definedummyword{ss}%
3107
\definedummyword{exclamdown}%
3108
\definedummyword{questiondown}%
3109
\definedummyword{ordf}%
3110
\definedummyword{ordm}%
3112
% Although these internal commands shouldn't show up, sometimes they do.
3113
\definedummyword{bf}%
3114
\definedummyword{gtr}%
3115
\definedummyword{hat}%
3116
\definedummyword{less}%
3117
\definedummyword{sf}%
3118
\definedummyword{sl}%
3119
\definedummyword{tclose}%
3120
\definedummyword{tt}%
3122
\definedummyword{LaTeX}%
3123
\definedummyword{TeX}%
3125
% Assorted special characters.
3126
\definedummyword{bullet}%
3127
\definedummyword{copyright}%
3128
\definedummyword{registeredsymbol}%
3129
\definedummyword{dots}%
3130
\definedummyword{enddots}%
3131
\definedummyword{equiv}%
3132
\definedummyword{error}%
3133
\definedummyword{expansion}%
3134
\definedummyword{minus}%
3135
\definedummyword{pounds}%
3136
\definedummyword{point}%
3137
\definedummyword{print}%
3138
\definedummyword{result}%
3140
% Handle some cases of @value -- where it does not contain any
3141
% (non-fully-expandable) commands.
3142
\makevalueexpandable
3144
% Normal spaces, not active ones.
3147
% No macro expansion.
3151
% \commondummiesnofonts: common to \commondummies and \indexnofonts.
3153
% Better have this without active chars.
3156
\gdef\commondummiesnofonts{%
3157
% Control letters and accents.
3158
\definedummyletter{!}%
3159
\definedummyletter{"}%
3160
\definedummyletter{'}%
3161
\definedummyletter{*}%
3162
\definedummyletter{,}%
3163
\definedummyletter{.}%
3164
\definedummyletter{/}%
3165
\definedummyletter{:}%
3166
\definedummyletter{=}%
3167
\definedummyletter{?}%
3168
\definedummyletter{^}%
3169
\definedummyletter{`}%
3170
\definedummyletter{~}%
3171
\definedummyword{u}%
3172
\definedummyword{v}%
3173
\definedummyword{H}%
3174
\definedummyword{dotaccent}%
3175
\definedummyword{ringaccent}%
3176
\definedummyword{tieaccent}%
3177
\definedummyword{ubaraccent}%
3178
\definedummyword{udotaccent}%
3179
\definedummyword{dotless}%
3181
% Texinfo font commands.
3182
\definedummyword{b}%
3183
\definedummyword{i}%
3184
\definedummyword{r}%
3185
\definedummyword{sc}%
3186
\definedummyword{t}%
3188
% Commands that take arguments.
3189
\definedummyword{acronym}%
3190
\definedummyword{cite}%
3191
\definedummyword{code}%
3192
\definedummyword{command}%
3193
\definedummyword{dfn}%
3194
\definedummyword{emph}%
3195
\definedummyword{env}%
3196
\definedummyword{file}%
3197
\definedummyword{kbd}%
3198
\definedummyword{key}%
3199
\definedummyword{math}%
3200
\definedummyword{option}%
3201
\definedummyword{samp}%
3202
\definedummyword{strong}%
3203
\definedummyword{tie}%
3204
\definedummyword{uref}%
3205
\definedummyword{url}%
3206
\definedummyword{var}%
3207
\definedummyword{verb}%
3208
\definedummyword{w}%
3212
% \indexnofonts is used when outputting the strings to sort the index
3213
% by, and when constructing control sequence names. It eliminates all
3214
% control sequences and just writes whatever the best ASCII sort string
3215
% would be for a given command (usually its argument).
2266
3217
\def\indexnofonts{%
2267
% Just ignore accents.
2268
\let\,=\indexdummyfont
2269
\let\"=\indexdummyfont
2270
\let\`=\indexdummyfont
2271
\let\'=\indexdummyfont
2272
\let\^=\indexdummyfont
2273
\let\~=\indexdummyfont
2274
\let\==\indexdummyfont
2275
\let\b=\indexdummyfont
2276
\let\c=\indexdummyfont
2277
\let\d=\indexdummyfont
2278
\let\u=\indexdummyfont
2279
\let\v=\indexdummyfont
2280
\let\H=\indexdummyfont
2281
\let\dotless=\indexdummyfont
2282
% Take care of the plain tex special European modified letters.
2294
\let\w=\indexdummyfont
2295
\let\t=\indexdummyfont
2296
\let\r=\indexdummyfont
2297
\let\i=\indexdummyfont
2298
\let\b=\indexdummyfont
2299
\let\emph=\indexdummyfont
2300
\let\strong=\indexdummyfont
2301
\let\cite=\indexdummyfont
2302
\let\sc=\indexdummyfont
2303
%Don't no-op \tt, since it isn't a user-level command
2304
% and is used in the definitions of the active chars like <, >, |...
2305
%\let\tt=\indexdummyfont
2306
\let\tclose=\indexdummyfont
2307
\let\code=\indexdummyfont
2308
\let\file=\indexdummyfont
2309
\let\samp=\indexdummyfont
2310
\let\kbd=\indexdummyfont
2311
\let\key=\indexdummyfont
2312
\let\var=\indexdummyfont
2313
\let\TeX=\indexdummytex
2314
\let\dots=\indexdummydots
3218
\def\definedummyword##1{%
3219
\expandafter\let\csname ##1\endcsname\asis
3221
% We can just ignore the accent commands and other control letters.
3222
\def\definedummyletter##1{%
3223
\expandafter\def\csname ##1\endcsname{}%
3226
\commondummiesnofonts
3228
% Don't no-op \tt, since it isn't a user-level command
3229
% and is used in the definitions of the active chars like <, >, |, etc.
3230
% Likewise with the other plain tex font commands.
3235
% how to handle braces?
3236
\def\_{\normalunderscore}%
3238
% Non-English letters.
3251
\def\questiondown{?}%
3258
% Assorted special characters.
3259
% (The following {} will end up in the sort string, but that's ok.)
3260
\def\bullet{bullet}%
3261
\def\copyright{copyright}%
3262
\def\registeredsymbol{R}%
3267
\def\expansion{==>}%
3269
\def\pounds{pounds}%
2318
% To define \realbackslash, we must make \ not be an escape.
2319
% We must first make another character (@) an escape
2320
% so we do not become unable to do a definition.
2322
{\catcode`\@=0 \catcode`\\=\other
2323
@gdef@realbackslash{\}}
2325
3275
\let\indexbackslash=0 %overridden during \printindex.
2327
\let\SETmarginindex=\relax %initialize!
2328
% workhorse for all \fooindexes
2329
% #1 is name of index, #2 is stuff to put there
3276
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
3278
% Most index entries go through here, but \dosubind is the general case.
3279
% #1 is the index name, #2 is the entry text.
3280
\def\doind#1#2{\dosubind{#1}{#2}{}}
3282
% Workhorse for all \fooindexes.
3283
% #1 is name of index, #2 is stuff to put there, #3 is subentry --
3284
% empty if called from \doind, as we usually are (the main exception
3285
% is with most defuns, which call us directly).
3287
\def\dosubind#1#2#3{%
3290
% Store the main index entry text (including the third arg).
3292
% If third arg is present, precede it with a space.
3294
\ifx\thirdarg\empty \else
3295
\toks0 = \expandafter{\the\toks0 \space #3}%
3298
\edef\writeto{\csname#1indfile\endcsname}%
3309
% Write the entry in \toks0 to the index file:
3311
\def\dosubindwrite{%
2331
3312
% Put the index entry in the margin if desired.
2332
3313
\ifx\SETmarginindex\relax\else
2333
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
3314
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
2336
\count255=\lastpenalty
2338
\indexdummies % Must do this here, since \bf, etc expand at this stage
2341
\let\folio=0% We will expand all macros now EXCEPT \folio.
2342
\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
2343
% so it will be output as is; and it will print as backslash.
2345
% First process the index-string with all font commands turned off
2346
% to get the string to sort by.
2347
{\indexnofonts \xdef\indexsorttmp{#2}}%
2349
% Now produce the complete index entry, with both the sort key and the
2350
% original text, including any font commands.
2353
\write\csname#1indfile\endcsname{%
2354
\realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3317
% Remember, we are within a group.
3318
\indexdummies % Must do this here, since \bf, etc expand at this stage
3320
\def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
3321
% so it will be output as is; and it will print as backslash.
3323
% Process the index entry with all font commands turned off, to
3324
% get the string to sort by.
3326
\edef\temp{\the\toks0}% need full expansion
3327
\xdef\indexsorttmp{\temp}%
3330
% Set up the complete index entry, with both the sort key and
3331
% the original text, including any font commands. We write
3332
% three arguments to \entry to the .?? file (four in the
3333
% subentry case), texindex reduces to two when writing the .??s
3337
\string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
2363
\def\dosubind #1#2#3{%
2364
{\count10=\lastpenalty %
2365
{\indexdummies % Must do this here, since \bf, etc expand at this stage
2368
\def\rawbackslashxx{\indexbackslash}%
2370
% Now process the index-string once, with all font commands turned off,
2371
% to get the string to sort the index by.
2375
% Now produce the complete index entry. We process the index-string again,
2376
% this time with font commands expanded, to get what to print in the index.
2378
\write \csname#1indfile\endcsname{%
2379
\realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
3342
% Take care of unwanted page breaks:
3344
% If a skip is the last thing on the list now, preserve it
3345
% by backing up by \lastskip, doing the \write, then inserting
3346
% the skip again. Otherwise, the whatsit generated by the
3347
% \write will make \lastskip zero. The result is that sequences
3352
% will have extra space inserted, because the \medbreak in the
3353
% start of the @defun won't see the skip inserted by the @end of
3354
% the previous defun.
3356
% But don't do any of this if we're not in vertical mode. We
3357
% don't want to do a \vskip and prematurely end a paragraph.
3359
% Avoid page breaks due to these extra skips, too.
3361
% But wait, there is a catch there:
3362
% We'll have to check whether \lastskip is zero skip. \ifdim is not
3363
% sufficient for this purpose, as it ignores stretch and shrink parts
3364
% of the skip. The only way seems to be to check the textual
3365
% representation of the skip.
3367
% The following is almost like \def\zeroskipmacro{0.0pt} except that
3368
% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
3370
\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
3374
\def\dosubindsanitize{%
3375
% \lastskip and \lastpenalty cannot both be nonzero simultaneously.
3377
\edef\lastskipmacro{\the\lastskip}%
3378
\count255 = \lastpenalty
3380
% If \lastskip is nonzero, that means the last item was a
3381
% skip. And since a skip is discardable, that means this
3382
% -\skip0 glue we're inserting is preceded by a
3383
% non-discardable item, therefore it is not a potential
3384
% breakpoint, therefore no \nobreak needed.
3385
\ifx\lastskipmacro\zeroskipmacro
3392
\ifx\lastskipmacro\zeroskipmacro
3393
% if \lastskip was zero, perhaps the last item was a
3394
% penalty, and perhaps it was >=10000, e.g., a \nobreak.
3395
% In that case, we want to re-insert the penalty; since we
3396
% just inserted a non-discardable item, any following glue
3397
% (such as a \parskip) would be a breakpoint. For example:
3398
% @deffn deffn-whatever
3399
% @vindex index-whatever
3401
% would allow a break between the index-whatever whatsit
3402
% and the "Description." paragraph.
3403
\ifnum\count255>9999 \nobreak \fi
3405
% On the other hand, if we had a nonzero \lastskip,
3406
% this make-up glue would be preceded by a non-discardable item
3407
% (the whatsit from the \write), so we must insert a \nobreak.
3408
\nobreak\vskip\skip0
2383
3412
% The index entry written in the file actually looks like
2384
3413
% \entry {sortstring}{page}{topic}
2717
3842
\def\lowersections{\global\advance\secbase by 1}
2718
3843
\let\down=\lowersections % original BFox name
2720
% Choose a numbered-heading macro
2721
% #1 is heading level if unmodified by @raisesections or @lowersections
2722
% #2 is text for heading
2723
\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2729
\numberedsubseczzz{#2}
2731
\numberedsubsubseczzz{#2}
2733
\ifnum \absseclevel<0
2736
\numberedsubsubseczzz{#2}
2741
% like \numhead, but chooses appendix heading levels
2742
\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2746
\appendixsectionzzz{#2}
2748
\appendixsubseczzz{#2}
2750
\appendixsubsubseczzz{#2}
2752
\ifnum \absseclevel<0
2755
\appendixsubsubseczzz{#2}
2760
% like \numhead, but chooses numberless heading levels
2761
\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2765
\unnumberedseczzz{#2}
2767
\unnumberedsubseczzz{#2}
2769
\unnumberedsubsubseczzz{#2}
2771
\ifnum \absseclevel<0
2774
\unnumberedsubsubseczzz{#2}
2780
\def\thischaptername{No Chapter Title}
2781
\outer\def\chapter{\parsearg\chapteryyy}
2782
\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
2783
\def\chapterzzz #1{\seccheck{chapter}%
2784
\secno=0 \subsecno=0 \subsubsecno=0
2785
\global\advance \chapno by 1 \message{\putwordChapter \the\chapno}%
2786
\chapmacro {#1}{\the\chapno}%
2787
\gdef\thissection{#1}%
2788
\gdef\thischaptername{#1}%
2789
% We don't substitute the actual chapter name into \thischapter
2790
% because we don't want its macros evaluated now.
2791
\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
2794
\edef\temp{{\realbackslash chapentry{\the\toks0}{\the\chapno}{\noexpand\folio}}}%
2796
\write \contentsfile \temp %
2798
\global\let\section = \numberedsec
2799
\global\let\subsection = \numberedsubsec
2800
\global\let\subsubsection = \numberedsubsubsec
2803
\outer\def\appendix{\parsearg\appendixyyy}
2804
\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
2805
\def\appendixzzz #1{\seccheck{appendix}%
2806
\secno=0 \subsecno=0 \subsubsecno=0
2807
\global\advance \appendixno by 1 \message{Appendix \appendixletter}%
2808
\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
2809
\gdef\thissection{#1}%
2810
\gdef\thischaptername{#1}%
2811
\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
2814
\edef\temp{{\realbackslash chapentry{\the\toks0}%
2815
{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
2817
\write \contentsfile \temp %
2819
\global\let\section = \appendixsec
2820
\global\let\subsection = \appendixsubsec
2821
\global\let\subsubsection = \appendixsubsubsec
3845
% we only have subsub.
3846
\chardef\maxseclevel = 3
3848
% A numbered section within an unnumbered changes to unnumbered too.
3849
% To achive this, remember the "biggest" unnum. sec. we are currently in:
3850
\chardef\unmlevel = \maxseclevel
3852
% Trace whether the current chapter is an appendix or not:
3853
% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
3854
\def\chapheadtype{N}
3856
% Choose a heading macro
3857
% #1 is heading type
3858
% #2 is heading level
3859
% #3 is text for heading
3860
\def\genhead#1#2#3{%
3861
% Compute the abs. sec. level:
3863
\advance\absseclevel by \secbase
3864
% Make sure \absseclevel doesn't fall outside the range:
3865
\ifnum \absseclevel < 0
3868
\ifnum \absseclevel > 3
3875
\ifnum \absseclevel < \unmlevel
3876
\chardef\unmlevel = \absseclevel
3879
% Check for appendix sections:
3880
\ifnum \absseclevel = 0
3881
\edef\chapheadtype{\headtype}%
3883
\if \headtype A\if \chapheadtype N%
3884
\errmessage{@appendix... within a non-appendix chapter}%
3887
% Check for numbered within unnumbered:
3888
\ifnum \absseclevel > \unmlevel
3891
\chardef\unmlevel = 3
3894
% Now print the heading:
3898
\or \unnumberedseczzz{#3}%
3899
\or \unnumberedsubseczzz{#3}%
3900
\or \unnumberedsubsubseczzz{#3}%
3906
\or \appendixsectionzzz{#3}%
3907
\or \appendixsubseczzz{#3}%
3908
\or \appendixsubsubseczzz{#3}%
3914
\or \numberedsubseczzz{#3}%
3915
\or \numberedsubsubseczzz{#3}%
3919
\suppressfirstparagraphindent
3923
\def\numhead{\genhead N}
3924
\def\apphead{\genhead A}
3925
\def\unnmhead{\genhead U}
3927
% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
3928
% all lower-level sectioning counters to zero.
3930
% Also set \chaplevelprefix, which we prepend to @float sequence numbers
3931
% (e.g., figures), q.v. By default (before any chapter), that is empty.
3932
\let\chaplevelprefix = \empty
3934
\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
3936
% section resetting is \global in case the chapter is in a group, such
3937
% as an @include file.
3938
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3939
\global\advance\chapno by 1
3942
\gdef\chaplevelprefix{\the\chapno.}%
3945
\message{\putwordChapter\space \the\chapno}%
3947
% Write the actual heading.
3948
\chapmacro{#1}{Ynumbered}{\the\chapno}%
3950
% So @section and the like are numbered underneath this chapter.
3951
\global\let\section = \numberedsec
3952
\global\let\subsection = \numberedsubsec
3953
\global\let\subsubsection = \numberedsubsubsec
3956
\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
3957
\def\appendixzzz#1{%
3958
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3959
\global\advance\appendixno by 1
3960
\gdef\chaplevelprefix{\appendixletter.}%
3963
\def\appendixnum{\putwordAppendix\space \appendixletter}%
3964
\message{\appendixnum}%
3966
\chapmacro{#1}{Yappendix}{\appendixletter}%
3968
\global\let\section = \appendixsec
3969
\global\let\subsection = \appendixsubsec
3970
\global\let\subsubsection = \appendixsubsubsec
3973
\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3974
\def\unnumberedzzz#1{%
3975
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3976
\global\advance\unnumberedno by 1
3978
% Since an unnumbered has no number, no prefix for figures.
3979
\global\let\chaplevelprefix = \empty
3982
% This used to be simply \message{#1}, but TeX fully expands the
3983
% argument to \message. Therefore, if #1 contained @-commands, TeX
3984
% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
3985
% expanded @cite (which turns out to cause errors because \cite is meant
3986
% to be executed, not expanded).
3988
% Anyway, we don't want the fully-expanded definition of @cite to appear
3989
% as a result of the \message, we just want `@cite' itself. We use
3990
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
3991
% simply yielding the contents of <toks register>. (We also do this for
3994
\message{(\the\toks0)}%
3996
\chapmacro{#1}{Ynothing}{\the\unnumberedno}%
3998
\global\let\section = \unnumberedsec
3999
\global\let\subsection = \unnumberedsubsec
4000
\global\let\subsubsection = \unnumberedsubsubsec
2824
4003
% @centerchap is like @unnumbered, but the heading is centered.
2825
\outer\def\centerchap{\parsearg\centerchapyyy}
2826
\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
2828
\outer\def\top{\parsearg\unnumberedyyy}
2829
\outer\def\unnumbered{\parsearg\unnumberedyyy}
2830
\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
2831
\def\unnumberedzzz #1{\seccheck{unnumbered}%
2832
\secno=0 \subsecno=0 \subsubsecno=0
2834
% This used to be simply \message{#1}, but TeX fully expands the
2835
% argument to \message. Therefore, if #1 contained @-commands, TeX
2836
% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
2837
% expanded @cite (which turns out to cause errors because \cite is meant
2838
% to be executed, not expanded).
2840
% Anyway, we don't want the fully-expanded definition of @cite to appear
2841
% as a result of the \message, we just want `@cite' itself. We use
2842
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
2843
% simply yielding the contents of the <toks register>.
2844
\toks0 = {#1}\message{(\the\toks0)}%
2846
\unnumbchapmacro {#1}%
2847
\gdef\thischapter{#1}\gdef\thissection{#1}%
2850
\edef\temp{{\realbackslash unnumbchapentry{\the\toks0}{\noexpand\folio}}}%
2852
\write \contentsfile \temp %
2854
\global\let\section = \unnumberedsec
2855
\global\let\subsection = \unnumberedsubsec
2856
\global\let\subsubsection = \unnumberedsubsubsec
2859
\outer\def\numberedsec{\parsearg\secyyy}
2860
\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
2861
\def\seczzz #1{\seccheck{section}%
2862
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2863
\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
2866
\edef\temp{{\realbackslash secentry %
2867
{\the\toks0}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
2869
\write \contentsfile \temp %
2874
\outer\def\appendixsection{\parsearg\appendixsecyyy}
2875
\outer\def\appendixsec{\parsearg\appendixsecyyy}
2876
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
2877
\def\appendixsectionzzz #1{\seccheck{appendixsection}%
2878
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2879
\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
2882
\edef\temp{{\realbackslash secentry %
2883
{\the\toks0}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
2885
\write \contentsfile \temp %
2890
\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
2891
\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
2892
\def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
2893
\plainsecheading {#1}\gdef\thissection{#1}%
2896
\edef\temp{{\realbackslash unnumbsecentry{\the\toks0}{\noexpand\folio}}}%
2898
\write \contentsfile \temp %
2903
\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
2904
\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
2905
\def\numberedsubseczzz #1{\seccheck{subsection}%
2906
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2907
\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
2910
\edef\temp{{\realbackslash subsecentry %
2911
{\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2913
\write \contentsfile \temp %
2918
\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
2919
\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
2920
\def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
2921
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2922
\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
2925
\edef\temp{{\realbackslash subsecentry %
2926
{\the\toks0}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2928
\write \contentsfile \temp %
2933
\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
2934
\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
2935
\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
2936
\plainsubsecheading {#1}\gdef\thissection{#1}%
2939
\edef\temp{{\realbackslash unnumbsubsecentry{\the\toks0}{\noexpand\folio}}}%
2941
\write \contentsfile \temp %
2946
\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
2947
\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
2948
\def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
2949
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2950
\subsubsecheading {#1}
2951
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2954
\edef\temp{{\realbackslash subsubsecentry{\the\toks0}
2955
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
2956
{\noexpand\folio}}}%
2958
\write \contentsfile \temp %
2963
\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
2964
\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
2965
\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
2966
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2967
\subsubsecheading {#1}
2968
{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2971
\edef\temp{{\realbackslash subsubsecentry{\the\toks0}%
2973
{\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
2975
\write \contentsfile \temp %
2980
\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
2981
\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
2982
\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
2983
\plainsubsubsecheading {#1}\gdef\thissection{#1}%
2986
\edef\temp{{\realbackslash unnumbsubsubsecentry{\the\toks0}{\noexpand\folio}}}%
2988
\write \contentsfile \temp %
2993
% These are variants which are not "outer", so they can appear in @ifinfo.
2994
% Actually, they should now be obsolete; ordinary section commands should work.
2995
\def\infotop{\parsearg\unnumberedzzz}
2996
\def\infounnumbered{\parsearg\unnumberedzzz}
2997
\def\infounnumberedsec{\parsearg\unnumberedseczzz}
2998
\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
2999
\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3001
\def\infoappendix{\parsearg\appendixzzz}
3002
\def\infoappendixsec{\parsearg\appendixseczzz}
3003
\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3004
\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3006
\def\infochapter{\parsearg\chapterzzz}
3007
\def\infosection{\parsearg\sectionzzz}
3008
\def\infosubsection{\parsearg\subsectionzzz}
3009
\def\infosubsubsection{\parsearg\subsubsectionzzz}
4004
\outer\parseargdef\centerchap{%
4005
% Well, we could do the following in a group, but that would break
4006
% an assumption that \chapmacro is called at the outermost level.
4007
% Thus we are safer this way: --kasal, 24feb04
4008
\let\centerparametersmaybe = \centerparameters
4010
\let\centerparametersmaybe = \relax
4013
% @top is like @unnumbered.
4017
\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
4019
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4020
\sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
4023
\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
4024
\def\appendixsectionzzz#1{%
4025
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4026
\sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
4028
\let\appendixsec\appendixsection
4030
\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
4031
\def\unnumberedseczzz#1{%
4032
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4033
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
4037
\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
4038
\def\numberedsubseczzz#1{%
4039
\global\subsubsecno=0 \global\advance\subsecno by 1
4040
\sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
4043
\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
4044
\def\appendixsubseczzz#1{%
4045
\global\subsubsecno=0 \global\advance\subsecno by 1
4046
\sectionheading{#1}{subsec}{Yappendix}%
4047
{\appendixletter.\the\secno.\the\subsecno}%
4050
\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
4051
\def\unnumberedsubseczzz#1{%
4052
\global\subsubsecno=0 \global\advance\subsecno by 1
4053
\sectionheading{#1}{subsec}{Ynothing}%
4054
{\the\unnumberedno.\the\secno.\the\subsecno}%
4058
\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
4059
\def\numberedsubsubseczzz#1{%
4060
\global\advance\subsubsecno by 1
4061
\sectionheading{#1}{subsubsec}{Ynumbered}%
4062
{\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
4065
\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
4066
\def\appendixsubsubseczzz#1{%
4067
\global\advance\subsubsecno by 1
4068
\sectionheading{#1}{subsubsec}{Yappendix}%
4069
{\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
4072
\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
4073
\def\unnumberedsubsubseczzz#1{%
4074
\global\advance\subsubsecno by 1
4075
\sectionheading{#1}{subsubsec}{Ynothing}%
4076
{\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
3011
4079
% These macros control what the section commands do, according
3012
4080
% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3013
4081
% Define them by default for a numbered chapter.
3014
\global\let\section = \numberedsec
3015
\global\let\subsection = \numberedsubsec
3016
\global\let\subsubsection = \numberedsubsubsec
4082
\let\section = \numberedsec
4083
\let\subsection = \numberedsubsec
4084
\let\subsubsection = \numberedsubsubsec
3018
4086
% Define @majorheading, @heading and @subheading
3020
% NOTE on use of \vbox for chapter headings, section headings, and
4088
% NOTE on use of \vbox for chapter headings, section headings, and such:
3022
4089
% 1) We use \vbox rather than the earlier \line to permit
3023
4090
% overlong headings to fold.
3024
4091
% 2) \hyphenpenalty is set to 10000 because hyphenation in a
3088
\global\let\chapmacro=\chfplain
3089
\global\let\unnumbchapmacro=\unnchfplain
3090
\global\let\centerchapmacro=\centerchfplain}
3092
% Plain chapter opening.
3093
% #1 is the text, #2 the chapter number or empty if unnumbered.
4158
% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
4159
% Yappendix, Yomitfromtoc), #3 the chapter number.
4161
% To test against our argument.
4162
\def\Ynothingkeyword{Ynothing}
4163
\def\Yomitfromtockeyword{Yomitfromtoc}
4164
\def\Yappendixkeyword{Yappendix}
4166
\def\chapmacro#1#2#3{%
3099
\setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
4171
% Have to define \thissection before calling \donoderef, because the
4172
% xref code eventually uses it. On the other hand, it has to be called
4173
% after \pchapsepmacro, or the headline will change too soon.
4174
\gdef\thissection{#1}%
4175
\gdef\thischaptername{#1}%
4177
% Only insert the separating space if we have a chapter/appendix
4178
% number, and don't print the unnumbered ``number''.
4180
\ifx\temptype\Ynothingkeyword
4182
\def\toctype{unnchap}%
4183
\def\thischapter{#1}%
4184
\else\ifx\temptype\Yomitfromtockeyword
4185
\setbox0 = \hbox{}% contents like unnumbered, but no toc entry
4187
\xdef\thischapter{}%
4188
\else\ifx\temptype\Yappendixkeyword
4189
\setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
4191
% We don't substitute the actual chapter name into \thischapter
4192
% because we don't want its macros evaluated now. And we don't
4193
% use \thissection because that changes with each section.
4195
\xdef\thischapter{\putwordAppendix{} \appendixletter:
4196
\noexpand\thischaptername}%
4198
\setbox0 = \hbox{#3\enspace}%
4199
\def\toctype{numchap}%
4200
\xdef\thischapter{\putwordChapter{} \the\chapno:
4201
\noexpand\thischaptername}%
4204
% Write the toc entry for this chapter. Must come before the
4205
% \donoderef, because we include the current node name in the toc
4206
% entry, and \donoderef resets it to empty.
4207
\writetocentry{\toctype}{#1}{#3}%
4209
% For pdftex, we have to write out the node definition (aka, make
4210
% the pdfdest) after any page break, but before the actual text has
4211
% been typeset. If the destination for the pdf outline is after the
4212
% text, then jumping from the outline may wind up with the text not
4213
% being visible, for instance under high magnification.
4216
% Typeset the actual heading.
3100
4217
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3101
\hangindent = \wd0 \centerparametersmaybe
4218
\hangindent=\wd0 \centerparametersmaybe
3102
4219
\unhbox0 #1\par}%
3104
4221
\nobreak\bigskip % no page break after a chapter title
3108
% Plain opening for unnumbered.
3109
\def\unnchfplain#1{\chfplain{#1}{}}
3111
4225
% @centerchap -- centered and unnumbered.
3112
4226
\let\centerparametersmaybe = \relax
3113
\def\centerchfplain#1{{%
3114
\def\centerparametersmaybe{%
3115
\advance\rightskip by 3\rightskip
3116
\leftskip = \rightskip
3122
\CHAPFplain % The default
4227
\def\centerparameters{%
4228
\advance\rightskip by 3\rightskip
4229
\leftskip = \rightskip
4234
% I don't think this chapter style is supported any more, so I'm not
4235
% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
4237
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3124
4239
\def\unnchfopen #1{%
3125
4240
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3126
4241
\parindent=0pt\raggedright
3127
\rm #1\hfill}}\bigskip \par\penalty 10000 %
4242
\rm #1\hfill}}\bigskip \par\nobreak
3130
4244
\def\chfopen #1#2{\chapoddpage {\chapfonts
3131
4245
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3132
4246
\par\penalty 5000 %
3135
4248
\def\centerchfopen #1{%
3136
4249
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3138
\hfill {\rm #1}\hfill}}\bigskip \par\penalty 10000 %
4251
\hfill {\rm #1}\hfill}}\bigskip \par\nobreak
3142
\global\let\chapmacro=\chfopen
3143
\global\let\unnumbchapmacro=\unnchfopen
3144
\global\let\centerchapmacro=\centerchfopen}
4254
\global\let\chapmacro=\chfopen
4255
\global\let\centerchapmacro=\centerchfopen}
4258
% Section titles. These macros combine the section number parts and
4259
% call the generic \sectionheading to do the printing.
3148
4261
\newskip\secheadingskip
3149
\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
3150
\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3151
\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
4262
\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
3153
4264
% Subsection titles.
3154
\newskip \subsecheadingskip
3155
\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
3156
\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3157
\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
4265
\newskip\subsecheadingskip
4266
\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
3159
4268
% Subsubsection titles.
3160
\let\subsubsecheadingskip = \subsecheadingskip
3161
\let\subsubsecheadingbreak = \subsecheadingbreak
3162
\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3163
\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3166
% Print any size section title.
3168
% #1 is the section type (sec/subsec/subsubsec), #2 is the section
3169
% number (maybe empty), #3 the text.
3170
\def\sectionheading#1#2#3{%
3172
\expandafter\advance\csname #1headingskip\endcsname by \parskip
3173
\csname #1headingbreak\endcsname
4269
\def\subsubsecheadingskip{\subsecheadingskip}
4270
\def\subsubsecheadingbreak{\subsecheadingbreak}
4273
% Print any size, any type, section title.
4275
% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
4276
% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
4279
\def\sectionheading#1#2#3#4{%
3176
4281
% Switch to the right set of fonts.
3177
\csname #1fonts\endcsname \rm
3179
% Only insert the separating space if we have a section number.
3181
\setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
4282
\csname #2fonts\endcsname \rm
4284
% Insert space above the heading.
4285
\csname #2headingbreak\endcsname
4287
% Only insert the space after the number if we have a section number.
4288
\def\sectionlevel{#2}%
4291
\ifx\temptype\Ynothingkeyword
4294
\gdef\thissection{#1}%
4295
\else\ifx\temptype\Yomitfromtockeyword
4296
% for @headings -- no section number, don't include in toc,
4297
% and don't redefine \thissection.
4300
\let\sectionlevel=\empty
4301
\else\ifx\temptype\Yappendixkeyword
4302
\setbox0 = \hbox{#4\enspace}%
4304
\gdef\thissection{#1}%
4306
\setbox0 = \hbox{#4\enspace}%
4308
\gdef\thissection{#1}%
4311
% Write the toc entry (before \donoderef). See comments in \chfplain.
4312
\writetocentry{\toctype\sectionlevel}{#1}{#4}%
4314
% Write the node reference (= pdf destination for pdftex).
4315
% Again, see comments in \chfplain.
4318
% Output the actual section heading.
3183
4319
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3184
\hangindent = \wd0 % zero if no section number
4320
\hangindent=\wd0 % zero if no section number
3187
\ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
3191
\message{toc printing,}
3192
% Finish up the main text and prepare to read what we've written
4323
% Add extra space after the heading -- half of whatever came above it.
4324
% Don't allow stretch, though.
4325
\kern .5 \csname #2headingskip\endcsname
4327
% Do not let the kern be a potential breakpoint, as it would be if it
4328
% was followed by glue.
4331
% We'll almost certainly start a paragraph next, so don't let that
4332
% glue accumulate. (Not a breakpoint because it's preceded by a
4333
% discardable item.)
4336
% This \nobreak is purely so the last item on the list is a \penalty
4337
% of 10000. This is so other code, for instance \parsebodycommon, can
4338
% check for and avoid allowing breakpoints. Otherwise, it would
4339
% insert a valid breakpoint between:
4340
% @section sec-whatever
4341
% @deffn def-whatever
4347
% Table of contents.
4350
% Write an entry to the toc file, opening it if necessary.
4351
% Called from @chapter, etc.
4353
% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
4354
% We append the current node name (if any) and page number as additional
4355
% arguments for the \{chap,sec,...}entry macros which will eventually
4356
% read this. The node name is used in the pdf outlines as the
4357
% destination to jump to.
4359
% We open the .toc file for writing here instead of at @setfilename (or
4360
% any other fixed time) so that @contents can be anywhere in the document.
4361
% But if #1 is `omit', then we don't do anything. This is used for the
4362
% table of contents chapter openings themselves.
4364
\newif\iftocfileopened
4365
\def\omitkeyword{omit}%
4367
\def\writetocentry#1#2#3{%
4368
\edef\writetoctype{#1}%
4369
\ifx\writetoctype\omitkeyword \else
4370
\iftocfileopened\else
4371
\immediate\openout\tocfile = \jobname.toc
4372
\global\tocfileopenedtrue
4377
\toks2 = \expandafter{\lastnode}%
4378
\edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}{#3}%
4379
{\the\toks2}{\noexpand\folio}}}%
4384
% Tell \shipout to create a pdf destination on each page, if we're
4385
% writing pdf. These are used in the table of contents. We can't
4386
% just write one on every page because the title pages are numbered
4387
% 1 and 2 (the page numbers aren't printed), and so are the first
4388
% two pages of the document. Thus, we'd have two destinations named
4389
% `1', and two named `2'.
4390
\ifpdf \global\pdfmakepagedesttrue \fi
3195
4393
\newskip\contentsrightmargin \contentsrightmargin=1in
4394
\newcount\savepageno
4395
\newcount\lastnegativepageno \lastnegativepageno = -1
4397
% Prepare to read what we've written to \tocfile.
3196
4399
\def\startcontents#1{%
3197
% If @setchapternewpage on, and @headings double, the contents should
3198
% start on an odd page, unlike chapters. Thus, we maintain
3199
% \contentsalignmacro in parallel with \pagealignmacro.
3200
% From: Torbjorn Granlund <tege@matematik.su.se>
3202
\immediate\closeout \contentsfile
3204
\pageno = -1 % Request roman numbered pages.
3206
% Don't need to put `Contents' or `Short Contents' in the headline.
3207
% It is abundantly clear what they are.
3208
\unnumbchapmacro{#1}\def\thischapter{}%
3209
\begingroup % Set up to handle contents files properly.
3210
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
3211
\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
3212
\raggedbottom % Worry more about breakpoints than the bottom.
3213
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4400
% If @setchapternewpage on, and @headings double, the contents should
4401
% start on an odd page, unlike chapters. Thus, we maintain
4402
% \contentsalignmacro in parallel with \pagealignmacro.
4403
% From: Torbjorn Granlund <tege@matematik.su.se>
4405
\immediate\closeout\tocfile
4407
% Don't need to put `Contents' or `Short Contents' in the headline.
4408
% It is abundantly clear what they are.
4410
\chapmacro{#1}{Yomitfromtoc}{}%
4412
\savepageno = \pageno
4413
\begingroup % Set up to handle contents files properly.
4414
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
4415
% We can't do this, because then an actual ^ in a section
4416
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
4417
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
4418
\raggedbottom % Worry more about breakpoints than the bottom.
4419
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4421
% Roman numerals for page numbers.
4422
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
3217
4426
% Normal (long) toc.
3218
\outer\def\contents{%
3219
\startcontents{\putwordTableofContents}%
4428
\startcontents{\putwordTOC}%
4429
\openin 1 \jobname.toc
3220
4431
\input \jobname.toc
4434
\contentsalignmacro % in case @setchapternewpage odd is in effect
4440
\lastnegativepageno = \pageno
4441
\global\pageno = \savepageno
3225
4444
% And just the chapters.
3226
\outer\def\summarycontents{%
3227
\startcontents{\putwordShortContents}%
3229
\let\chapentry = \shortchapentry
3230
\let\unnumbchapentry = \shortunnumberedentry
3231
% We want a true roman here for the page numbers.
3233
\let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
3235
\hyphenpenalty = 10000
3236
\advance\baselineskip by 1pt % Open it up a little.
3237
\def\secentry ##1##2##3##4{}
3238
\def\unnumbsecentry ##1##2{}
3239
\def\subsecentry ##1##2##3##4##5{}
3240
\def\unnumbsubsecentry ##1##2{}
3241
\def\subsubsecentry ##1##2##3##4##5##6{}
3242
\def\unnumbsubsubsecentry ##1##2{}
4445
\def\summarycontents{%
4446
\startcontents{\putwordShortTOC}%
4448
\let\numchapentry = \shortchapentry
4449
\let\appentry = \shortchapentry
4450
\let\unnchapentry = \shortunnchapentry
4451
% We want a true roman here for the page numbers.
4453
\let\rm=\shortcontrm \let\bf=\shortcontbf
4454
\let\sl=\shortcontsl \let\tt=\shortconttt
4456
\hyphenpenalty = 10000
4457
\advance\baselineskip by 1pt % Open it up a little.
4458
\def\numsecentry##1##2##3##4{}
4459
\let\appsecentry = \numsecentry
4460
\let\unnsecentry = \numsecentry
4461
\let\numsubsecentry = \numsecentry
4462
\let\appsubsecentry = \numsecentry
4463
\let\unnsubsecentry = \numsecentry
4464
\let\numsubsubsecentry = \numsecentry
4465
\let\appsubsubsecentry = \numsecentry
4466
\let\unnsubsubsecentry = \numsecentry
4467
\openin 1 \jobname.toc
3243
4469
\input \jobname.toc
4473
\contentsalignmacro % in case @setchapternewpage odd is in effect
4475
\lastnegativepageno = \pageno
4476
\global\pageno = \savepageno
3247
4478
\let\shortcontents = \summarycontents
3249
% These macros generate individual entries in the table of contents.
3250
% The first argument is the chapter or section name.
3251
% The last argument is the page number.
3252
% The arguments in between are the chapter number, section number, ...
3254
% Chapter-level things, for both the long and short contents.
3255
\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
3257
% See comments in \dochapentry re vbox and related settings
3258
\def\shortchapentry#1#2#3{%
3259
\tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
3262
4480
% Typeset the label for a chapter or appendix for the short contents.
3263
% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
3264
% We could simplify the code here by writing out an \appendixentry
3265
% command in the toc file for appendices, instead of using \chapentry
3266
% for both, but it doesn't seem worth it.
3267
\setbox0 = \hbox{\shortcontrm \putwordAppendix }
3268
\newdimen\shortappendixwidth \shortappendixwidth = \wd0
4481
% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
3270
4483
\def\shortchaplabel#1{%
3271
% We typeset #1 in a box of constant width, regardless of the text of
3272
% #1, so the chapter titles will come out aligned.
3273
\setbox0 = \hbox{#1}%
3274
\dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
3276
% This space should be plenty, since a single number is .5em, and the
4484
% This space should be enough, since a single number is .5em, and the
3277
4485
% widest letter (M) is 1em, at least in the Computer Modern fonts.
4486
% But use \hss just in case.
3278
4487
% (This space doesn't include the extra space that gets added after
3279
4488
% the label; that gets put in by \shortchapentry above.)
3280
\advance\dimen0 by 1.1em
3281
\hbox to \dimen0{#1\hfil}%
3284
\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
3285
\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
4490
% We'd like to right-justify chapter numbers, but that looks strange
4491
% with appendix letters. And right-justifying numbers and
4492
% left-justifying letters looks strange when there is less than 10
4493
% chapters. Have to read the whole toc once to know how many chapters
4494
% there are before deciding ...
4495
\hbox to 1em{#1\hss}%
4498
% These macros generate individual entries in the table of contents.
4499
% The first argument is the chapter or section name.
4500
% The last argument is the page number.
4501
% The arguments in between are the chapter number, section number, ...
4503
% Chapters, in the main contents.
4504
\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
4506
% Chapters, in the short toc.
4507
% See comments in \dochapentry re vbox and related settings.
4508
\def\shortchapentry#1#2#3#4{%
4509
\tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
4512
% Appendices, in the main contents.
4513
% Need the word Appendix, and a fixed-size box.
4515
\def\appendixbox#1{%
4516
% We use M since it's probably the widest letter.
4517
\setbox0 = \hbox{\putwordAppendix{} M}%
4518
\hbox to \wd0{\putwordAppendix{} #1\hss}}
4520
\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
4522
% Unnumbered chapters.
4523
\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
4524
\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
3288
\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
3289
\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
4527
\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
4528
\let\appsecentry=\numsecentry
4529
\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
3292
\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
3293
\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
4532
\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
4533
\let\appsubsecentry=\numsubsecentry
4534
\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
3295
4536
% And subsubsections.
3296
\def\subsubsecentry#1#2#3#4#5#6{%
3297
\dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
3298
\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
4537
\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
4538
\let\appsubsubsecentry=\numsubsubsecentry
4539
\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
3300
4541
% This parameter controls the indentation of the various levels.
3301
\newdimen\tocindent \tocindent = 3pc
4542
% Same as \defaultparindent.
4543
\newdimen\tocindent \tocindent = 15pt
3303
4545
% Now for the actual typesetting. In all these, #1 is the text and #2 is the
3647
4883
\exdentamount = \lispnarrowing
3648
4884
\let\nonarrowing = \relax
4886
\parsearg\quotationlabel
4889
% We have retained a nonzero parskip for the environment, since we're
4890
% doing normal filling.
4894
\ifx\quotationauthor\undefined\else
4896
\leftline{\kern 2\leftskip \sl ---\quotationauthor}%
4898
{\parskip=0pt \afterenvbreak}%
4901
% If we're given an argument, typeset it in bold with a colon after.
4902
\def\quotationlabel#1{%
4904
\ifx\temp\empty \else
4910
% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
4911
% If we want to allow any <char> as delimiter,
4912
% we need the curly braces so that makeinfo sees the @verb command, eg:
4913
% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
4915
% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
4917
% [Knuth] p.344; only we need to do the other characters Texinfo sets
4918
% active too. Otherwise, they get lost as the first character on a
4921
\do\ \do\\\do\{\do\}\do\$\do\&%
4922
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
4923
\do\<\do\>\do\|\do\@\do+\do\"%
4927
\def\uncatcodespecials{%
4928
\def\do##1{\catcode`##1=\other}\dospecials}
4930
% [Knuth] pp. 380,381,391
4931
% Disable Spanish ligatures ?` and !` of \tt font
4933
\catcode`\`=\active\gdef`{\relax\lq}
4936
% Setup for the @verb command.
4938
% Eight spaces for a tab
4940
\catcode`\^^I=\active
4941
\gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
4945
\tt % easiest (and conventionally used) font for verbatim
4946
\def\par{\leavevmode\endgraf}%
4949
% Respect line breaks,
4950
% print special symbols as themselves, and
4951
% make each space count
4952
% must do in this order:
4953
\obeylines \uncatcodespecials \sepspaces
4956
% Setup for the @verbatim environment
4958
% Real tab expansion
4959
\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
4961
\def\starttabbox{\setbox0=\hbox\bgroup}
4963
\catcode`\^^I=\active
4965
\catcode`\^^I=\active
4966
\def^^I{\leavevmode\egroup
4967
\dimen0=\wd0 % the width so far, or since the previous tab
4968
\divide\dimen0 by\tabw
4969
\multiply\dimen0 by\tabw % compute previous multiple of \tabw
4970
\advance\dimen0 by\tabw % advance to next multiple of \tabw
4971
\wd0=\dimen0 \box0 \starttabbox
4975
\def\setupverbatim{%
4977
\advance\leftskip by -\defbodyindent
4978
% Easiest (and conventionally used) font for verbatim
4980
\def\par{\leavevmode\egroup\box0\endgraf}%
4983
% Respect line breaks,
4984
% print special symbols as themselves, and
4985
% make each space count
4986
% must do in this order:
4987
\obeylines \uncatcodespecials \sepspaces
4988
\everypar{\starttabbox}%
4991
% Do the @verb magic: verbatim text is quoted by unique
4992
% delimiter characters. Before first delimiter expect a
4993
% right brace, after last delimiter expect closing brace:
4995
% \def\doverb'{'<char>#1<char>'}'{#1}
4997
% [Knuth] p. 382; only eat outer {}
4999
\catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
5000
\gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
5003
\def\verb{\begingroup\setupverb\doverb}
5006
% Do the @verbatim magic: define the macro \doverbatim so that
5007
% the (first) argument ends when '@end verbatim' is reached, ie:
5009
% \def\doverbatim#1@end verbatim{#1}
5011
% For Texinfo it's a lot easier than for LaTeX,
5012
% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
5013
% we need not redefine '\', '{' and '}'.
5015
% Inspired by LaTeX's verbatim command set [latex.ltx]
5020
% ignore everything up to the first ^^M, that's the newline at the end
5021
% of the @verbatim input line itself. Otherwise we get an extra blank
5022
% line in the output.
5023
\xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
5024
% We really want {...\end verbatim} in the body of the macro, but
5025
% without the active space; thus we have to use \xdef and \gobble.
5029
\setupverbatim\doverbatim
5031
\let\Everbatim = \afterenvbreak
5034
% @verbatiminclude FILE - insert text of file in verbatim environment.
5036
\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
5038
\def\doverbatiminclude#1{%
5040
\makevalueexpandable
5047
% @copying ... @end copying.
5048
% Save the text away for @insertcopying later. Many commands won't be
5049
% allowed in this context, but that's ok.
5051
% We save the uninterpreted tokens, rather than creating a box.
5052
% Saving the text in a box would be much easier, but then all the
5053
% typesetting commands (@smallbook, font changes, etc.) have to be done
5054
% beforehand -- and a) we want @copying to be done first in the source
5055
% file; b) letting users define the frontmatter in as flexible order as
5056
% possible is very desirable.
5058
\def\copying{\begingroup
5059
% Define a command to swallow text until we reach `@end copying'.
5060
% \ is the escape char in this texinfo.tex file, so it is the
5061
% delimiter for the command; @ will be the escape char when we read
5062
% it, but that doesn't matter.
5063
\long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}%
5065
% We must preserve ^^M's in the input file; see \insertcopying below.
5066
\catcode`\^^M = \active
5070
% What we do to finish off the copying text.
5072
\def\enddocopying{\endgroup\ignorespaces}
5074
% @insertcopying. Here we must play games with ^^M's. On the one hand,
5075
% we need them to delimit commands such as `@end quotation', so they
5076
% must be active. On the other hand, we certainly don't want every
5077
% end-of-line to be a \par, as would happen with the normal active
5078
% definition of ^^M. On the third hand, two ^^M's in a row should still
5081
% Our approach is to make ^^M insert a space and a penalty1 normally;
5082
% then it can also check if \lastpenalty=1. If it does, then manually
5085
% This messes up the normal definitions of @c[omment], so we redefine
5086
% it. Similarly for @ignore. (These commands are used in the gcc
5087
% manual for man page generation.)
5089
% Seems pretty fragile, most line-oriented commands will presumably
5090
% fail, but for the limited use of getting the copying text (which
5091
% should be quite simple) inserted, we can hope it's ok.
5093
{\catcode`\^^M=\active %
5094
\gdef\insertcopying{\begingroup %
5095
\parindent = 0pt % looks wrong on title page
5097
\ifnum \lastpenalty=1 %
5104
% Fix @c[omment] for catcode 13 ^^M's.
5105
\def\c##1^^M{\ignorespaces}%
5108
% Don't bother jumping through all the hoops that \doignore does, it
5109
% would be very hard since the catcodes are already set.
5110
\long\def\ignore##1\end ignore{\ignorespaces}%
3652
5116
\message{defuns,}
3653
% Define formatter for defuns
3654
% First, allow user to change definition object font (\df) internally
3655
\def\setdeffont #1 {\csname DEF#1\endcsname}
3657
5119
\newskip\defbodyindent \defbodyindent=.4in
3658
5120
\newskip\defargsindent \defargsindent=50pt
3659
\newskip\deftypemargin \deftypemargin=12pt
3660
5121
\newskip\deflastargmargin \deflastargmargin=18pt
3662
\newcount\parencount
3663
% define \functionparens, which makes ( and ) and & do special things.
3664
% \functionparens affects the group it is contained in.
5123
% Start the processing of @deffn:
5125
\ifnum\lastpenalty<10000
5128
% If there are two @def commands in a row, we'll have a \nobreak,
5129
% which is there to keep the function description together with its
5130
% header. But if there's nothing but headers, we need to allow a
5131
% break somewhere. Check for penalty 10002 (inserted by
5132
% \defargscommonending) instead of 10000, since the sectioning
5133
% commands insert a \penalty10000, and we don't want to allow a break
5134
% between a section heading and a defun.
5135
\ifnum\lastpenalty=10002 \penalty2000 \fi
5137
% Similarly, after a section heading, do not allow a break.
5138
% But do insert the glue.
5139
\medskip % preceded by discardable penalty, so not a breakpoint
5143
\advance\leftskip by \defbodyindent
5144
\exdentamount=\defbodyindent
5148
% First, check whether we are in the right environment:
5151
% As above, allow line break if we have multiple x headers in a row.
5152
% It's not a great place, though.
5153
\ifnum\lastpenalty=10002 \penalty3000 \fi
5155
% And now, it's time to reuse the body of the original defun:
5156
\expandafter\gobbledefun#1%
5158
\def\gobbledefun#1\startdefun{}
5160
% \printdefunline \deffnheader{text}
5162
\def\printdefunline#1#2{%
5164
% call \deffnheader:
5167
\interlinepenalty = 10000
5168
\advance\rightskip by 0pt plus 1fil
5170
\nobreak\vskip -\parskip
5171
\penalty 10002 % signal to \startdefun and \dodefunx
5172
% Some of the @defun-type tags do not enable magic parentheses,
5173
% rendering the following check redundant. But we don't optimize.
5178
\def\Edefun{\endgraf\medbreak}
5180
% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
5181
% the only thing remainnig is to define \deffnheader.
5184
\expandafter\let\csname E#1\endcsname = \Edefun
5185
\edef\temp{\noexpand\domakedefun
5186
\makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
5190
% \domakedefun \deffn \deffnx \deffnheader
5192
% Define \deffn and \deffnx, without parameters.
5193
% \deffnheader has to be defined explicitly.
5195
\def\domakedefun#1#2#3{%
5198
\parseargusing\activeparens{\printdefunline#3}%
5200
\def#2{\dodefunx#1}%
5204
%%% Untyped functions:
5206
% @deffn category name args
5207
\makedefun{deffn}{\deffngeneral{}}
5209
% @deffn category class name args
5210
\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
5212
% \defopon {category on}class name args
5213
\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5215
% \deffngeneral {subind}category name args
5217
\def\deffngeneral#1#2 #3 #4\endheader{%
5218
% Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
5219
\dosubind{fn}{\code{#3}}{#1}%
5220
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
5223
%%% Typed functions:
5225
% @deftypefn category type name args
5226
\makedefun{deftypefn}{\deftypefngeneral{}}
5228
% @deftypeop category class type name args
5229
\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
5231
% \deftypeopon {category on}class type name args
5232
\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5234
% \deftypefngeneral {subind}category type name args
5236
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
5237
\dosubind{fn}{\code{#4}}{#1}%
5238
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5241
%%% Typed variables:
5243
% @deftypevr category type var args
5244
\makedefun{deftypevr}{\deftypecvgeneral{}}
5246
% @deftypecv category class type var args
5247
\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
5249
% \deftypecvof {category of}class type var args
5250
\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
5252
% \deftypecvgeneral {subind}category type var args
5254
\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
5255
\dosubind{vr}{\code{#4}}{#1}%
5256
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5259
%%% Untyped variables:
5261
% @defvr category var args
5262
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
5264
% @defcv category class var args
5265
\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
5267
% \defcvof {category of}class var args
5268
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
5271
% @deftp category name args
5272
\makedefun{deftp}#1 #2 #3\endheader{%
5273
\doind{tp}{\code{#2}}%
5274
\defname{#1}{}{#2}\defunargs{#3\unskip}%
5277
% Remaining @defun-like shortcuts:
5278
\makedefun{defun}{\deffnheader{\putwordDeffunc} }
5279
\makedefun{defmac}{\deffnheader{\putwordDefmac} }
5280
\makedefun{defspec}{\deffnheader{\putwordDefspec} }
5281
\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
5282
\makedefun{defvar}{\defvrheader{\putwordDefvar} }
5283
\makedefun{defopt}{\defvrheader{\putwordDefopt} }
5284
\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
5285
\makedefun{defmethod}{\defopon\putwordMethodon}
5286
\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
5287
\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
5288
\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
5290
% \defname, which formats the name of the @def (not the args).
5291
% #1 is the category, such as "Function".
5292
% #2 is the return type, if any.
5293
% #3 is the function name.
5295
% We are followed by (but not passed) the arguments, if any.
5297
\def\defname#1#2#3{%
5298
% Get the values of \leftskip and \rightskip as they were outside the @def...
5299
\advance\leftskip by -\defbodyindent
5301
% How we'll format the type name. Putting it in brackets helps
5302
% distinguish it from the body text that may end up on the next line
5305
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
5307
% Figure out line sizes for the paragraph shape.
5308
% The first line needs space for \box0; but if \rightskip is nonzero,
5309
% we need only space for the part of \box0 which exceeds it:
5310
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
5311
% The continuations:
5312
\dimen2=\hsize \advance\dimen2 by -\defargsindent
5313
% (plain.tex says that \dimen1 should be used only as global.)
5314
\parshape 2 0in \dimen0 \defargsindent \dimen2
5316
% Put the type name to the right margin.
5319
\hfil\box0 \kern-\hsize
5320
% \hsize has to be shortened this way:
5322
% Intentionally do not respect \rightskip, since we need the space.
5325
% Allow all lines to be underfull without complaint:
5326
\tolerance=10000 \hbadness=10000
5327
\exdentamount=\defbodyindent
5329
% defun fonts. We use typewriter by default (used to be bold) because:
5330
% . we're printing identifiers, they should be in tt in principle.
5331
% . in languages with many accents, such as Czech or French, it's
5332
% common to leave accents off identifiers. The result looks ok in
5333
% tt, but exceedingly strange in rm.
5334
% . we don't want -- and --- to be treated as ligatures.
5335
% . this still does not fix the ?` and !` ligatures, but so far no
5336
% one has made identifiers using them :).
5338
\def\temp{#2}% return value type
5339
\ifx\temp\empty\else \tclose{\temp} \fi
5340
#3% output function name
5342
{\rm\enskip}% hskip 0.5 em of \tenrm
5345
% arguments will be output next, if any.
5348
% Print arguments in slanted roman (not ttsl), inconsistently with using
5349
% tt for the name. This is because literal text is sometimes needed in
5350
% the argument list (groff manual), and ttsl and tt are not very
5351
% distinguishable. Prevent hyphenation at `-' chars.
5354
% use sl by default (not ttsl),
5356
\df \sl \hyphenchar\font=0
5358
% On the other hand, if an argument has two dashes (for instance), we
5359
% want a way to get ttsl. Let's try @var for that.
5362
\sl\hyphenchar\font=45
5365
% We want ()&[] to print specially on the defun line.
3665
5367
\def\activeparens{%
3666
\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
3667
\catcode`\[=\active \catcode`\]=\active}
5368
\catcode`\(=\active \catcode`\)=\active
5369
\catcode`\[=\active \catcode`\]=\active
3669
5373
% Make control sequences which act like normal parenthesis chars.
3670
5374
\let\lparen = ( \let\rparen = )
3672
{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
3674
5376
% Be sure that we always have a definition for `(', etc. For example,
3675
5377
% if the fn name has parens in it, \boldbrax will not be in effect yet,
3676
5378
% so TeX would otherwise complain about undefined control sequence.
3677
\global\let(=\lparen \global\let)=\rparen
3678
\global\let[=\lbrack \global\let]=\rbrack
3680
\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
3681
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
3682
% This is used to turn on special parens
3683
% but make & act ordinary (given that it's active).
3684
\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
3686
% Definitions of (, ) and & used in args for functions.
3687
% This is the definition of ( outside of all parentheses.
3688
\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
5381
\global\let(=\lparen \global\let)=\rparen
5382
\global\let[=\lbrack \global\let]=\rbrack
5385
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5386
\gdef\magicamp{\let&=\amprm}
5389
\newcount\parencount
5391
% If we encounter &foo, then turn on ()-hacking afterwards
5393
\def\amprm#1 {\ampseentrue{\bf\ }}
5397
% At the first level, print parens in roman,
5398
% otherwise use the default font.
5399
\ifnum \parencount=1 \rm \fi
5401
% The \sf parens (in \boldbrax) actually are a little bolder than
5402
% the contained text. This is especially needed for [ and ] .
5406
\def\infirstlevel#1{%
5413
\def\bfafterword#1 {#1 \bf}
3689
5416
\global\advance\parencount by 1
3692
% This is the definition of ( when already inside a level of parens.
3693
\gdef\opnested{\char`\(\global\advance\parencount by 1 }
3695
\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
3696
% also in that case restore the outer-level definition of (.
3697
\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
3698
\global\advance \parencount by -1 }
3699
% If we encounter &foo, then turn on ()-hacking afterwards
3700
\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
3702
\gdef\normalparens{\boldbrax\let&=\ampnr}
3703
} % End of definition inside \activeparens
3704
%% These parens (in \boldbrax) actually are a little bolder than the
3705
%% contained text. This is especially needed for [ and ]
3706
\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
3707
\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
3709
\def\lbrb{{\bf\char`\[}}
3710
\def\rbrb{{\bf\char`\]}}
3712
% First, defname, which formats the header line itself.
3713
% #1 should be the function name.
3714
% #2 should be the type of definition, such as "Function".
3717
% Get the values of \leftskip and \rightskip as they were
3718
% outside the @def...
3720
\advance\dimen2 by -\defbodyindent
3722
\advance\dimen3 by -\defbodyindent
3724
\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
3725
\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
3726
\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
3727
\parshape 2 0in \dimen0 \defargsindent \dimen1 %
3728
% Now output arg 2 ("Function" or some such)
3729
% ending at \deftypemargin from the right margin,
3730
% but stuck inside a box of width 0 so it does not interfere with linebreaking
3731
{% Adjust \hsize to exclude the ambient margins,
3732
% so that \rightline will obey them.
3733
\advance \hsize by -\dimen2 \advance \hsize by -\dimen3
3734
\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
3735
% Make all lines underfull and no complaints:
3736
\tolerance=10000 \hbadness=10000
3737
\advance\leftskip by -\defbodyindent
3738
\exdentamount=\defbodyindent
3739
{\df #1}\enskip % Generate function name
3742
% Actually process the body of a definition
3743
% #1 should be the terminating control sequence, such as \Edefun.
3744
% #2 should be the "another name" control sequence, such as \defunx.
3745
% #3 should be the control sequence that actually processes the header,
3746
% such as \defunheader.
3748
\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3750
% Define the end token that this defining construct specifies
3751
% so that it will exit this group.
3752
\def#1{\endgraf\endgroup\medbreak}%
3753
\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
3755
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3756
\exdentamount=\defbodyindent
3758
\catcode 61=\active % 61 is `='
3759
\obeylines\activeparens\spacesplit#3}
3761
\def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
3763
% Define the end token that this defining construct specifies
3764
% so that it will exit this group.
3765
\def#1{\endgraf\endgroup\medbreak}%
3766
\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
3768
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3769
\exdentamount=\defbodyindent
3770
\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
3772
\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
3774
% Define the end token that this defining construct specifies
3775
% so that it will exit this group.
3776
\def#1{\endgraf\endgroup\medbreak}%
3777
\def#2##1 ##2 {\def#4{##1}%
3778
\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
3780
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3781
\exdentamount=\defbodyindent
3782
\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
3784
% These parsing functions are similar to the preceding ones
3785
% except that they do not make parens into active characters.
3786
% These are used for "variables" since they have no arguments.
3788
\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3790
% Define the end token that this defining construct specifies
3791
% so that it will exit this group.
3792
\def#1{\endgraf\endgroup\medbreak}%
3793
\def#2{\begingroup\obeylines\spacesplit#3}%
3795
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3796
\exdentamount=\defbodyindent
3798
\catcode 61=\active %
3799
\obeylines\spacesplit#3}
3801
% This is used for \def{tp,vr}parsebody. It could probably be used for
3802
% some of the others, too, with some judicious conditionals.
3804
\def\parsebodycommon#1#2#3{%
3807
% Define the end token that this defining construct specifies
3808
% so that it will exit this group.
3809
\def#1{\endgraf\endgroup\medbreak}%
3810
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
3812
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3813
\exdentamount=\defbodyindent
3814
\begingroup\obeylines
3817
\def\defvrparsebody#1#2#3#4 {%
3818
\parsebodycommon{#1}{#2}{#3}%
3819
\spacesplit{#3{#4}}%
3822
% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
3823
% type is just `struct', because we lose the braces in `{struct
3824
% termios}' when \spacesplit reads its undelimited argument. Sigh.
3825
% \let\deftpparsebody=\defvrparsebody
3827
% So, to get around this, we put \empty in with the type name. That
3828
% way, TeX won't find exactly `{...}' as an undelimited argument, and
3829
% won't strip off the braces.
3831
\def\deftpparsebody #1#2#3#4 {%
3832
\parsebodycommon{#1}{#2}{#3}%
3833
\spacesplit{\parsetpheaderline{#3{#4}}}\empty
3836
% Fine, but then we have to eventually remove the \empty *and* the
3837
% braces (if any). That's what this does.
3839
\def\removeemptybraces\empty#1\relax{#1}
3841
% After \spacesplit has done its work, this is called -- #1 is the final
3842
% thing to call, #2 the type name (which starts with \empty), and #3
3843
% (which might be empty) the arguments.
3845
\def\parsetpheaderline#1#2#3{%
3846
#1{\removeemptybraces#2\relax}{#3}%
3849
\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
3851
% Define the end token that this defining construct specifies
3852
% so that it will exit this group.
3853
\def#1{\endgraf\endgroup\medbreak}%
3854
\def#2##1 ##2 {\def#4{##1}%
3855
\begingroup\obeylines\spacesplit{#3{##2}}}%
3857
\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3858
\exdentamount=\defbodyindent
3859
\begingroup\obeylines\spacesplit{#3{#5}}}
3861
% Split up #2 at the first space token.
3862
% call #1 with two arguments:
3863
% the first is all of #2 before the space token,
3864
% the second is all of #2 after that space token.
3865
% If #2 contains no space token, all of it is passed as the first arg
3866
% and the second is passed as empty.
3869
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
3870
\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
3872
#1{#2}{}\else #1{#2}{#3#4}\fi}}
3874
% So much for the things common to all kinds of definitions.
3878
% First, define the processing that is wanted for arguments of \defun
3879
% Use this to expand the args and terminate the paragraph they make up
3881
\def\defunargs #1{\functionparens \sl
3882
% Expand, preventing hyphenation at `-' chars.
3883
% Note that groups don't affect changes in \hyphenchar.
3886
\hyphenchar\tensl=45
3887
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
3888
\interlinepenalty=10000
3889
\advance\rightskip by 0pt plus 1fil
3890
\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3893
\def\deftypefunargs #1{%
3894
% Expand, preventing hyphenation at `-' chars.
3895
% Note that groups don't affect changes in \hyphenchar.
3896
% Use \boldbraxnoamp, not \functionparens, so that & is not special.
3898
\tclose{#1}% avoid \code because of side effects on active chars
3899
\interlinepenalty=10000
3900
\advance\rightskip by 0pt plus 1fil
3901
\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3904
% Do complete processing of one @defun or @defunx line already parsed.
3906
% @deffn Command forward-char nchars
3908
\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
3910
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
3911
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
3912
\catcode 61=\other % Turn off change made in \defparsebody
3915
% @defun == @deffn Function
3917
\def\defun{\defparsebody\Edefun\defunx\defunheader}
3919
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3920
\begingroup\defname {#1}{Function}%
3921
\defunargs {#2}\endgroup %
3922
\catcode 61=\other % Turn off change made in \defparsebody
3925
% @deftypefun int foobar (int @var{foo}, float @var{bar})
3927
\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
3929
% #1 is the data type. #2 is the name and args.
3930
\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
3931
% #1 is the data type, #2 the name, #3 the args.
3932
\def\deftypefunheaderx #1#2 #3\relax{%
3933
\doind {fn}{\code{#2}}% Make entry in function index
3934
\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}%
3935
\deftypefunargs {#3}\endgroup %
3936
\catcode 61=\other % Turn off change made in \defparsebody
3939
% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
3941
\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
3943
% \defheaderxcond#1\relax$$$
3944
% puts #1 in @code, followed by a space, but does nothing if #1 is null.
3945
\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
3947
% #1 is the classification. #2 is the data type. #3 is the name and args.
3948
\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
3949
% #1 is the classification, #2 the data type, #3 the name, #4 the args.
3950
\def\deftypefnheaderx #1#2#3 #4\relax{%
3951
\doind {fn}{\code{#3}}% Make entry in function index
3953
\normalparens % notably, turn off `&' magic, which prevents
3954
% at least some C++ text from working
3955
\defname {\defheaderxcond#2\relax$$$#3}{#1}%
3956
\deftypefunargs {#4}\endgroup %
3957
\catcode 61=\other % Turn off change made in \defparsebody
3960
% @defmac == @deffn Macro
3962
\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
3964
\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3965
\begingroup\defname {#1}{Macro}%
3966
\defunargs {#2}\endgroup %
3967
\catcode 61=\other % Turn off change made in \defparsebody
3970
% @defspec == @deffn Special Form
3972
\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
3974
\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3975
\begingroup\defname {#1}{Special Form}%
3976
\defunargs {#2}\endgroup %
3977
\catcode 61=\other % Turn off change made in \defparsebody
3980
% This definition is run if you use @defunx
3981
% anywhere other than immediately after a @defun or @defunx.
3983
\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
3984
\def\defunx #1 {\errmessage{@defunx in invalid context}}
3985
\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
3986
\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
3987
\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
3988
\def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}}
3989
\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
3991
% @defmethod, and so on
3993
% @defop {Funny Method} foo-class frobnicate argument
3995
\def\defop #1 {\def\defoptype{#1}%
3996
\defopparsebody\Edefop\defopx\defopheader\defoptype}
3998
\def\defopheader #1#2#3{%
3999
\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
4000
\begingroup\defname {#2}{\defoptype{} on #1}%
4001
\defunargs {#3}\endgroup %
4004
% @deftypemethod foo-class return-type foo-method args
4006
\def\deftypemethod{%
4007
\defmethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
4009
% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
4010
\def\deftypemethodheader#1#2#3#4{%
4011
\deftypefnheaderx{Method on #1}{#2}#3 #4\relax
4014
% @defmethod == @defop Method
4016
\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
4018
\def\defmethodheader #1#2#3{%
4019
\dosubind {fn}{\code{#2}}{on #1}% entry in function index
4020
\begingroup\defname {#2}{Method on #1}%
4021
\defunargs {#3}\endgroup %
4024
% @defcv {Class Option} foo-class foo-flag
4026
\def\defcv #1 {\def\defcvtype{#1}%
4027
\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
4029
\def\defcvarheader #1#2#3{%
4030
\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
4031
\begingroup\defname {#2}{\defcvtype{} of #1}%
4032
\defvarargs {#3}\endgroup %
4035
% @defivar == @defcv {Instance Variable}
4037
\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
4039
\def\defivarheader #1#2#3{%
4040
\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
4041
\begingroup\defname {#2}{Instance Variable of #1}%
4042
\defvarargs {#3}\endgroup %
4045
% These definitions are run if you use @defmethodx, etc.,
4046
% anywhere other than immediately after a @defmethod, etc.
4048
\def\defopx #1 {\errmessage{@defopx in invalid context}}
4049
\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
4050
\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
4051
\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
4055
% First, define the processing that is wanted for arguments of @defvar.
4056
% This is actually simple: just print them in roman.
4057
% This must expand the args and terminate the paragraph they make up
4058
\def\defvarargs #1{\normalparens #1%
4059
\interlinepenalty=10000
4060
\endgraf\penalty 10000\vskip -\parskip\penalty 10000}
4062
% @defvr Counter foo-count
4064
\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
4066
\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
4067
\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
4069
% @defvar == @defvr Variable
4071
\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
4073
\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
4074
\begingroup\defname {#1}{Variable}%
4075
\defvarargs {#2}\endgroup %
4078
% @defopt == @defvr {User Option}
4080
\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
4082
\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
4083
\begingroup\defname {#1}{User Option}%
4084
\defvarargs {#2}\endgroup %
4087
% @deftypevar int foobar
4089
\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
4091
% #1 is the data type. #2 is the name, perhaps followed by text that
4092
% is actually part of the data type, which should not be put into the index.
4093
\def\deftypevarheader #1#2{%
4094
\dovarind#2 \relax% Make entry in variables index
4095
\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}%
4096
\interlinepenalty=10000
4097
\endgraf\penalty 10000\vskip -\parskip\penalty 10000
4099
\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
4101
% @deftypevr {Global Flag} int enable
4103
\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
4105
\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
4106
\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
4107
\interlinepenalty=10000
4108
\endgraf\penalty 10000\vskip -\parskip\penalty 10000
4111
% This definition is run if you use @defvarx
4112
% anywhere other than immediately after a @defvar or @defvarx.
4114
\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
4115
\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
4116
\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
4117
\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
4118
\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
4121
% Args are printed in bold, a slight difference from @defvar.
4123
\def\deftpargs #1{\bf \defvarargs{#1}}
4125
% @deftp Class window height width ...
4127
\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
4129
\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
4130
\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
4132
% This definition is run if you use @deftpx, etc
4133
% anywhere other than immediately after a @deftp, etc.
4135
\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
4138
\message{cross reference,}
4139
% Define cross-reference macros
4142
\newif\ifhavexrefs % True if xref values are known.
5418
\infirstlevel \bfafterword
5423
\global\advance\parencount by -1
5426
\newcount\brackcount
5428
\global\advance\brackcount by 1
5433
\global\advance\brackcount by -1
5436
\def\checkparencounts{%
5437
\ifnum\parencount=0 \else \badparencount \fi
5438
\ifnum\brackcount=0 \else \badbrackcount \fi
5440
\def\badparencount{%
5441
\errmessage{Unbalanced parentheses in @def}%
5442
\global\parencount=0
5444
\def\badbrackcount{%
5445
\errmessage{Unbalanced square braces in @def}%
5446
\global\brackcount=0
5453
% To do this right we need a feature of e-TeX, \scantokens,
5454
% which we arrange to emulate with a temporary file in ordinary TeX.
5455
\ifx\eTeXversion\undefined
5456
\newwrite\macscribble
5458
\toks0={#1\endinput}%
5459
\immediate\openout\macscribble=\jobname.tmp
5460
\immediate\write\macscribble{\the\toks0}%
5461
\immediate\closeout\macscribble
5469
\let\xeatspaces\eatspaces
5470
% Undo catcode changes of \startcontents and \doprintindex
5471
\catcode`\@=0 \catcode`\\=\other \escapechar=`\@
5475
% Append \endinput to make sure that TeX does not see the ending newline.
5477
% I've verified that it is necessary both for e-TeX and for ordinary TeX
5479
\scantokens{#1\endinput}%
5483
\newcount\paramno % Count of parameters
5484
\newtoks\macname % Macro name
5485
\newif\ifrecursive % Is it recursive?
5486
\def\macrolist{} % List of all defined macros in the form
5487
% \do\macro1\do\macro2...
5490
% This does \let #1 = #2, except with \csnames.
5492
\expandafter\expandafter
5494
\expandafter\expandafter
5496
\csname#2\endcsname}
5498
% Trim leading and trailing spaces off a string.
5499
% Concepts from aro-bend problem 15 (see CTAN).
5501
\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
5502
\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
5503
\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
5505
\unbrace{\gdef\trim@@@ #1 } #2@{#1}
5508
% Trim a single trailing ^^M off a string.
5509
{\catcode`\^^M=\other \catcode`\Q=3%
5510
\gdef\eatcr #1{\eatcra #1Q^^MQ}%
5511
\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
5512
\gdef\eatcrb#1Q#2Q{#1}%
5515
% Macro bodies are absorbed as an argument in a context where
5516
% all characters are catcode 10, 11 or 12, except \ which is active
5517
% (as in normal texinfo). It is necessary to change the definition of \.
5519
% It's necessary to have hard CRs when the macro is executed. This is
5520
% done by making ^^M (\endlinechar) catcode 12 when reading the macro
5521
% body, and then making it the \newlinechar in \scanmacro.
5523
\def\macrobodyctxt{%
5534
\catcode`\^^M=\other
5548
% \mbodybackslash is the definition of \ in @macro bodies.
5549
% It maps \foo\ => \csname macarg.foo\endcsname => #N
5550
% where N is the macro parameter number.
5551
% We define \csname macarg.\endcsname to be \realbackslash, so
5552
% \\ in macro replacement text gets you a backslash.
5554
{\catcode`@=0 @catcode`@\=@active
5555
@gdef@usembodybackslash{@let\=@mbodybackslash}
5556
@gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
5558
\expandafter\def\csname macarg.\endcsname{\realbackslash}
5560
\def\macro{\recursivefalse\parsearg\macroxxx}
5561
\def\rmacro{\recursivetrue\parsearg\macroxxx}
5564
\getargs{#1}% now \macname is the macname and \argl the arglist
5565
\ifx\argl\empty % no arguments
5568
\expandafter\parsemargdef \argl;%
5570
\if1\csname ismacro.\the\macname\endcsname
5571
\message{Warning: redefining \the\macname}%
5573
\expandafter\ifx\csname \the\macname\endcsname \relax
5574
\else \errmessage{Macro name \the\macname\space already defined}\fi
5575
\global\cslet{macsave.\the\macname}{\the\macname}%
5576
\global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
5577
% Add the macroname to \macrolist
5578
\toks0 = \expandafter{\macrolist\do}%
5579
\xdef\macrolist{\the\toks0
5580
\expandafter\noexpand\csname\the\macname\endcsname}%
5582
\begingroup \macrobodyctxt
5583
\ifrecursive \expandafter\parsermacbody
5584
\else \expandafter\parsemacbody
5587
\parseargdef\unmacro{%
5588
\if1\csname ismacro.#1\endcsname
5589
\global\cslet{#1}{macsave.#1}%
5590
\global\expandafter\let \csname ismacro.#1\endcsname=0%
5591
% Remove the macro name from \macrolist:
5593
\expandafter\let\csname#1\endcsname \relax
5595
\xdef\macrolist{\macrolist}%
5598
\errmessage{Macro #1 not defined}%
5602
% Called by \do from \dounmacro on each macro. The idea is to omit any
5603
% macro definitions that have been changed to \relax.
5609
\noexpand\do \noexpand #1%
5613
% This makes use of the obscure feature that if the last token of a
5614
% <parameter list> is #, then the preceding argument is delimited by
5615
% an opening brace, and that opening brace is not consumed.
5616
\def\getargs#1{\getargsxxx#1{}}
5617
\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
5618
\def\getmacname #1 #2\relax{\macname={#1}}
5619
\def\getmacargs#1{\def\argl{#1}}
5621
% Parse the optional {params} list. Set up \paramno and \paramlist
5622
% so \defmacro knows what to do. Define \macarg.blah for each blah
5623
% in the params list, to be ##N where N is the position in that list.
5624
% That gets used by \mbodybackslash (above).
5626
% We need to get `macro parameter char #' into several definitions.
5627
% The technique used is stolen from LaTeX: let \hash be something
5628
% unexpandable, insert that wherever you need a #, and then redefine
5629
% it to # just before using the token list produced.
5631
% The same technique is used to protect \eatspaces till just before
5632
% the macro is used.
5634
\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
5635
\let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
5636
\def\parsemargdefxxx#1,{%
5637
\if#1;\let\next=\relax
5638
\else \let\next=\parsemargdefxxx
5639
\advance\paramno by 1%
5640
\expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
5641
{\xeatspaces{\hash\the\paramno}}%
5642
\edef\paramlist{\paramlist\hash\the\paramno,}%
5645
% These two commands read recursive and nonrecursive macro bodies.
5646
% (They're different since rec and nonrec macros end differently.)
5648
\long\def\parsemacbody#1@end macro%
5649
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
5650
\long\def\parsermacbody#1@end rmacro%
5651
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
5653
% This defines the macro itself. There are six cases: recursive and
5654
% nonrecursive macros of zero, one, and many arguments.
5655
% Much magic with \expandafter here.
5656
% \xdef is used so that macro definitions will survive the file
5657
% they're defined in; @include reads the file inside a group.
5659
\let\hash=##% convert placeholders to macro parameter chars
5663
\expandafter\xdef\csname\the\macname\endcsname{%
5664
\noexpand\scanmacro{\temp}}%
5666
\expandafter\xdef\csname\the\macname\endcsname{%
5667
\bgroup\noexpand\macroargctxt
5668
\noexpand\braceorline
5669
\expandafter\noexpand\csname\the\macname xxx\endcsname}%
5670
\expandafter\xdef\csname\the\macname xxx\endcsname##1{%
5671
\egroup\noexpand\scanmacro{\temp}}%
5673
\expandafter\xdef\csname\the\macname\endcsname{%
5674
\bgroup\noexpand\macroargctxt
5675
\noexpand\csname\the\macname xx\endcsname}%
5676
\expandafter\xdef\csname\the\macname xx\endcsname##1{%
5677
\expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
5678
\expandafter\expandafter
5680
\expandafter\expandafter
5681
\csname\the\macname xxx\endcsname
5682
\paramlist{\egroup\noexpand\scanmacro{\temp}}%
5687
\expandafter\xdef\csname\the\macname\endcsname{%
5688
\noexpand\norecurse{\the\macname}%
5689
\noexpand\scanmacro{\temp}\egroup}%
5691
\expandafter\xdef\csname\the\macname\endcsname{%
5692
\bgroup\noexpand\macroargctxt
5693
\noexpand\braceorline
5694
\expandafter\noexpand\csname\the\macname xxx\endcsname}%
5695
\expandafter\xdef\csname\the\macname xxx\endcsname##1{%
5697
\noexpand\norecurse{\the\macname}%
5698
\noexpand\scanmacro{\temp}\egroup}%
5700
\expandafter\xdef\csname\the\macname\endcsname{%
5701
\bgroup\noexpand\macroargctxt
5702
\expandafter\noexpand\csname\the\macname xx\endcsname}%
5703
\expandafter\xdef\csname\the\macname xx\endcsname##1{%
5704
\expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
5705
\expandafter\expandafter
5707
\expandafter\expandafter
5708
\csname\the\macname xxx\endcsname
5711
\noexpand\norecurse{\the\macname}%
5712
\noexpand\scanmacro{\temp}\egroup}%
5716
\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
5718
% \braceorline decides whether the next nonwhitespace character is a
5719
% {. If so it reads up to the closing }, if not, it reads the whole
5720
% line. Whatever was read is then fed to the next control sequence
5721
% as an argument (by \parsebrace or \parsearg)
5722
\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
5723
\def\braceorlinexxx{%
5724
\ifx\nchar\bgroup\else
5725
\expandafter\parsearg
5728
% We mant to disable all macros during \shipout so that they are not
5729
% expanded by \write.
5730
\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
5731
\edef\next{\macrolist}\expandafter\endgroup\next}
5735
% We need some trickery to remove the optional spaces around the equal
5736
% sign. Just make them active and then expand them all to nothing.
5737
\def\alias{\parseargusing\obeyspaces\aliasxxx}
5738
\def\aliasxxx #1{\aliasyyy#1\relax}
5739
\def\aliasyyy #1=#2\relax{%
5741
\expandafter\let\obeyedspace=\empty
5742
\xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
5748
\message{cross references,}
5752
\newif\ifhavexrefs % True if xref values are known.
4143
5753
\newif\ifwarnedxrefs % True if we warned once that they aren't known.
4145
% @inforef is simple.
5755
% @inforef is relatively simple.
4146
5756
\def\inforef #1{\inforefzzz #1,,,,**}
4147
5757
\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
4148
5758
node \samp{\ignorespaces#1{}}}
4150
% \setref{foo} defines a cross-reference point named foo.
4153
\dosetq{#1-title}{Ytitle}%
4154
\dosetq{#1-pg}{Ypagenumber}%
4155
\dosetq{#1-snt}{Ysectionnumberandtype}}
4157
\def\unnumbsetref#1{%
4158
\dosetq{#1-title}{Ytitle}%
4159
\dosetq{#1-pg}{Ypagenumber}%
4160
\dosetq{#1-snt}{Ynothing}}
4162
\def\appendixsetref#1{%
4163
\dosetq{#1-title}{Ytitle}%
4164
\dosetq{#1-pg}{Ypagenumber}%
4165
\dosetq{#1-snt}{Yappendixletterandtype}}
4167
% \xref, \pxref, and \ref generate cross-references to specified points.
4168
% For \xrefX, #1 is the node name, #2 the name of the Info
4169
% cross-reference, #3 the printed node name, #4 the name of the Info
4170
% file, #5 the name of the printed manual. All but the node name can be
5760
% @node's only job in TeX is to define \lastnode, which is used in
5761
% cross-references. The @node line might or might not have commas, and
5762
% might or might not have spaces before the first comma, like:
5763
% @node foo , bar , ...
5764
% We don't want such trailing spaces in the node name.
5766
\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
5768
% also remove a trailing comma, in case of something like this:
5769
% @node Help-Cross, , , Cross-refs
5770
\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
5771
\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
5774
\let\lastnode=\empty
5776
% Write a cross-reference definition for the current node. #1 is the
5777
% type (Ynumbered, Yappendix, Ynothing).
5780
\ifx\lastnode\empty\else
5781
\setref{\lastnode}{#1}%
5782
\global\let\lastnode=\empty
5786
% @anchor{NAME} -- define xref target at arbitrary point.
5788
\newcount\savesfregister
5790
\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
5791
\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
5792
\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
5794
% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
5795
% anchor), which consists of three parts:
5796
% 1) NAME-title - the current sectioning name taken from \thissection,
5797
% or the anchor name.
5798
% 2) NAME-snt - section number and type, passed as the SNT arg, or
5799
% empty for anchors.
5800
% 3) NAME-pg - the page number.
5802
% This is called from \donoderef, \anchor, and \dofloat. In the case of
5803
% floats, there is an additional part, which is not written here:
5804
% 4) NAME-lof - the text as it should appear in a @listoffloats.
5810
\atdummies % preserve commands, but don't expand them
5813
\edef\writexrdef##1##2{%
5814
\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
5815
##1}{##2}}% these are parameters of \writexrdef
5817
\toks0 = \expandafter{\thissection}%
5818
\immediate \writexrdef{title}{\the\toks0 }%
5819
\immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
5820
\writexrdef{pg}{\folio}% will be written later, during \shipout
5825
% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
5826
% the node name, #2 the name of the Info cross-reference, #3 the printed
5827
% node name, #4 the name of the Info file, #5 the name of the printed
5828
% manual. All but the node name can be omitted.
4173
5830
\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
4174
5831
\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
4175
5832
\def\ref#1{\xrefX[#1,,,,,,,]}
4176
5833
\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
4177
5835
\def\printedmanual{\ignorespaces #5}%
4178
\def\printednodename{\ignorespaces #3}%
4179
\setbox1=\hbox{\printedmanual}%
4180
\setbox0=\hbox{\printednodename}%
5836
\def\printedrefname{\ignorespaces #3}%
5837
\setbox1=\hbox{\printedmanual\unskip}%
5838
\setbox0=\hbox{\printedrefname\unskip}%
4181
5839
\ifdim \wd0 = 0pt
4182
5840
% No printed node name was explicitly given.
4183
5841
\expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
4184
5842
% Use the node name inside the square brackets.
4185
\def\printednodename{\ignorespaces #1}%
5843
\def\printedrefname{\ignorespaces #1}%
4187
5845
% Use the actual chapter/section title appear inside
4188
5846
% the square brackets. Use the real section title if we have it.
4190
5848
% It is in another manual, so we don't have it.
4191
\def\printednodename{\ignorespaces #1}%
5849
\def\printedrefname{\ignorespaces #1}%
4194
5852
% We know the real title if we have the xref values.
4195
\def\printednodename{\refx{#1-title}{}}%
5853
\def\printedrefname{\refx{#1-title}{}}%
4197
5855
% Otherwise just copy the Info node name.
4198
\def\printednodename{\ignorespaces #1}%
5856
\def\printedrefname{\ignorespaces #1}%
4204
% If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
4205
% insert empty discretionaries after hyphens, which means that it will
4206
% not find a line break at a hyphen in a node names. Since some manuals
4207
% are best written with fairly long node names, containing hyphens, this
4208
% is a loss. Therefore, we give the text of the node name again, so it
4209
% is as if TeX is seeing it for the first time.
4211
\putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
5862
% Make link in pdf output.
5866
{\turnoffactive \otherbackslash
5867
\ifnum\filenamelength>0
5868
\startlink attr{/Border [0 0 0]}%
5869
goto file{\the\filename.pdf} name{#1}%
5871
\startlink attr{/Border [0 0 0]}%
5872
goto name{\pdfmkpgn{#1}}%
5878
% Float references are printed completely differently: "Figure 1.2"
5879
% instead of "[somenode], p.3". We distinguish them by the
5880
% LABEL-title being set to a magic string.
5882
% Have to otherify everything special to allow the \csname to
5883
% include an _ in the xref name, etc.
5887
\expandafter\global\expandafter\let\expandafter\Xthisreftitle
5888
\csname XR#1-title\endcsname
5890
\iffloat\Xthisreftitle
5891
% If the user specified the print name (third arg) to the ref,
5892
% print it instead of our usual "Figure 1.2".
5899
% if the user also gave the printed manual name (fifth arg), append
5902
\space \putwordin{} \cite{\printedmanual}%
4213
% _ (for example) has to be the character _ for the purposes of the
4214
% control sequence corresponding to the node, but it has to expand
4215
% into the usual \leavevmode...\vrule stuff for purposes of
4216
% printing. So we \turnoffactive for the \refx-snt, back on for the
4217
% printing, back off for the \refx-pg.
4218
{\turnoffactive \refx{#1-snt}{}}%
4219
\space [\printednodename],\space
4220
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
5905
% node/anchor (non-float) references.
5907
% If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
5908
% insert empty discretionaries after hyphens, which means that it will
5909
% not find a line break at a hyphen in a node names. Since some manuals
5910
% are best written with fairly long node names, containing hyphens, this
5911
% is a loss. Therefore, we give the text of the node name again, so it
5912
% is as if TeX is seeing it for the first time.
5914
\putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
5916
% _ (for example) has to be the character _ for the purposes of the
5917
% control sequence corresponding to the node, but it has to expand
5918
% into the usual \leavevmode...\vrule stuff for purposes of
5919
% printing. So we \turnoffactive for the \refx-snt, back on for the
5920
% printing, back off for the \refx-pg.
5921
{\turnoffactive \otherbackslash
5922
% Only output a following space if the -snt ref is nonempty; for
5923
% @unnumbered and @anchor, it won't be.
5924
\setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
5925
\ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
5927
% output the `[mynode]' via a macro so it can be overridden.
5928
\xrefprintnodename\printedrefname
5930
% But we always want a comma and a space:
5933
% output the `page 3'.
5934
\turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}%
4224
% \dosetq is the interface for calls from other macros
4226
% Use \turnoffactive so that punctuation chars such as underscore
4227
% work in node names.
4228
\def\dosetq #1#2{{\let\folio=0 \turnoffactive
4229
\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
4232
% \internalsetq {foo}{page} expands into
4233
% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
4234
% When the aux file is read, ' is the escape character
4236
\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
4238
% Things to be expanded by \internalsetq
4240
\def\Ypagenumber{\folio}
4242
\def\Ytitle{\thissection}
5940
% This macro is called from \xrefX for the `[nodename]' part of xref
5941
% output. It's a separate macro only so it can be changed more easily,
5942
% since square brackets don't work well in some documents. Particularly
5943
% one that Bob is working on :).
5945
\def\xrefprintnodename#1{[#1]}
5947
% Things referred to by \setref.
4244
5949
\def\Ynothing{}
4246
\def\Ysectionnumberandtype{%
4247
\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
4248
\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
4249
\else \ifnum \subsubsecno=0 %
4250
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
4252
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
4255
\def\Yappendixletterandtype{%
4256
\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
4257
\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
4258
\else \ifnum \subsubsecno=0 %
4259
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
4261
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
4266
% Use TeX 3.0's \inputlineno to get the line number, for better error
4267
% messages, but if we're using an old version of TeX, don't do anything.
4269
\ifx\inputlineno\thisisundefined
4270
\let\linenumber = \empty % Non-3.0.
4272
\def\linenumber{\the\inputlineno:\space}
5953
\putwordChapter@tie \the\chapno
5954
\else \ifnum\subsecno=0
5955
\putwordSection@tie \the\chapno.\the\secno
5956
\else \ifnum\subsubsecno=0
5957
\putwordSection@tie \the\chapno.\the\secno.\the\subsecno
5959
\putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
5964
\putwordAppendix@tie @char\the\appendixno{}%
5965
\else \ifnum\subsecno=0
5966
\putwordSection@tie @char\the\appendixno.\the\secno
5967
\else \ifnum\subsubsecno=0
5968
\putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
5971
@char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
4275
5975
% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
4276
5976
% If its value is nonempty, SUFFIX is output afterward.
4278
5978
\def\refx#1#2{%
4279
\expandafter\ifx\csname X#1\endcsname\relax
5982
\expandafter\global\expandafter\let\expandafter\thisrefX
5983
\csname XR#1\endcsname
4280
5986
% If not defined, say something at least.
4281
$\langle$un\-de\-fined$\rangle$%
4283
\message{\linenumber Undefined cross reference `#1'.}%
4286
\global\warnedxrefstrue
4287
\message{Cross reference values unknown; you must run TeX again.}%
5987
\angleleft un\-de\-fined\angleright
5990
\message{\linenumber Undefined cross reference `#1'.}%
5993
\global\warnedxrefstrue
5994
\message{Cross reference values unknown; you must run TeX again.}%
4291
5999
% It's defined, so just use it.
4292
\csname X#1\endcsname
4294
6002
#2% Output the suffix in any case.
4297
% This is the macro invoked by entries in the aux file.
4300
\expandafter\gdef\csname X#1\endcsname{#2}%
6005
% This is the macro invoked by entries in the aux file. Usually it's
6006
% just a \def (we prepend XR to the control sequence name to avoid
6007
% collisions). But if this is a float type, we have more work to do.
6010
\expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value.
6012
% Was that xref control sequence that we just defined for a float?
6013
\expandafter\iffloat\csname XR#1\endcsname
6014
% it was a float, and we have the (safe) float type in \iffloattype.
6015
\expandafter\let\expandafter\floatlist
6016
\csname floatlist\iffloattype\endcsname
6018
% Is this the first time we've seen this float type?
6019
\expandafter\ifx\floatlist\relax
6020
\toks0 = {\do}% yes, so just \do
6022
% had it before, so preserve previous elements in list.
6023
\toks0 = \expandafter{\floatlist\do}%
6026
% Remember this xref in the control sequence \floatlistFLOATTYPE,
6027
% for later use in \listoffloats.
6028
\expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
4303
6032
% Read the last existing aux file, if any. No error if none exists.
6035
\openin 1 \jobname.aux
6038
\global\havexrefstrue
4304
6043
\def\readauxfile{\begingroup
4305
6044
\catcode`\^^@=\other
6045
\catcode`\^^A=\other
6046
\catcode`\^^B=\other
4308
6047
\catcode`\^^C=\other
4309
6048
\catcode`\^^D=\other
4310
6049
\catcode`\^^E=\other
4311
6050
\catcode`\^^F=\other
4312
6051
\catcode`\^^G=\other
4313
6052
\catcode`\^^H=\other
6053
\catcode`\^^K=\other
4315
6054
\catcode`\^^L=\other
6055
\catcode`\^^N=\other
6056
\catcode`\^^P=\other
6057
\catcode`\^^Q=\other
6058
\catcode`\^^R=\other
6059
\catcode`\^^S=\other
6060
\catcode`\^^T=\other
6061
\catcode`\^^U=\other
6062
\catcode`\^^V=\other
6063
\catcode`\^^W=\other
6064
\catcode`\^^X=\other
6065
\catcode`\^^Z=\other
4329
6066
\catcode`\^^[=\other
4330
6067
\catcode`\^^\=\other
4331
6068
\catcode`\^^]=\other
4332
6069
\catcode`\^^^=\other
4333
6070
\catcode`\^^_=\other
4336
% It was suggested to define this as 7, which would allow ^^e4 etc.
6071
% It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
4337
6072
% in xref tags, i.e., node names. But since ^^e4 notation isn't
4338
6073
% supported in the main text, it doesn't seem desirable. Furthermore,
4339
6074
% that is not enough: for node names that actually contain a ^
4458
6204
\futurelet\next\fo@t
4460
\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
4461
\else\let\next\f@t\fi \next}
4462
\def\f@@t{\bgroup\aftergroup\@foot\let\next}
4463
\def\f@t#1{#1\@foot}
4464
\def\@foot{\strut\egroup}
4466
6206
}%end \catcode `\@=11
4468
% Set the baselineskip to #1, and the lineskip and strut size
4469
% correspondingly. There is no deep meaning behind these magic numbers
4470
% used as factors; they just match (closely enough) what Knuth defined.
4472
\def\lineskipfactor{.08333}
4473
\def\strutheightpercent{.70833}
4474
\def\strutdepthpercent {.29167}
4477
\normalbaselineskip = #1\relax
4478
\normallineskip = \lineskipfactor\normalbaselineskip
4480
\setbox\strutbox =\hbox{%
4481
\vrule width0pt height\strutheightpercent\baselineskip
4482
depth \strutdepthpercent \baselineskip
4486
% @| inserts a changebar to the left of the current line. It should
4487
% surround any changed text. This approach does *not* work if the
4488
% change spans more than two lines of output. To handle that, we would
4489
% have adopt a much more difficult approach (putting marks into the main
4490
% vertical list for the beginning and end of each change).
4493
% \vadjust can only be used in horizontal mode.
4496
% Append this vertical mode material after the current line in the output.
4498
% We want to insert a rule with the height and depth of the current
4499
% leading; that is exactly what \strutbox is supposed to record.
4500
\vskip-\baselineskip
4502
% \vadjust-items are inserted at the left edge of the type. So
4503
% the \llap here moves out into the left-hand margin.
4506
% For a thicker or thinner bar, change the `1pt'.
4507
\vrule height\baselineskip width1pt
4509
% This is the space between the bar and the text.
4515
% For a final copy, take out the rectangles
4516
% that mark overfull boxes (in case you have decided
4517
% that the text looks ok even though it passes the margin).
4519
\def\finalout{\overfullrule=0pt}
4522
% End of control word definitions.
4524
\message{and turning on texinfo input format.}
4535
% Set some numeric style parameters, for 8.5 x 11 format.
6208
% In case a @footnote appears in a vbox, save the footnote text and create
6209
% the real \insert just after the vbox finished. Otherwise, the insertion
6211
% Similarily, if a @footnote appears inside an alignment, save the footnote
6212
% text to a box and make the \insert when a row of the table is finished.
6213
% And the same can be done for other insert classes. --kasal, 16nov03.
6215
% Replace the \insert primitive by a cheating macro.
6216
% Deeper inside, just make sure that the saved insertions are not spilled
6219
\def\startsavinginserts{%
6220
\ifx \insert\ptexinsert
6221
\let\insert\saveinsert
6223
\let\checkinserts\relax
6227
% This \insert replacement works for both \insert\footins{foo} and
6228
% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
6231
\edef\next{\noexpand\savetobox \makeSAVEname#1}%
6232
\afterassignment\next
6233
% swallow the left brace
6236
\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
6237
\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
6239
\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
6241
\def\placesaveins#1{%
6242
\ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
6246
% eat @SAVE -- beware, all of them have catcode \other:
6248
\def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
6249
\gdef\gobblesave @SAVE{}
6253
\def\newsaveins #1{%
6254
\edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
6257
\def\newsaveinsX #1{%
6258
\csname newbox\endcsname #1%
6259
\expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
6264
\let\checkinserts\empty
6269
% @image. We use the macros from epsf.tex to support this.
6270
% If epsf.tex is not installed and @image is used, we complain.
6272
% Check for and read epsf.tex up front. If we read it only at @image
6273
% time, we might be inside a group, and then its definitions would get
6274
% undone and the next image would fail.
6275
\openin 1 = epsf.tex
6277
% Do not bother showing banner with epsf.tex v2.7k (available in
6278
% doc/epsf.tex and on ctan).
6279
\def\epsfannounce{\toks0 = }%
6284
% We will only complain once about lack of epsf.tex.
6285
\newif\ifwarnednoepsf
6286
\newhelp\noepsfhelp{epsf.tex must be installed for images to
6287
work. It is also included in the Texinfo distribution, or you can get
6288
it from ftp://tug.org/tex/epsf.tex.}
6291
\ifx\epsfbox\undefined
6292
\ifwarnednoepsf \else
6293
\errhelp = \noepsfhelp
6294
\errmessage{epsf.tex not found, images will be ignored}%
6295
\global\warnednoepsftrue
6298
\imagexxx #1,,,,,\finish
6302
% Arguments to @image:
6303
% #1 is (mandatory) image filename; we tack on .eps extension.
6304
% #2 is (optional) width, #3 is (optional) height.
6305
% #4 is (ignored optional) html alt text.
6306
% #5 is (ignored optional) extension.
6307
% #6 is just the usual extra ignored arg for parsing this stuff.
6309
\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
6310
\catcode`\^^M = 5 % in case we're inside an example
6311
\normalturnoffactive % allow _ et al. in names
6312
% If the image is by itself, center it.
6316
% Usually we'll have text after the image which will insert
6317
% \parskip glue, so insert it here too to equalize the space
6319
\nobreak\vskip\parskip
6326
\dopdfimage{#1}{#2}{#3}%
6328
% \epsfbox itself resets \epsf?size at each figure.
6329
\setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
6330
\setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
6334
\ifimagevmode \hss \egroup \bigbreak \fi % space after the image
6338
% @float FLOATTYPE,LOC ... @end float for displayed figures, tables, etc.
6339
% We don't actually implement floating yet, we just plop the float "here".
6340
% But it seemed the best name for the future.
6342
\envparseargdef\float{\dofloat #1,,,\finish}
6344
% #1 is the optional FLOATTYPE, the text label for this float, typically
6345
% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
6346
% this float will not be numbered and cannot be referred to.
6348
% #2 is the optional xref label. Also must be present for the float to
6351
% #3 is the optional positioning argument; for now, it is ignored. It
6352
% will somehow specify the positions allowed to float to (here, top, bottom).
6354
% We keep a separate counter for each FLOATTYPE, which we reset at each
6355
% chapter-level command.
6356
\let\resetallfloatnos=\empty
6358
\def\dofloat#1,#2,#3,#4\finish{%
6359
\let\thiscaption=\empty
6360
\let\thisshortcaption=\empty
6362
% don't lose footnotes inside @float.
6365
% We can't be used inside a paragraph.
6370
\def\floatlabel{#2}%
6371
\def\floatloc{#3}% we do nothing with this yet.
6373
\ifx\floattype\empty
6374
\let\safefloattype=\empty
6377
% the floattype might have accents or other special characters,
6378
% but we need to use it in a control sequence name.
6381
\xdef\safefloattype{\floattype}%
6385
% If label is given but no type, we handle that as the empty type.
6386
\ifx\floatlabel\empty \else
6387
% We want each FLOATTYPE to be numbered separately (Figure 1,
6388
% Table 1, Figure 2, ...). (And if no label, no number.)
6390
\expandafter\getfloatno\csname\safefloattype floatno\endcsname
6391
\global\advance\floatno by 1
6394
% This magic value for \thissection is output by \setref as the
6395
% XREFLABEL-title value. \xrefX uses it to distinguish float
6396
% labels (which have a completely different output format) from
6397
% node and anchor labels. And \xrdef uses it to construct the
6400
\edef\thissection{\floatmagic=\safefloattype}%
6401
\setref{\floatlabel}{Yfloat}%
6405
% start with \parskip glue, I guess.
6408
% Don't suppress indentation if a float happens to start a section.
6409
\restorefirstparagraphindent
6412
% we have these possibilities:
6413
% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
6414
% @float Foo,lbl & no caption: Foo 1.1
6415
% @float Foo & @caption{Cap}: Foo: Cap
6416
% @float Foo & no caption: Foo
6417
% @float ,lbl & Caption{Cap}: 1.1: Cap
6418
% @float ,lbl & no caption: 1.1
6419
% @float & @caption{Cap}: Cap
6420
% @float & no caption:
6423
\let\floatident = \empty
6425
% In all cases, if we have a float type, it comes first.
6426
\ifx\floattype\empty \else \def\floatident{\floattype}\fi
6428
% If we have an xref label, the number comes next.
6429
\ifx\floatlabel\empty \else
6430
\ifx\floattype\empty \else % if also had float type, need tie first.
6431
\appendtomacro\floatident{\tie}%
6434
\appendtomacro\floatident{\chaplevelprefix\the\floatno}%
6437
% Start the printed caption with what we've constructed in
6438
% \floatident, but keep it separate; we need \floatident again.
6439
\let\captionline = \floatident
6441
\ifx\thiscaption\empty \else
6442
\ifx\floatident\empty \else
6443
\appendtomacro\captionline{: }% had ident, so need a colon between
6447
\appendtomacro\captionline\thiscaption
6450
% If we have anything to print, print it, with space before.
6451
% Eventually this needs to become an \insert.
6452
\ifx\captionline\empty \else
6457
% If have an xref label, write the list of floats info. Do this
6458
% after the caption, to avoid chance of it being a breakpoint.
6459
\ifx\floatlabel\empty \else
6460
% Write the text that goes in the lof to the aux file as
6461
% \floatlabel-lof. Besides \floatident, we include the short
6462
% caption if specified, else the full caption if specified, else nothing.
6464
\atdummies \turnoffactive \otherbackslash
6465
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{%
6467
\ifx\thisshortcaption\empty
6468
\ifx\thiscaption\empty \else : \thiscaption \fi
6476
% Space below caption, if we printed anything.
6477
\ifx\printedsomething\empty \else \vskip\parskip \fi
6478
\egroup % end of \vtop
6482
% Append the tokens #2 to the definition of macro #1, not expanding either.
6484
\newtoks\appendtomacroAtoks
6485
\newtoks\appendtomacroBtoks
6486
\def\appendtomacro#1#2{%
6487
\appendtomacroAtoks = \expandafter{#1}%
6488
\appendtomacroBtoks = {#2}%
6489
\edef#1{\the\appendtomacroAtoks \the\appendtomacroBtoks}%
6492
% @caption, @shortcaption are easy.
6494
\long\def\caption#1{\checkenv\float \def\thiscaption{#1}}
6495
\def\shortcaption#1{\checkenv\float \def\thisshortcaption{#1}}
6497
% The parameter is the control sequence identifying the counter we are
6498
% going to use. Create it if it doesn't exist and assign it to \floatno.
6501
% Haven't seen this figure type before.
6502
\csname newcount\endcsname #1%
6504
% Remember to reset this floatno at the next chap.
6505
\expandafter\gdef\expandafter\resetallfloatnos
6506
\expandafter{\resetallfloatnos #1=0 }%
6511
% \setref calls this to get the XREFLABEL-snt value. We want an @xref
6512
% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
6513
% first read the @float command.
6515
\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
6517
% Magic string used for the XREFLABEL-title value, so \xrefX can
6518
% distinguish floats from other xref types.
6519
\def\floatmagic{!!float!!}
6521
% #1 is the control sequence we are passed; we expand into a conditional
6522
% which is true if #1 represents a float ref. That is, the magic
6523
% \thissection value which we \setref above.
6525
\def\iffloat#1{\expandafter\doiffloat#1==\finish}
6527
% #1 is (maybe) the \floatmagic string. If so, #2 will be the
6528
% (safe) float type for this float. We set \iffloattype to #2.
6530
\def\doiffloat#1=#2=#3\finish{%
6532
\def\iffloattype{#2}%
6533
\ifx\temp\floatmagic
6536
% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
6538
\parseargdef\listoffloats{%
6539
\def\floattype{#1}% floattype
6541
% the floattype might have accents or other special characters,
6542
% but we need to use it in a control sequence name.
6545
\xdef\safefloattype{\floattype}%
6548
% \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
6549
\expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
6551
% if the user said @listoffloats foo but never @float foo.
6552
\message{\linenumber No `\safefloattype' floats to list.}%
6556
\leftskip=\tocindent % indent these entries like a toc
6557
\let\do=\listoffloatsdo
6558
\csname floatlist\safefloattype\endcsname
6563
% This is called on each entry in a list of floats. We're passed the
6564
% xref label, in the form LABEL-title, which is how we save it in the
6565
% aux file. We strip off the -title and look up \XRLABEL-lof, which
6566
% has the text we're supposed to typeset here.
6568
% Figures without xref labels will not be included in the list (since
6569
% they won't appear in the aux file).
6571
\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
6572
\def\listoffloatsdoentry#1-title\finish{{%
6573
% Can't fully expand XR#1-lof because it can contain anything. Just
6574
% pass the control sequence. On the other hand, XR#1-pg is just the
6575
% page number, and we want to fully expand that so we can get a link
6577
\toksA = \expandafter{\csname XR#1-lof\endcsname}%
6579
% use the same \entry macro we use to generate the TOC and index.
6580
\edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
6584
\message{localization,}
6587
% @documentlanguage is usually given very early, just after
6588
% @setfilename. If done too late, it may not override everything
6589
% properly. Single argument is the language abbreviation.
6590
% It would be nice if we could set up a hyphenation file here.
6592
\parseargdef\documentlanguage{%
6593
\tex % read txi-??.tex file in plain TeX.
6594
% Read the file if it exists.
6595
\openin 1 txi-#1.tex
6597
\errhelp = \nolanghelp
6598
\errmessage{Cannot read language file txi-#1.tex}%
6605
\newhelp\nolanghelp{The given language definition file cannot be found or
6606
is empty. Maybe you need to install it? In the current directory
6607
should work if nowhere else does.}
6610
% @documentencoding should change something in TeX eventually, most
6611
% likely, but for now just recognize it.
6612
\let\documentencoding = \comment
6615
% Page size parameters.
4539
6617
\newdimen\defaultparindent \defaultparindent = 15pt
4540
\parindent = \defaultparindent
4541
\parskip 3pt plus 2pt minus 1pt
4543
\advance\topskip by 1.2cm
4545
6619
\chapheadingskip = 15pt plus 4pt minus 2pt
4546
6620
\secheadingskip = 12pt plus 3pt minus 2pt
4547
6621
\subsecheadingskip = 9pt plus 2pt minus 2pt
4549
6623
% Prevent underfull vbox error messages.
6626
% Don't be so finicky about underfull hboxes, either.
4552
6629
% Following George Bush, just get rid of widows and orphans.
4553
6630
\widowpenalty=10000