Chris@82: % texinfo.tex -- TeX macros to handle Texinfo files. Chris@82: % Chris@82: % Load plain if necessary, i.e., if running under initex. Chris@82: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi Chris@82: % Chris@82: \def\texinfoversion{2013-02-01.11} Chris@82: % Chris@82: % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, Chris@82: % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, Chris@82: % 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. Chris@82: % Chris@82: % This texinfo.tex file is free software: you can redistribute it and/or Chris@82: % modify it under the terms of the GNU General Public License as Chris@82: % published by the Free Software Foundation, either version 3 of the Chris@82: % License, or (at your option) any later version. Chris@82: % Chris@82: % This texinfo.tex file is distributed in the hope that it will be Chris@82: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty Chris@82: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Chris@82: % General Public License for more details. Chris@82: % Chris@82: % You should have received a copy of the GNU General Public License Chris@82: % along with this program. If not, see . Chris@82: % Chris@82: % As a special exception, when this file is read by TeX when processing Chris@82: % a Texinfo source document, you may use the result without Chris@82: % restriction. This Exception is an additional permission under section 7 Chris@82: % of the GNU General Public License, version 3 ("GPLv3"). Chris@82: % Chris@82: % Please try the latest version of texinfo.tex before submitting bug Chris@82: % reports; you can get the latest version from: Chris@82: % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or Chris@82: % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or Chris@82: % http://www.gnu.org/software/texinfo/ (the Texinfo home page) Chris@82: % The texinfo.tex in any given distribution could well be out Chris@82: % of date, so if that's what you're using, please check. Chris@82: % Chris@82: % Send bug reports to bug-texinfo@gnu.org. Please include including a Chris@82: % complete document in each bug report with which we can reproduce the Chris@82: % problem. Patches are, of course, greatly appreciated. Chris@82: % Chris@82: % To process a Texinfo manual with TeX, it's most reliable to use the Chris@82: % texi2dvi shell script that comes with the distribution. For a simple Chris@82: % manual foo.texi, however, you can get away with this: Chris@82: % tex foo.texi Chris@82: % texindex foo.?? Chris@82: % tex foo.texi Chris@82: % tex foo.texi Chris@82: % dvips foo.dvi -o # or whatever; this makes foo.ps. Chris@82: % The extra TeX runs get the cross-reference information correct. Chris@82: % Sometimes one run after texindex suffices, and sometimes you need more Chris@82: % than two; texi2dvi does it as many times as necessary. Chris@82: % Chris@82: % It is possible to adapt texinfo.tex for other languages, to some Chris@82: % extent. You can get the existing language-specific files from the Chris@82: % full Texinfo distribution. Chris@82: % Chris@82: % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. Chris@82: Chris@82: Chris@82: \message{Loading texinfo [version \texinfoversion]:} Chris@82: Chris@82: % If in a .fmt file, print the version number Chris@82: % and turn on active characters that we couldn't do earlier because Chris@82: % they might have appeared in the input file name. Chris@82: \everyjob{\message{[Texinfo version \texinfoversion]}% Chris@82: \catcode`+=\active \catcode`\_=\active} Chris@82: Chris@82: \chardef\other=12 Chris@82: Chris@82: % We never want plain's \outer definition of \+ in Texinfo. Chris@82: % For @tex, we can use \tabalign. Chris@82: \let\+ = \relax Chris@82: Chris@82: % Save some plain tex macros whose names we will redefine. Chris@82: \let\ptexb=\b Chris@82: \let\ptexbullet=\bullet Chris@82: \let\ptexc=\c Chris@82: \let\ptexcomma=\, Chris@82: \let\ptexdot=\. Chris@82: \let\ptexdots=\dots Chris@82: \let\ptexend=\end Chris@82: \let\ptexequiv=\equiv Chris@82: \let\ptexexclam=\! Chris@82: \let\ptexfootnote=\footnote Chris@82: \let\ptexgtr=> Chris@82: \let\ptexhat=^ Chris@82: \let\ptexi=\i Chris@82: \let\ptexindent=\indent Chris@82: \let\ptexinsert=\insert Chris@82: \let\ptexlbrace=\{ Chris@82: \let\ptexless=< Chris@82: \let\ptexnewwrite\newwrite Chris@82: \let\ptexnoindent=\noindent Chris@82: \let\ptexplus=+ Chris@82: \let\ptexraggedright=\raggedright Chris@82: \let\ptexrbrace=\} Chris@82: \let\ptexslash=\/ Chris@82: \let\ptexstar=\* Chris@82: \let\ptext=\t Chris@82: \let\ptextop=\top Chris@82: {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode Chris@82: Chris@82: % If this character appears in an error message or help string, it Chris@82: % starts a new line in the output. Chris@82: \newlinechar = `^^J Chris@82: Chris@82: % Use TeX 3.0's \inputlineno to get the line number, for better error Chris@82: % messages, but if we're using an old version of TeX, don't do anything. Chris@82: % Chris@82: \ifx\inputlineno\thisisundefined Chris@82: \let\linenumber = \empty % Pre-3.0. Chris@82: \else Chris@82: \def\linenumber{l.\the\inputlineno:\space} Chris@82: \fi Chris@82: Chris@82: % Set up fixed words for English if not already set. Chris@82: \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi Chris@82: \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi Chris@82: \ifx\putworderror\undefined \gdef\putworderror{error}\fi Chris@82: \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi Chris@82: \ifx\putwordin\undefined \gdef\putwordin{in}\fi Chris@82: \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi Chris@82: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi Chris@82: \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi Chris@82: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi Chris@82: \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi Chris@82: \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi Chris@82: \ifx\putwordof\undefined \gdef\putwordof{of}\fi Chris@82: \ifx\putwordon\undefined \gdef\putwordon{on}\fi Chris@82: \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi Chris@82: \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi Chris@82: \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi Chris@82: \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi Chris@82: \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi Chris@82: \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi Chris@82: \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi Chris@82: % Chris@82: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi Chris@82: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi Chris@82: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi Chris@82: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi Chris@82: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi Chris@82: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi Chris@82: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi Chris@82: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi Chris@82: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi Chris@82: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi Chris@82: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi Chris@82: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi Chris@82: % Chris@82: \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi Chris@82: \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi Chris@82: \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi Chris@82: \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi Chris@82: \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi Chris@82: Chris@82: % Since the category of space is not known, we have to be careful. Chris@82: \chardef\spacecat = 10 Chris@82: \def\spaceisspace{\catcode`\ =\spacecat} Chris@82: Chris@82: % sometimes characters are active, so we need control sequences. Chris@82: \chardef\ampChar = `\& Chris@82: \chardef\colonChar = `\: Chris@82: \chardef\commaChar = `\, Chris@82: \chardef\dashChar = `\- Chris@82: \chardef\dotChar = `\. Chris@82: \chardef\exclamChar= `\! Chris@82: \chardef\hashChar = `\# Chris@82: \chardef\lquoteChar= `\` Chris@82: \chardef\questChar = `\? Chris@82: \chardef\rquoteChar= `\' Chris@82: \chardef\semiChar = `\; Chris@82: \chardef\slashChar = `\/ Chris@82: \chardef\underChar = `\_ Chris@82: Chris@82: % Ignore a token. Chris@82: % Chris@82: \def\gobble#1{} Chris@82: Chris@82: % The following is used inside several \edef's. Chris@82: \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} Chris@82: Chris@82: % Hyphenation fixes. Chris@82: \hyphenation{ Chris@82: Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script Chris@82: ap-pen-dix bit-map bit-maps Chris@82: data-base data-bases eshell fall-ing half-way long-est man-u-script Chris@82: man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm Chris@82: par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces Chris@82: spell-ing spell-ings Chris@82: stand-alone strong-est time-stamp time-stamps which-ever white-space Chris@82: wide-spread wrap-around Chris@82: } Chris@82: Chris@82: % Margin to add to right of even pages, to left of odd pages. Chris@82: \newdimen\bindingoffset Chris@82: \newdimen\normaloffset Chris@82: \newdimen\pagewidth \newdimen\pageheight Chris@82: Chris@82: % For a final copy, take out the rectangles Chris@82: % that mark overfull boxes (in case you have decided Chris@82: % that the text looks ok even though it passes the margin). Chris@82: % Chris@82: \def\finalout{\overfullrule=0pt } Chris@82: Chris@82: % Sometimes it is convenient to have everything in the transcript file Chris@82: % and nothing on the terminal. We don't just call \tracingall here, Chris@82: % since that produces some useless output on the terminal. We also make Chris@82: % some effort to order the tracing commands to reduce output in the log Chris@82: % file; cf. trace.sty in LaTeX. Chris@82: % Chris@82: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% Chris@82: \def\loggingall{% Chris@82: \tracingstats2 Chris@82: \tracingpages1 Chris@82: \tracinglostchars2 % 2 gives us more in etex Chris@82: \tracingparagraphs1 Chris@82: \tracingoutput1 Chris@82: \tracingmacros2 Chris@82: \tracingrestores1 Chris@82: \showboxbreadth\maxdimen \showboxdepth\maxdimen Chris@82: \ifx\eTeXversion\thisisundefined\else % etex gives us more logging Chris@82: \tracingscantokens1 Chris@82: \tracingifs1 Chris@82: \tracinggroups1 Chris@82: \tracingnesting2 Chris@82: \tracingassigns1 Chris@82: \fi Chris@82: \tracingcommands3 % 3 gives us more in etex Chris@82: \errorcontextlines16 Chris@82: }% Chris@82: Chris@82: % @errormsg{MSG}. Do the index-like expansions on MSG, but if things Chris@82: % aren't perfect, it's not the end of the world, being an error message, Chris@82: % after all. Chris@82: % Chris@82: \def\errormsg{\begingroup \indexnofonts \doerrormsg} Chris@82: \def\doerrormsg#1{\errmessage{#1}} Chris@82: Chris@82: % add check for \lastpenalty to plain's definitions. If the last thing Chris@82: % we did was a \nobreak, we don't want to insert more space. Chris@82: % Chris@82: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount Chris@82: \removelastskip\penalty-50\smallskip\fi\fi} Chris@82: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount Chris@82: \removelastskip\penalty-100\medskip\fi\fi} Chris@82: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount Chris@82: \removelastskip\penalty-200\bigskip\fi\fi} Chris@82: Chris@82: % Do @cropmarks to get crop marks. Chris@82: % Chris@82: \newif\ifcropmarks Chris@82: \let\cropmarks = \cropmarkstrue Chris@82: % Chris@82: % Dimensions to add cropmarks at corners. Chris@82: % Added by P. A. MacKay, 12 Nov. 1986 Chris@82: % Chris@82: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines Chris@82: \newdimen\cornerlong \cornerlong=1pc Chris@82: \newdimen\cornerthick \cornerthick=.3pt Chris@82: \newdimen\topandbottommargin \topandbottommargin=.75in Chris@82: Chris@82: % Output a mark which sets \thischapter, \thissection and \thiscolor. Chris@82: % We dump everything together because we only have one kind of mark. Chris@82: % This works because we only use \botmark / \topmark, not \firstmark. Chris@82: % Chris@82: % A mark contains a subexpression of the \ifcase ... \fi construct. Chris@82: % \get*marks macros below extract the needed part using \ifcase. Chris@82: % Chris@82: % Another complication is to let the user choose whether \thischapter Chris@82: % (\thissection) refers to the chapter (section) in effect at the top Chris@82: % of a page, or that at the bottom of a page. The solution is Chris@82: % described on page 260 of The TeXbook. It involves outputting two Chris@82: % marks for the sectioning macros, one before the section break, and Chris@82: % one after. I won't pretend I can describe this better than DEK... Chris@82: \def\domark{% Chris@82: \toks0=\expandafter{\lastchapterdefs}% Chris@82: \toks2=\expandafter{\lastsectiondefs}% Chris@82: \toks4=\expandafter{\prevchapterdefs}% Chris@82: \toks6=\expandafter{\prevsectiondefs}% Chris@82: \toks8=\expandafter{\lastcolordefs}% Chris@82: \mark{% Chris@82: \the\toks0 \the\toks2 Chris@82: \noexpand\or \the\toks4 \the\toks6 Chris@82: \noexpand\else \the\toks8 Chris@82: }% Chris@82: } Chris@82: % \topmark doesn't work for the very first chapter (after the title Chris@82: % page or the contents), so we use \firstmark there -- this gets us Chris@82: % the mark with the chapter defs, unless the user sneaks in, e.g., Chris@82: % @setcolor (or @url, or @link, etc.) between @contents and the very Chris@82: % first @chapter. Chris@82: \def\gettopheadingmarks{% Chris@82: \ifcase0\topmark\fi Chris@82: \ifx\thischapter\empty \ifcase0\firstmark\fi \fi Chris@82: } Chris@82: \def\getbottomheadingmarks{\ifcase1\botmark\fi} Chris@82: \def\getcolormarks{\ifcase2\topmark\fi} Chris@82: Chris@82: % Avoid "undefined control sequence" errors. Chris@82: \def\lastchapterdefs{} Chris@82: \def\lastsectiondefs{} Chris@82: \def\prevchapterdefs{} Chris@82: \def\prevsectiondefs{} Chris@82: \def\lastcolordefs{} Chris@82: Chris@82: % Main output routine. Chris@82: \chardef\PAGE = 255 Chris@82: \output = {\onepageout{\pagecontents\PAGE}} Chris@82: Chris@82: \newbox\headlinebox Chris@82: \newbox\footlinebox Chris@82: Chris@82: % \onepageout takes a vbox as an argument. Note that \pagecontents Chris@82: % does insertions, but you have to call it yourself. Chris@82: \def\onepageout#1{% Chris@82: \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi Chris@82: % Chris@82: \ifodd\pageno \advance\hoffset by \bindingoffset Chris@82: \else \advance\hoffset by -\bindingoffset\fi Chris@82: % Chris@82: % Do this outside of the \shipout so @code etc. will be expanded in Chris@82: % the headline as they should be, not taken literally (outputting ''code). Chris@82: \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi Chris@82: \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% Chris@82: \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi Chris@82: \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% Chris@82: % Chris@82: {% Chris@82: % Have to do this stuff outside the \shipout because we want it to Chris@82: % take effect in \write's, yet the group defined by the \vbox ends Chris@82: % before the \shipout runs. Chris@82: % Chris@82: \indexdummies % don't expand commands in the output. Chris@82: \normalturnoffactive % \ in index entries must not stay \, e.g., if Chris@82: % the page break happens to be in the middle of an example. Chris@82: % We don't want .vr (or whatever) entries like this: Chris@82: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} Chris@82: % "\acronym" won't work when it's read back in; Chris@82: % it needs to be Chris@82: % {\code {{\tt \backslashcurfont }acronym} Chris@82: \shipout\vbox{% Chris@82: % Do this early so pdf references go to the beginning of the page. Chris@82: \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi Chris@82: % Chris@82: \ifcropmarks \vbox to \outervsize\bgroup Chris@82: \hsize = \outerhsize Chris@82: \vskip-\topandbottommargin Chris@82: \vtop to0pt{% Chris@82: \line{\ewtop\hfil\ewtop}% Chris@82: \nointerlineskip Chris@82: \line{% Chris@82: \vbox{\moveleft\cornerthick\nstop}% Chris@82: \hfill Chris@82: \vbox{\moveright\cornerthick\nstop}% Chris@82: }% Chris@82: \vss}% Chris@82: \vskip\topandbottommargin Chris@82: \line\bgroup Chris@82: \hfil % center the page within the outer (page) hsize. Chris@82: \ifodd\pageno\hskip\bindingoffset\fi Chris@82: \vbox\bgroup Chris@82: \fi Chris@82: % Chris@82: \unvbox\headlinebox Chris@82: \pagebody{#1}% Chris@82: \ifdim\ht\footlinebox > 0pt Chris@82: % Only leave this space if the footline is nonempty. Chris@82: % (We lessened \vsize for it in \oddfootingyyy.) Chris@82: % The \baselineskip=24pt in plain's \makefootline has no effect. Chris@82: \vskip 24pt Chris@82: \unvbox\footlinebox Chris@82: \fi Chris@82: % Chris@82: \ifcropmarks Chris@82: \egroup % end of \vbox\bgroup Chris@82: \hfil\egroup % end of (centering) \line\bgroup Chris@82: \vskip\topandbottommargin plus1fill minus1fill Chris@82: \boxmaxdepth = \cornerthick Chris@82: \vbox to0pt{\vss Chris@82: \line{% Chris@82: \vbox{\moveleft\cornerthick\nsbot}% Chris@82: \hfill Chris@82: \vbox{\moveright\cornerthick\nsbot}% Chris@82: }% Chris@82: \nointerlineskip Chris@82: \line{\ewbot\hfil\ewbot}% Chris@82: }% Chris@82: \egroup % \vbox from first cropmarks clause Chris@82: \fi Chris@82: }% end of \shipout\vbox Chris@82: }% end of group with \indexdummies Chris@82: \advancepageno Chris@82: \ifnum\outputpenalty>-20000 \else\dosupereject\fi Chris@82: } Chris@82: Chris@82: \newinsert\margin \dimen\margin=\maxdimen Chris@82: Chris@82: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} Chris@82: {\catcode`\@ =11 Chris@82: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi Chris@82: % marginal hacks, juha@viisa.uucp (Juha Takala) Chris@82: \ifvoid\margin\else % marginal info is present Chris@82: \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi Chris@82: \dimen@=\dp#1\relax \unvbox#1\relax Chris@82: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi Chris@82: \ifr@ggedbottom \kern-\dimen@ \vfil \fi} Chris@82: } Chris@82: Chris@82: % Here are the rules for the cropmarks. Note that they are Chris@82: % offset so that the space between them is truly \outerhsize or \outervsize Chris@82: % (P. A. MacKay, 12 November, 1986) Chris@82: % Chris@82: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} Chris@82: \def\nstop{\vbox Chris@82: {\hrule height\cornerthick depth\cornerlong width\cornerthick}} Chris@82: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} Chris@82: \def\nsbot{\vbox Chris@82: {\hrule height\cornerlong depth\cornerthick width\cornerthick}} Chris@82: Chris@82: % Parse an argument, then pass it to #1. The argument is the rest of Chris@82: % the input line (except we remove a trailing comment). #1 should be a Chris@82: % macro which expects an ordinary undelimited TeX argument. Chris@82: % Chris@82: \def\parsearg{\parseargusing{}} Chris@82: \def\parseargusing#1#2{% Chris@82: \def\argtorun{#2}% Chris@82: \begingroup Chris@82: \obeylines Chris@82: \spaceisspace Chris@82: #1% Chris@82: \parseargline\empty% Insert the \empty token, see \finishparsearg below. Chris@82: } Chris@82: Chris@82: {\obeylines % Chris@82: \gdef\parseargline#1^^M{% Chris@82: \endgroup % End of the group started in \parsearg. Chris@82: \argremovecomment #1\comment\ArgTerm% Chris@82: }% Chris@82: } Chris@82: Chris@82: % First remove any @comment, then any @c comment. Chris@82: \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} Chris@82: \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} Chris@82: Chris@82: % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. Chris@82: % Chris@82: % \argremovec might leave us with trailing space, e.g., Chris@82: % @end itemize @c foo Chris@82: % This space token undergoes the same procedure and is eventually removed Chris@82: % by \finishparsearg. Chris@82: % Chris@82: \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} Chris@82: \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} Chris@82: \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% Chris@82: \def\temp{#3}% Chris@82: \ifx\temp\empty Chris@82: % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: Chris@82: \let\temp\finishparsearg Chris@82: \else Chris@82: \let\temp\argcheckspaces Chris@82: \fi Chris@82: % Put the space token in: Chris@82: \temp#1 #3\ArgTerm Chris@82: } Chris@82: Chris@82: % If a _delimited_ argument is enclosed in braces, they get stripped; so Chris@82: % to get _exactly_ the rest of the line, we had to prevent such situation. Chris@82: % We prepended an \empty token at the very beginning and we expand it now, Chris@82: % just before passing the control to \argtorun. Chris@82: % (Similarly, we have to think about #3 of \argcheckspacesY above: it is Chris@82: % either the null string, or it ends with \^^M---thus there is no danger Chris@82: % that a pair of braces would be stripped. Chris@82: % Chris@82: % But first, we have to remove the trailing space token. Chris@82: % Chris@82: \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} Chris@82: Chris@82: % \parseargdef\foo{...} Chris@82: % is roughly equivalent to Chris@82: % \def\foo{\parsearg\Xfoo} Chris@82: % \def\Xfoo#1{...} Chris@82: % Chris@82: % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my Chris@82: % favourite TeX trick. --kasal, 16nov03 Chris@82: Chris@82: \def\parseargdef#1{% Chris@82: \expandafter \doparseargdef \csname\string#1\endcsname #1% Chris@82: } Chris@82: \def\doparseargdef#1#2{% Chris@82: \def#2{\parsearg#1}% Chris@82: \def#1##1% Chris@82: } Chris@82: Chris@82: % Several utility definitions with active space: Chris@82: { Chris@82: \obeyspaces Chris@82: \gdef\obeyedspace{ } Chris@82: Chris@82: % Make each space character in the input produce a normal interword Chris@82: % space in the output. Don't allow a line break at this space, as this Chris@82: % is used only in environments like @example, where each line of input Chris@82: % should produce a line of output anyway. Chris@82: % Chris@82: \gdef\sepspaces{\obeyspaces\let =\tie} Chris@82: Chris@82: % If an index command is used in an @example environment, any spaces Chris@82: % therein should become regular spaces in the raw index file, not the Chris@82: % expansion of \tie (\leavevmode \penalty \@M \ ). Chris@82: \gdef\unsepspaces{\let =\space} Chris@82: } Chris@82: Chris@82: Chris@82: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} Chris@82: Chris@82: % Define the framework for environments in texinfo.tex. It's used like this: Chris@82: % Chris@82: % \envdef\foo{...} Chris@82: % \def\Efoo{...} Chris@82: % Chris@82: % It's the responsibility of \envdef to insert \begingroup before the Chris@82: % actual body; @end closes the group after calling \Efoo. \envdef also Chris@82: % defines \thisenv, so the current environment is known; @end checks Chris@82: % whether the environment name matches. The \checkenv macro can also be Chris@82: % used to check whether the current environment is the one expected. Chris@82: % Chris@82: % Non-false conditionals (@iftex, @ifset) don't fit into this, so they Chris@82: % are not treated as environments; they don't open a group. (The Chris@82: % implementation of @end takes care not to call \endgroup in this Chris@82: % special case.) Chris@82: Chris@82: Chris@82: % At run-time, environments start with this: Chris@82: \def\startenvironment#1{\begingroup\def\thisenv{#1}} Chris@82: % initialize Chris@82: \let\thisenv\empty Chris@82: Chris@82: % ... but they get defined via ``\envdef\foo{...}'': Chris@82: \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} Chris@82: \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} Chris@82: Chris@82: % Check whether we're in the right environment: Chris@82: \def\checkenv#1{% Chris@82: \def\temp{#1}% Chris@82: \ifx\thisenv\temp Chris@82: \else Chris@82: \badenverr Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Environment mismatch, #1 expected: Chris@82: \def\badenverr{% Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{This command can appear only \inenvironment\temp, Chris@82: not \inenvironment\thisenv}% Chris@82: } Chris@82: \def\inenvironment#1{% Chris@82: \ifx#1\empty Chris@82: outside of any environment% Chris@82: \else Chris@82: in environment \expandafter\string#1% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @end foo executes the definition of \Efoo. Chris@82: % But first, it executes a specialized version of \checkenv Chris@82: % Chris@82: \parseargdef\end{% Chris@82: \if 1\csname iscond.#1\endcsname Chris@82: \else Chris@82: % The general wording of \badenverr may not be ideal. Chris@82: \expandafter\checkenv\csname#1\endcsname Chris@82: \csname E#1\endcsname Chris@82: \endgroup Chris@82: \fi Chris@82: } Chris@82: Chris@82: \newhelp\EMsimple{Press RETURN to continue.} Chris@82: Chris@82: Chris@82: % Be sure we're in horizontal mode when doing a tie, since we make space Chris@82: % equivalent to this in @example-like environments. Otherwise, a space Chris@82: % at the beginning of a line will start with \penalty -- and Chris@82: % since \penalty is valid in vertical mode, we'd end up putting the Chris@82: % penalty on the vertical list instead of in the new paragraph. Chris@82: {\catcode`@ = 11 Chris@82: % Avoid using \@M directly, because that causes trouble Chris@82: % if the definition is written into an index file. Chris@82: \global\let\tiepenalty = \@M Chris@82: \gdef\tie{\leavevmode\penalty\tiepenalty\ } Chris@82: } Chris@82: Chris@82: % @: forces normal size whitespace following. Chris@82: \def\:{\spacefactor=1000 } Chris@82: Chris@82: % @* forces a line break. Chris@82: \def\*{\unskip\hfil\break\hbox{}\ignorespaces} Chris@82: Chris@82: % @/ allows a line break. Chris@82: \let\/=\allowbreak Chris@82: Chris@82: % @. is an end-of-sentence period. Chris@82: \def\.{.\spacefactor=\endofsentencespacefactor\space} Chris@82: Chris@82: % @! is an end-of-sentence bang. Chris@82: \def\!{!\spacefactor=\endofsentencespacefactor\space} Chris@82: Chris@82: % @? is an end-of-sentence query. Chris@82: \def\?{?\spacefactor=\endofsentencespacefactor\space} Chris@82: Chris@82: % @frenchspacing on|off says whether to put extra space after punctuation. Chris@82: % Chris@82: \def\onword{on} Chris@82: \def\offword{off} Chris@82: % Chris@82: \parseargdef\frenchspacing{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\onword \plainfrenchspacing Chris@82: \else\ifx\temp\offword \plainnonfrenchspacing Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % @w prevents a word break. Without the \leavevmode, @w at the Chris@82: % beginning of a paragraph, when TeX is still in vertical mode, would Chris@82: % produce a whole line of output instead of starting the paragraph. Chris@82: \def\w#1{\leavevmode\hbox{#1}} Chris@82: Chris@82: % @group ... @end group forces ... to be all on one page, by enclosing Chris@82: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box Chris@82: % to keep its height that of a normal line. According to the rules for Chris@82: % \topskip (p.114 of the TeXbook), the glue inserted is Chris@82: % max (\topskip - \ht (first item), 0). If that height is large, Chris@82: % therefore, no glue is inserted, and the space between the headline and Chris@82: % the text is small, which looks bad. Chris@82: % Chris@82: % Another complication is that the group might be very large. This can Chris@82: % cause the glue on the previous page to be unduly stretched, because it Chris@82: % does not have much material. In this case, it's better to add an Chris@82: % explicit \vfill so that the extra space is at the bottom. The Chris@82: % threshold for doing this is if the group is more than \vfilllimit Chris@82: % percent of a page (\vfilllimit can be changed inside of @tex). Chris@82: % Chris@82: \newbox\groupbox Chris@82: \def\vfilllimit{0.7} Chris@82: % Chris@82: \envdef\group{% Chris@82: \ifnum\catcode`\^^M=\active \else Chris@82: \errhelp = \groupinvalidhelp Chris@82: \errmessage{@group invalid in context where filling is enabled}% Chris@82: \fi Chris@82: \startsavinginserts Chris@82: % Chris@82: \setbox\groupbox = \vtop\bgroup Chris@82: % Do @comment since we are called inside an environment such as Chris@82: % @example, where each end-of-line in the input causes an Chris@82: % end-of-line in the output. We don't want the end-of-line after Chris@82: % the `@group' to put extra space in the output. Since @group Chris@82: % should appear on a line by itself (according to the Texinfo Chris@82: % manual), we don't worry about eating any user text. Chris@82: \comment Chris@82: } Chris@82: % Chris@82: % The \vtop produces a box with normal height and large depth; thus, TeX puts Chris@82: % \baselineskip glue before it, and (when the next line of text is done) Chris@82: % \lineskip glue after it. Thus, space below is not quite equal to space Chris@82: % above. But it's pretty close. Chris@82: \def\Egroup{% Chris@82: % To get correct interline space between the last line of the group Chris@82: % and the first line afterwards, we have to propagate \prevdepth. Chris@82: \endgraf % Not \par, as it may have been set to \lisppar. Chris@82: \global\dimen1 = \prevdepth Chris@82: \egroup % End the \vtop. Chris@82: % \dimen0 is the vertical size of the group's box. Chris@82: \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox Chris@82: % \dimen2 is how much space is left on the page (more or less). Chris@82: \dimen2 = \pageheight \advance\dimen2 by -\pagetotal Chris@82: % if the group doesn't fit on the current page, and it's a big big Chris@82: % group, force a page break. Chris@82: \ifdim \dimen0 > \dimen2 Chris@82: \ifdim \pagetotal < \vfilllimit\pageheight Chris@82: \page Chris@82: \fi Chris@82: \fi Chris@82: \box\groupbox Chris@82: \prevdepth = \dimen1 Chris@82: \checkinserts Chris@82: } Chris@82: % Chris@82: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help Chris@82: % message, so this ends up printing `@group can only ...'. Chris@82: % Chris@82: \newhelp\groupinvalidhelp{% Chris@82: group can only be used in environments such as @example,^^J% Chris@82: where each line of input produces a line of output.} Chris@82: Chris@82: % @need space-in-mils Chris@82: % forces a page break if there is not space-in-mils remaining. Chris@82: Chris@82: \newdimen\mil \mil=0.001in Chris@82: Chris@82: \parseargdef\need{% Chris@82: % Ensure vertical mode, so we don't make a big box in the middle of a Chris@82: % paragraph. Chris@82: \par Chris@82: % Chris@82: % If the @need value is less than one line space, it's useless. Chris@82: \dimen0 = #1\mil Chris@82: \dimen2 = \ht\strutbox Chris@82: \advance\dimen2 by \dp\strutbox Chris@82: \ifdim\dimen0 > \dimen2 Chris@82: % Chris@82: % Do a \strut just to make the height of this box be normal, so the Chris@82: % normal leading is inserted relative to the preceding line. Chris@82: % And a page break here is fine. Chris@82: \vtop to #1\mil{\strut\vfil}% Chris@82: % Chris@82: % TeX does not even consider page breaks if a penalty added to the Chris@82: % main vertical list is 10000 or more. But in order to see if the Chris@82: % empty box we just added fits on the page, we must make it consider Chris@82: % page breaks. On the other hand, we don't want to actually break the Chris@82: % page after the empty box. So we use a penalty of 9999. Chris@82: % Chris@82: % There is an extremely small chance that TeX will actually break the Chris@82: % page at this \penalty, if there are no other feasible breakpoints in Chris@82: % sight. (If the user is using lots of big @group commands, which Chris@82: % almost-but-not-quite fill up a page, TeX will have a hard time doing Chris@82: % good page breaking, for example.) However, I could not construct an Chris@82: % example where a page broke at this \penalty; if it happens in a real Chris@82: % document, then we can reconsider our strategy. Chris@82: \penalty9999 Chris@82: % Chris@82: % Back up by the size of the box, whether we did a page break or not. Chris@82: \kern -#1\mil Chris@82: % Chris@82: % Do not allow a page break right after this kern. Chris@82: \nobreak Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @br forces paragraph break (and is undocumented). Chris@82: Chris@82: \let\br = \par Chris@82: Chris@82: % @page forces the start of a new page. Chris@82: % Chris@82: \def\page{\par\vfill\supereject} Chris@82: Chris@82: % @exdent text.... Chris@82: % outputs text on separate line in roman font, starting at standard page margin Chris@82: Chris@82: % This records the amount of indent in the innermost environment. Chris@82: % That's how much \exdent should take out. Chris@82: \newskip\exdentamount Chris@82: Chris@82: % This defn is used inside fill environments such as @defun. Chris@82: \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} Chris@82: Chris@82: % This defn is used inside nofill environments such as @example. Chris@82: \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount Chris@82: \leftline{\hskip\leftskip{\rm#1}}}} Chris@82: Chris@82: % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current Chris@82: % paragraph. For more general purposes, use the \margin insertion Chris@82: % class. WHICH is `l' or `r'. Not documented, written for gawk manual. Chris@82: % Chris@82: \newskip\inmarginspacing \inmarginspacing=1cm Chris@82: \def\strutdepth{\dp\strutbox} Chris@82: % Chris@82: \def\doinmargin#1#2{\strut\vadjust{% Chris@82: \nobreak Chris@82: \kern-\strutdepth Chris@82: \vtop to \strutdepth{% Chris@82: \baselineskip=\strutdepth Chris@82: \vss Chris@82: % if you have multiple lines of stuff to put here, you'll need to Chris@82: % make the vbox yourself of the appropriate size. Chris@82: \ifx#1l% Chris@82: \llap{\ignorespaces #2\hskip\inmarginspacing}% Chris@82: \else Chris@82: \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% Chris@82: \fi Chris@82: \null Chris@82: }% Chris@82: }} Chris@82: \def\inleftmargin{\doinmargin l} Chris@82: \def\inrightmargin{\doinmargin r} Chris@82: % Chris@82: % @inmargin{TEXT [, RIGHT-TEXT]} Chris@82: % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; Chris@82: % else use TEXT for both). Chris@82: % Chris@82: \def\inmargin#1{\parseinmargin #1,,\finish} Chris@82: \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. Chris@82: \setbox0 = \hbox{\ignorespaces #2}% Chris@82: \ifdim\wd0 > 0pt Chris@82: \def\lefttext{#1}% have both texts Chris@82: \def\righttext{#2}% Chris@82: \else Chris@82: \def\lefttext{#1}% have only one text Chris@82: \def\righttext{#1}% Chris@82: \fi Chris@82: % Chris@82: \ifodd\pageno Chris@82: \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin Chris@82: \else Chris@82: \def\temp{\inleftmargin\lefttext}% Chris@82: \fi Chris@82: \temp Chris@82: } Chris@82: Chris@82: % @| inserts a changebar to the left of the current line. It should Chris@82: % surround any changed text. This approach does *not* work if the Chris@82: % change spans more than two lines of output. To handle that, we would Chris@82: % have adopt a much more difficult approach (putting marks into the main Chris@82: % vertical list for the beginning and end of each change). This command Chris@82: % is not documented, not supported, and doesn't work. Chris@82: % Chris@82: \def\|{% Chris@82: % \vadjust can only be used in horizontal mode. Chris@82: \leavevmode Chris@82: % Chris@82: % Append this vertical mode material after the current line in the output. Chris@82: \vadjust{% Chris@82: % We want to insert a rule with the height and depth of the current Chris@82: % leading; that is exactly what \strutbox is supposed to record. Chris@82: \vskip-\baselineskip Chris@82: % Chris@82: % \vadjust-items are inserted at the left edge of the type. So Chris@82: % the \llap here moves out into the left-hand margin. Chris@82: \llap{% Chris@82: % Chris@82: % For a thicker or thinner bar, change the `1pt'. Chris@82: \vrule height\baselineskip width1pt Chris@82: % Chris@82: % This is the space between the bar and the text. Chris@82: \hskip 12pt Chris@82: }% Chris@82: }% Chris@82: } Chris@82: Chris@82: % @include FILE -- \input text of FILE. Chris@82: % Chris@82: \def\include{\parseargusing\filenamecatcodes\includezzz} Chris@82: \def\includezzz#1{% Chris@82: \pushthisfilestack Chris@82: \def\thisfile{#1}% Chris@82: {% Chris@82: \makevalueexpandable % we want to expand any @value in FILE. Chris@82: \turnoffactive % and allow special characters in the expansion Chris@82: \indexnofonts % Allow `@@' and other weird things in file names. Chris@82: \wlog{texinfo.tex: doing @include of #1^^J}% Chris@82: \edef\temp{\noexpand\input #1 }% Chris@82: % Chris@82: % This trickery is to read FILE outside of a group, in case it makes Chris@82: % definitions, etc. Chris@82: \expandafter Chris@82: }\temp Chris@82: \popthisfilestack Chris@82: } Chris@82: \def\filenamecatcodes{% Chris@82: \catcode`\\=\other Chris@82: \catcode`~=\other Chris@82: \catcode`^=\other Chris@82: \catcode`_=\other Chris@82: \catcode`|=\other Chris@82: \catcode`<=\other Chris@82: \catcode`>=\other Chris@82: \catcode`+=\other Chris@82: \catcode`-=\other Chris@82: \catcode`\`=\other Chris@82: \catcode`\'=\other Chris@82: } Chris@82: Chris@82: \def\pushthisfilestack{% Chris@82: \expandafter\pushthisfilestackX\popthisfilestack\StackTerm Chris@82: } Chris@82: \def\pushthisfilestackX{% Chris@82: \expandafter\pushthisfilestackY\thisfile\StackTerm Chris@82: } Chris@82: \def\pushthisfilestackY #1\StackTerm #2\StackTerm {% Chris@82: \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% Chris@82: } Chris@82: Chris@82: \def\popthisfilestack{\errthisfilestackempty} Chris@82: \def\errthisfilestackempty{\errmessage{Internal error: Chris@82: the stack of filenames is empty.}} Chris@82: % Chris@82: \def\thisfile{} Chris@82: Chris@82: % @center line Chris@82: % outputs that line, centered. Chris@82: % Chris@82: \parseargdef\center{% Chris@82: \ifhmode Chris@82: \let\centersub\centerH Chris@82: \else Chris@82: \let\centersub\centerV Chris@82: \fi Chris@82: \centersub{\hfil \ignorespaces#1\unskip \hfil}% Chris@82: \let\centersub\relax % don't let the definition persist, just in case Chris@82: } Chris@82: \def\centerH#1{{% Chris@82: \hfil\break Chris@82: \advance\hsize by -\leftskip Chris@82: \advance\hsize by -\rightskip Chris@82: \line{#1}% Chris@82: \break Chris@82: }} Chris@82: % Chris@82: \newcount\centerpenalty Chris@82: \def\centerV#1{% Chris@82: % The idea here is the same as in \startdefun, \cartouche, etc.: if Chris@82: % @center is the first thing after a section heading, we need to wipe Chris@82: % out the negative parskip inserted by \sectionheading, but still Chris@82: % prevent a page break here. Chris@82: \centerpenalty = \lastpenalty Chris@82: \ifnum\centerpenalty>10000 \vskip\parskip \fi Chris@82: \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi Chris@82: \line{\kern\leftskip #1\kern\rightskip}% Chris@82: } Chris@82: Chris@82: % @sp n outputs n lines of vertical space Chris@82: % Chris@82: \parseargdef\sp{\vskip #1\baselineskip} Chris@82: Chris@82: % @comment ...line which is ignored... Chris@82: % @c is the same as @comment Chris@82: % @ignore ... @end ignore is another way to write a comment Chris@82: % Chris@82: \def\comment{\begingroup \catcode`\^^M=\other% Chris@82: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% Chris@82: \commentxxx} Chris@82: {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} Chris@82: % Chris@82: \let\c=\comment Chris@82: Chris@82: % @paragraphindent NCHARS Chris@82: % We'll use ems for NCHARS, close enough. Chris@82: % NCHARS can also be the word `asis' or `none'. Chris@82: % We cannot feasibly implement @paragraphindent asis, though. Chris@82: % Chris@82: \def\asisword{asis} % no translation, these are keywords Chris@82: \def\noneword{none} Chris@82: % Chris@82: \parseargdef\paragraphindent{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\asisword Chris@82: \else Chris@82: \ifx\temp\noneword Chris@82: \defaultparindent = 0pt Chris@82: \else Chris@82: \defaultparindent = #1em Chris@82: \fi Chris@82: \fi Chris@82: \parindent = \defaultparindent Chris@82: } Chris@82: Chris@82: % @exampleindent NCHARS Chris@82: % We'll use ems for NCHARS like @paragraphindent. Chris@82: % It seems @exampleindent asis isn't necessary, but Chris@82: % I preserve it to make it similar to @paragraphindent. Chris@82: \parseargdef\exampleindent{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\asisword Chris@82: \else Chris@82: \ifx\temp\noneword Chris@82: \lispnarrowing = 0pt Chris@82: \else Chris@82: \lispnarrowing = #1em Chris@82: \fi Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @firstparagraphindent WORD Chris@82: % If WORD is `none', then suppress indentation of the first paragraph Chris@82: % after a section heading. If WORD is `insert', then do indent at such Chris@82: % paragraphs. Chris@82: % Chris@82: % The paragraph indentation is suppressed or not by calling Chris@82: % \suppressfirstparagraphindent, which the sectioning commands do. Chris@82: % We switch the definition of this back and forth according to WORD. Chris@82: % By default, we suppress indentation. Chris@82: % Chris@82: \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} Chris@82: \def\insertword{insert} Chris@82: % Chris@82: \parseargdef\firstparagraphindent{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\noneword Chris@82: \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent Chris@82: \else\ifx\temp\insertword Chris@82: \let\suppressfirstparagraphindent = \relax Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @firstparagraphindent option `\temp'}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % Here is how we actually suppress indentation. Redefine \everypar to Chris@82: % \kern backwards by \parindent, and then reset itself to empty. Chris@82: % Chris@82: % We also make \indent itself not actually do anything until the next Chris@82: % paragraph. Chris@82: % Chris@82: \gdef\dosuppressfirstparagraphindent{% Chris@82: \gdef\indent{% Chris@82: \restorefirstparagraphindent Chris@82: \indent Chris@82: }% Chris@82: \gdef\noindent{% Chris@82: \restorefirstparagraphindent Chris@82: \noindent Chris@82: }% Chris@82: \global\everypar = {% Chris@82: \kern -\parindent Chris@82: \restorefirstparagraphindent Chris@82: }% Chris@82: } Chris@82: Chris@82: \gdef\restorefirstparagraphindent{% Chris@82: \global \let \indent = \ptexindent Chris@82: \global \let \noindent = \ptexnoindent Chris@82: \global \everypar = {}% Chris@82: } Chris@82: Chris@82: Chris@82: % @refill is a no-op. Chris@82: \let\refill=\relax Chris@82: Chris@82: % If working on a large document in chapters, it is convenient to Chris@82: % be able to disable indexing, cross-referencing, and contents, for test runs. Chris@82: % This is done with @novalidate (before @setfilename). Chris@82: % Chris@82: \newif\iflinks \linkstrue % by default we want the aux files. Chris@82: \let\novalidate = \linksfalse Chris@82: Chris@82: % @setfilename is done at the beginning of every texinfo file. Chris@82: % So open here the files we need to have open while reading the input. Chris@82: % This makes it possible to make a .fmt file for texinfo. Chris@82: \def\setfilename{% Chris@82: \fixbackslash % Turn off hack to swallow `\input texinfo'. Chris@82: \iflinks Chris@82: \tryauxfile Chris@82: % Open the new aux file. TeX will close it automatically at exit. Chris@82: \immediate\openout\auxfile=\jobname.aux Chris@82: \fi % \openindices needs to do some work in any case. Chris@82: \openindices Chris@82: \let\setfilename=\comment % Ignore extra @setfilename cmds. Chris@82: % Chris@82: % If texinfo.cnf is present on the system, read it. Chris@82: % Useful for site-wide @afourpaper, etc. Chris@82: \openin 1 texinfo.cnf Chris@82: \ifeof 1 \else \input texinfo.cnf \fi Chris@82: \closein 1 Chris@82: % Chris@82: \comment % Ignore the actual filename. Chris@82: } Chris@82: Chris@82: % Called from \setfilename. Chris@82: % Chris@82: \def\openindices{% Chris@82: \newindex{cp}% Chris@82: \newcodeindex{fn}% Chris@82: \newcodeindex{vr}% Chris@82: \newcodeindex{tp}% Chris@82: \newcodeindex{ky}% Chris@82: \newcodeindex{pg}% Chris@82: } Chris@82: Chris@82: % @bye. Chris@82: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} Chris@82: Chris@82: Chris@82: \message{pdf,} Chris@82: % adobe `portable' document format Chris@82: \newcount\tempnum Chris@82: \newcount\lnkcount Chris@82: \newtoks\filename Chris@82: \newcount\filenamelength Chris@82: \newcount\pgn Chris@82: \newtoks\toksA Chris@82: \newtoks\toksB Chris@82: \newtoks\toksC Chris@82: \newtoks\toksD Chris@82: \newbox\boxA Chris@82: \newcount\countA Chris@82: \newif\ifpdf Chris@82: \newif\ifpdfmakepagedest Chris@82: Chris@82: % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 Chris@82: % can be set). So we test for \relax and 0 as well as being undefined. Chris@82: \ifx\pdfoutput\thisisundefined Chris@82: \else Chris@82: \ifx\pdfoutput\relax Chris@82: \else Chris@82: \ifcase\pdfoutput Chris@82: \else Chris@82: \pdftrue Chris@82: \fi Chris@82: \fi Chris@82: \fi Chris@82: Chris@82: % PDF uses PostScript string constants for the names of xref targets, Chris@82: % for display in the outlines, and in other places. Thus, we have to Chris@82: % double any backslashes. Otherwise, a name like "\node" will be Chris@82: % interpreted as a newline (\n), followed by o, d, e. Not good. Chris@82: % Chris@82: % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and Chris@82: % related messages. The final outcome is that it is up to the TeX user Chris@82: % to double the backslashes and otherwise make the string valid, so Chris@82: % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to Chris@82: % do this reliably, so we use it. Chris@82: Chris@82: % #1 is a control sequence in which to do the replacements, Chris@82: % which we \xdef. Chris@82: \def\txiescapepdf#1{% Chris@82: \ifx\pdfescapestring\thisisundefined Chris@82: % No primitive available; should we give a warning or log? Chris@82: % Many times it won't matter. Chris@82: \else Chris@82: % The expandable \pdfescapestring primitive escapes parentheses, Chris@82: % backslashes, and other special chars. Chris@82: \xdef#1{\pdfescapestring{#1}}% Chris@82: \fi Chris@82: } Chris@82: Chris@82: \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images Chris@82: with PDF output, and none of those formats could be found. (.eps cannot Chris@82: be supported due to the design of the PDF format; use regular TeX (DVI Chris@82: output) for that.)} Chris@82: Chris@82: \ifpdf Chris@82: % Chris@82: % Color manipulation macros based on pdfcolor.tex, Chris@82: % except using rgb instead of cmyk; the latter is said to render as a Chris@82: % very dark gray on-screen and a very dark halftone in print, instead Chris@82: % of actual black. Chris@82: \def\rgbDarkRed{0.50 0.09 0.12} Chris@82: \def\rgbBlack{0 0 0} Chris@82: % Chris@82: % k sets the color for filling (usual text, etc.); Chris@82: % K sets the color for stroking (thin rules, e.g., normal _'s). Chris@82: \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} Chris@82: % Chris@82: % Set color, and create a mark which defines \thiscolor accordingly, Chris@82: % so that \makeheadline knows which color to restore. Chris@82: \def\setcolor#1{% Chris@82: \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% Chris@82: \domark Chris@82: \pdfsetcolor{#1}% Chris@82: } Chris@82: % Chris@82: \def\maincolor{\rgbBlack} Chris@82: \pdfsetcolor{\maincolor} Chris@82: \edef\thiscolor{\maincolor} Chris@82: \def\lastcolordefs{} Chris@82: % Chris@82: \def\makefootline{% Chris@82: \baselineskip24pt Chris@82: \line{\pdfsetcolor{\maincolor}\the\footline}% Chris@82: } Chris@82: % Chris@82: \def\makeheadline{% Chris@82: \vbox to 0pt{% Chris@82: \vskip-22.5pt Chris@82: \line{% Chris@82: \vbox to8.5pt{}% Chris@82: % Extract \thiscolor definition from the marks. Chris@82: \getcolormarks Chris@82: % Typeset the headline with \maincolor, then restore the color. Chris@82: \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% Chris@82: }% Chris@82: \vss Chris@82: }% Chris@82: \nointerlineskip Chris@82: } Chris@82: % Chris@82: % Chris@82: \pdfcatalog{/PageMode /UseOutlines} Chris@82: % Chris@82: % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). Chris@82: \def\dopdfimage#1#2#3{% Chris@82: \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% Chris@82: \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% Chris@82: % Chris@82: % pdftex (and the PDF format) support .pdf, .png, .jpg (among Chris@82: % others). Let's try in that order, PDF first since if Chris@82: % someone has a scalable image, presumably better to use that than a Chris@82: % bitmap. Chris@82: \let\pdfimgext=\empty Chris@82: \begingroup Chris@82: \openin 1 #1.pdf \ifeof 1 Chris@82: \openin 1 #1.PDF \ifeof 1 Chris@82: \openin 1 #1.png \ifeof 1 Chris@82: \openin 1 #1.jpg \ifeof 1 Chris@82: \openin 1 #1.jpeg \ifeof 1 Chris@82: \openin 1 #1.JPG \ifeof 1 Chris@82: \errhelp = \nopdfimagehelp Chris@82: \errmessage{Could not find image file #1 for pdf}% Chris@82: \else \gdef\pdfimgext{JPG}% Chris@82: \fi Chris@82: \else \gdef\pdfimgext{jpeg}% Chris@82: \fi Chris@82: \else \gdef\pdfimgext{jpg}% Chris@82: \fi Chris@82: \else \gdef\pdfimgext{png}% Chris@82: \fi Chris@82: \else \gdef\pdfimgext{PDF}% Chris@82: \fi Chris@82: \else \gdef\pdfimgext{pdf}% Chris@82: \fi Chris@82: \closein 1 Chris@82: \endgroup Chris@82: % Chris@82: % without \immediate, ancient pdftex seg faults when the same image is Chris@82: % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) Chris@82: \ifnum\pdftexversion < 14 Chris@82: \immediate\pdfimage Chris@82: \else Chris@82: \immediate\pdfximage Chris@82: \fi Chris@82: \ifdim \wd0 >0pt width \pdfimagewidth \fi Chris@82: \ifdim \wd2 >0pt height \pdfimageheight \fi Chris@82: \ifnum\pdftexversion<13 Chris@82: #1.\pdfimgext Chris@82: \else Chris@82: {#1.\pdfimgext}% Chris@82: \fi Chris@82: \ifnum\pdftexversion < 14 \else Chris@82: \pdfrefximage \pdflastximage Chris@82: \fi} Chris@82: % Chris@82: \def\pdfmkdest#1{{% Chris@82: % We have to set dummies so commands such as @code, and characters Chris@82: % such as \, aren't expanded when present in a section title. Chris@82: \indexnofonts Chris@82: \turnoffactive Chris@82: \makevalueexpandable Chris@82: \def\pdfdestname{#1}% Chris@82: \txiescapepdf\pdfdestname Chris@82: \safewhatsit{\pdfdest name{\pdfdestname} xyz}% Chris@82: }} Chris@82: % Chris@82: % used to mark target names; must be expandable. Chris@82: \def\pdfmkpgn#1{#1} Chris@82: % Chris@82: % by default, use a color that is dark enough to print on paper as Chris@82: % nearly black, but still distinguishable for online viewing. Chris@82: \def\urlcolor{\rgbDarkRed} Chris@82: \def\linkcolor{\rgbDarkRed} Chris@82: \def\endlink{\setcolor{\maincolor}\pdfendlink} Chris@82: % Chris@82: % Adding outlines to PDF; macros for calculating structure of outlines Chris@82: % come from Petr Olsak Chris@82: \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% Chris@82: \else \csname#1\endcsname \fi} Chris@82: \def\advancenumber#1{\tempnum=\expnumber{#1}\relax Chris@82: \advance\tempnum by 1 Chris@82: \expandafter\xdef\csname#1\endcsname{\the\tempnum}} Chris@82: % Chris@82: % #1 is the section text, which is what will be displayed in the Chris@82: % outline by the pdf viewer. #2 is the pdf expression for the number Chris@82: % of subentries (or empty, for subsubsections). #3 is the node text, Chris@82: % which might be empty if this toc entry had no corresponding node. Chris@82: % #4 is the page number Chris@82: % Chris@82: \def\dopdfoutline#1#2#3#4{% Chris@82: % Generate a link to the node text if that exists; else, use the Chris@82: % page number. We could generate a destination for the section Chris@82: % text in the case where a section has no node, but it doesn't Chris@82: % seem worth the trouble, since most documents are normally structured. Chris@82: \edef\pdfoutlinedest{#3}% Chris@82: \ifx\pdfoutlinedest\empty Chris@82: \def\pdfoutlinedest{#4}% Chris@82: \else Chris@82: \txiescapepdf\pdfoutlinedest Chris@82: \fi Chris@82: % Chris@82: % Also escape PDF chars in the display string. Chris@82: \edef\pdfoutlinetext{#1}% Chris@82: \txiescapepdf\pdfoutlinetext Chris@82: % Chris@82: \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% Chris@82: } Chris@82: % Chris@82: \def\pdfmakeoutlines{% Chris@82: \begingroup Chris@82: % Read toc silently, to get counts of subentries for \pdfoutline. Chris@82: \def\partentry##1##2##3##4{}% ignore parts in the outlines Chris@82: \def\numchapentry##1##2##3##4{% Chris@82: \def\thischapnum{##2}% Chris@82: \def\thissecnum{0}% Chris@82: \def\thissubsecnum{0}% Chris@82: }% Chris@82: \def\numsecentry##1##2##3##4{% Chris@82: \advancenumber{chap\thischapnum}% Chris@82: \def\thissecnum{##2}% Chris@82: \def\thissubsecnum{0}% Chris@82: }% Chris@82: \def\numsubsecentry##1##2##3##4{% Chris@82: \advancenumber{sec\thissecnum}% Chris@82: \def\thissubsecnum{##2}% Chris@82: }% Chris@82: \def\numsubsubsecentry##1##2##3##4{% Chris@82: \advancenumber{subsec\thissubsecnum}% Chris@82: }% Chris@82: \def\thischapnum{0}% Chris@82: \def\thissecnum{0}% Chris@82: \def\thissubsecnum{0}% Chris@82: % Chris@82: % use \def rather than \let here because we redefine \chapentry et Chris@82: % al. a second time, below. Chris@82: \def\appentry{\numchapentry}% Chris@82: \def\appsecentry{\numsecentry}% Chris@82: \def\appsubsecentry{\numsubsecentry}% Chris@82: \def\appsubsubsecentry{\numsubsubsecentry}% Chris@82: \def\unnchapentry{\numchapentry}% Chris@82: \def\unnsecentry{\numsecentry}% Chris@82: \def\unnsubsecentry{\numsubsecentry}% Chris@82: \def\unnsubsubsecentry{\numsubsubsecentry}% Chris@82: \readdatafile{toc}% Chris@82: % Chris@82: % Read toc second time, this time actually producing the outlines. Chris@82: % The `-' means take the \expnumber as the absolute number of Chris@82: % subentries, which we calculated on our first read of the .toc above. Chris@82: % Chris@82: % We use the node names as the destinations. Chris@82: \def\numchapentry##1##2##3##4{% Chris@82: \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% Chris@82: \def\numsecentry##1##2##3##4{% Chris@82: \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% Chris@82: \def\numsubsecentry##1##2##3##4{% Chris@82: \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% Chris@82: \def\numsubsubsecentry##1##2##3##4{% count is always zero Chris@82: \dopdfoutline{##1}{}{##3}{##4}}% Chris@82: % Chris@82: % PDF outlines are displayed using system fonts, instead of Chris@82: % document fonts. Therefore we cannot use special characters, Chris@82: % since the encoding is unknown. For example, the eogonek from Chris@82: % Latin 2 (0xea) gets translated to a | character. Info from Chris@82: % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. Chris@82: % Chris@82: % TODO this right, we have to translate 8-bit characters to Chris@82: % their "best" equivalent, based on the @documentencoding. Too Chris@82: % much work for too little return. Just use the ASCII equivalents Chris@82: % we use for the index sort strings. Chris@82: % Chris@82: \indexnofonts Chris@82: \setupdatafile Chris@82: % We can have normal brace characters in the PDF outlines, unlike Chris@82: % Texinfo index files. So set that up. Chris@82: \def\{{\lbracecharliteral}% Chris@82: \def\}{\rbracecharliteral}% Chris@82: \catcode`\\=\active \otherbackslash Chris@82: \input \tocreadfilename Chris@82: \endgroup Chris@82: } Chris@82: {\catcode`[=1 \catcode`]=2 Chris@82: \catcode`{=\other \catcode`}=\other Chris@82: \gdef\lbracecharliteral[{]% Chris@82: \gdef\rbracecharliteral[}]% Chris@82: ] Chris@82: % Chris@82: \def\skipspaces#1{\def\PP{#1}\def\D{|}% Chris@82: \ifx\PP\D\let\nextsp\relax Chris@82: \else\let\nextsp\skipspaces Chris@82: \addtokens{\filename}{\PP}% Chris@82: \advance\filenamelength by 1 Chris@82: \fi Chris@82: \nextsp} Chris@82: \def\getfilename#1{% Chris@82: \filenamelength=0 Chris@82: % If we don't expand the argument now, \skipspaces will get Chris@82: % snagged on things like "@value{foo}". Chris@82: \edef\temp{#1}% Chris@82: \expandafter\skipspaces\temp|\relax Chris@82: } Chris@82: \ifnum\pdftexversion < 14 Chris@82: \let \startlink \pdfannotlink Chris@82: \else Chris@82: \let \startlink \pdfstartlink Chris@82: \fi Chris@82: % make a live url in pdf output. Chris@82: \def\pdfurl#1{% Chris@82: \begingroup Chris@82: % it seems we really need yet another set of dummies; have not Chris@82: % tried to figure out what each command should do in the context Chris@82: % of @url. for now, just make @/ a no-op, that's the only one Chris@82: % people have actually reported a problem with. Chris@82: % Chris@82: \normalturnoffactive Chris@82: \def\@{@}% Chris@82: \let\/=\empty Chris@82: \makevalueexpandable Chris@82: % do we want to go so far as to use \indexnofonts instead of just Chris@82: % special-casing \var here? Chris@82: \def\var##1{##1}% Chris@82: % Chris@82: \leavevmode\setcolor{\urlcolor}% Chris@82: \startlink attr{/Border [0 0 0]}% Chris@82: user{/Subtype /Link /A << /S /URI /URI (#1) >>}% Chris@82: \endgroup} Chris@82: \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} Chris@82: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} Chris@82: \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} Chris@82: \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} Chris@82: \def\maketoks{% Chris@82: \expandafter\poptoks\the\toksA|ENDTOKS|\relax Chris@82: \ifx\first0\adn0 Chris@82: \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 Chris@82: \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 Chris@82: \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 Chris@82: \else Chris@82: \ifnum0=\countA\else\makelink\fi Chris@82: \ifx\first.\let\next=\done\else Chris@82: \let\next=\maketoks Chris@82: \addtokens{\toksB}{\the\toksD} Chris@82: \ifx\first,\addtokens{\toksB}{\space}\fi Chris@82: \fi Chris@82: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi Chris@82: \next} Chris@82: \def\makelink{\addtokens{\toksB}% Chris@82: {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} Chris@82: \def\pdflink#1{% Chris@82: \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} Chris@82: \setcolor{\linkcolor}#1\endlink} Chris@82: \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} Chris@82: \else Chris@82: % non-pdf mode Chris@82: \let\pdfmkdest = \gobble Chris@82: \let\pdfurl = \gobble Chris@82: \let\endlink = \relax Chris@82: \let\setcolor = \gobble Chris@82: \let\pdfsetcolor = \gobble Chris@82: \let\pdfmakeoutlines = \relax Chris@82: \fi % \ifx\pdfoutput Chris@82: Chris@82: Chris@82: \message{fonts,} Chris@82: Chris@82: % Change the current font style to #1, remembering it in \curfontstyle. Chris@82: % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in Chris@82: % italics, not bold italics. Chris@82: % Chris@82: \def\setfontstyle#1{% Chris@82: \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. Chris@82: \csname ten#1\endcsname % change the current font Chris@82: } Chris@82: Chris@82: % Select #1 fonts with the current style. Chris@82: % Chris@82: \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} Chris@82: Chris@82: \def\rm{\fam=0 \setfontstyle{rm}} Chris@82: \def\it{\fam=\itfam \setfontstyle{it}} Chris@82: \def\sl{\fam=\slfam \setfontstyle{sl}} Chris@82: \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} Chris@82: \def\tt{\fam=\ttfam \setfontstyle{tt}} Chris@82: Chris@82: % Unfortunately, we have to override this for titles and the like, since Chris@82: % in those cases "rm" is bold. Sigh. Chris@82: \def\rmisbold{\rm\def\curfontstyle{bf}} Chris@82: Chris@82: % Texinfo sort of supports the sans serif font style, which plain TeX does not. Chris@82: % So we set up a \sf. Chris@82: \newfam\sffam Chris@82: \def\sf{\fam=\sffam \setfontstyle{sf}} Chris@82: \let\li = \sf % Sometimes we call it \li, not \sf. Chris@82: Chris@82: % We don't need math for this font style. Chris@82: \def\ttsl{\setfontstyle{ttsl}} Chris@82: Chris@82: Chris@82: % Set the baselineskip to #1, and the lineskip and strut size Chris@82: % correspondingly. There is no deep meaning behind these magic numbers Chris@82: % used as factors; they just match (closely enough) what Knuth defined. Chris@82: % Chris@82: \def\lineskipfactor{.08333} Chris@82: \def\strutheightpercent{.70833} Chris@82: \def\strutdepthpercent {.29167} Chris@82: % Chris@82: % can get a sort of poor man's double spacing by redefining this. Chris@82: \def\baselinefactor{1} Chris@82: % Chris@82: \newdimen\textleading Chris@82: \def\setleading#1{% Chris@82: \dimen0 = #1\relax Chris@82: \normalbaselineskip = \baselinefactor\dimen0 Chris@82: \normallineskip = \lineskipfactor\normalbaselineskip Chris@82: \normalbaselines Chris@82: \setbox\strutbox =\hbox{% Chris@82: \vrule width0pt height\strutheightpercent\baselineskip Chris@82: depth \strutdepthpercent \baselineskip Chris@82: }% Chris@82: } Chris@82: Chris@82: % PDF CMaps. See also LaTeX's t1.cmap. Chris@82: % Chris@82: % do nothing with this by default. Chris@82: \expandafter\let\csname cmapOT1\endcsname\gobble Chris@82: \expandafter\let\csname cmapOT1IT\endcsname\gobble Chris@82: \expandafter\let\csname cmapOT1TT\endcsname\gobble Chris@82: Chris@82: % if we are producing pdf, and we have \pdffontattr, then define cmaps. Chris@82: % (\pdffontattr was introduced many years ago, but people still run Chris@82: % older pdftex's; it's easy to conditionalize, so we do.) Chris@82: \ifpdf \ifx\pdffontattr\thisisundefined \else Chris@82: \begingroup Chris@82: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. Chris@82: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap Chris@82: %%DocumentNeededResources: ProcSet (CIDInit) Chris@82: %%IncludeResource: ProcSet (CIDInit) Chris@82: %%BeginResource: CMap (TeX-OT1-0) Chris@82: %%Title: (TeX-OT1-0 TeX OT1 0) Chris@82: %%Version: 1.000 Chris@82: %%EndComments Chris@82: /CIDInit /ProcSet findresource begin Chris@82: 12 dict begin Chris@82: begincmap Chris@82: /CIDSystemInfo Chris@82: << /Registry (TeX) Chris@82: /Ordering (OT1) Chris@82: /Supplement 0 Chris@82: >> def Chris@82: /CMapName /TeX-OT1-0 def Chris@82: /CMapType 2 def Chris@82: 1 begincodespacerange Chris@82: <00> <7F> Chris@82: endcodespacerange Chris@82: 8 beginbfrange Chris@82: <00> <01> <0393> Chris@82: <09> <0A> <03A8> Chris@82: <23> <26> <0023> Chris@82: <28> <3B> <0028> Chris@82: <3F> <5B> <003F> Chris@82: <5D> <5E> <005D> Chris@82: <61> <7A> <0061> Chris@82: <7B> <7C> <2013> Chris@82: endbfrange Chris@82: 40 beginbfchar Chris@82: <02> <0398> Chris@82: <03> <039B> Chris@82: <04> <039E> Chris@82: <05> <03A0> Chris@82: <06> <03A3> Chris@82: <07> <03D2> Chris@82: <08> <03A6> Chris@82: <0B> <00660066> Chris@82: <0C> <00660069> Chris@82: <0D> <0066006C> Chris@82: <0E> <006600660069> Chris@82: <0F> <00660066006C> Chris@82: <10> <0131> Chris@82: <11> <0237> Chris@82: <12> <0060> Chris@82: <13> <00B4> Chris@82: <14> <02C7> Chris@82: <15> <02D8> Chris@82: <16> <00AF> Chris@82: <17> <02DA> Chris@82: <18> <00B8> Chris@82: <19> <00DF> Chris@82: <1A> <00E6> Chris@82: <1B> <0153> Chris@82: <1C> <00F8> Chris@82: <1D> <00C6> Chris@82: <1E> <0152> Chris@82: <1F> <00D8> Chris@82: <21> <0021> Chris@82: <22> <201D> Chris@82: <27> <2019> Chris@82: <3C> <00A1> Chris@82: <3D> <003D> Chris@82: <3E> <00BF> Chris@82: <5C> <201C> Chris@82: <5F> <02D9> Chris@82: <60> <2018> Chris@82: <7D> <02DD> Chris@82: <7E> <007E> Chris@82: <7F> <00A8> Chris@82: endbfchar Chris@82: endcmap Chris@82: CMapName currentdict /CMap defineresource pop Chris@82: end Chris@82: end Chris@82: %%EndResource Chris@82: %%EOF Chris@82: }\endgroup Chris@82: \expandafter\edef\csname cmapOT1\endcsname#1{% Chris@82: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% Chris@82: }% Chris@82: % Chris@82: % \cmapOT1IT Chris@82: \begingroup Chris@82: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. Chris@82: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap Chris@82: %%DocumentNeededResources: ProcSet (CIDInit) Chris@82: %%IncludeResource: ProcSet (CIDInit) Chris@82: %%BeginResource: CMap (TeX-OT1IT-0) Chris@82: %%Title: (TeX-OT1IT-0 TeX OT1IT 0) Chris@82: %%Version: 1.000 Chris@82: %%EndComments Chris@82: /CIDInit /ProcSet findresource begin Chris@82: 12 dict begin Chris@82: begincmap Chris@82: /CIDSystemInfo Chris@82: << /Registry (TeX) Chris@82: /Ordering (OT1IT) Chris@82: /Supplement 0 Chris@82: >> def Chris@82: /CMapName /TeX-OT1IT-0 def Chris@82: /CMapType 2 def Chris@82: 1 begincodespacerange Chris@82: <00> <7F> Chris@82: endcodespacerange Chris@82: 8 beginbfrange Chris@82: <00> <01> <0393> Chris@82: <09> <0A> <03A8> Chris@82: <25> <26> <0025> Chris@82: <28> <3B> <0028> Chris@82: <3F> <5B> <003F> Chris@82: <5D> <5E> <005D> Chris@82: <61> <7A> <0061> Chris@82: <7B> <7C> <2013> Chris@82: endbfrange Chris@82: 42 beginbfchar Chris@82: <02> <0398> Chris@82: <03> <039B> Chris@82: <04> <039E> Chris@82: <05> <03A0> Chris@82: <06> <03A3> Chris@82: <07> <03D2> Chris@82: <08> <03A6> Chris@82: <0B> <00660066> Chris@82: <0C> <00660069> Chris@82: <0D> <0066006C> Chris@82: <0E> <006600660069> Chris@82: <0F> <00660066006C> Chris@82: <10> <0131> Chris@82: <11> <0237> Chris@82: <12> <0060> Chris@82: <13> <00B4> Chris@82: <14> <02C7> Chris@82: <15> <02D8> Chris@82: <16> <00AF> Chris@82: <17> <02DA> Chris@82: <18> <00B8> Chris@82: <19> <00DF> Chris@82: <1A> <00E6> Chris@82: <1B> <0153> Chris@82: <1C> <00F8> Chris@82: <1D> <00C6> Chris@82: <1E> <0152> Chris@82: <1F> <00D8> Chris@82: <21> <0021> Chris@82: <22> <201D> Chris@82: <23> <0023> Chris@82: <24> <00A3> Chris@82: <27> <2019> Chris@82: <3C> <00A1> Chris@82: <3D> <003D> Chris@82: <3E> <00BF> Chris@82: <5C> <201C> Chris@82: <5F> <02D9> Chris@82: <60> <2018> Chris@82: <7D> <02DD> Chris@82: <7E> <007E> Chris@82: <7F> <00A8> Chris@82: endbfchar Chris@82: endcmap Chris@82: CMapName currentdict /CMap defineresource pop Chris@82: end Chris@82: end Chris@82: %%EndResource Chris@82: %%EOF Chris@82: }\endgroup Chris@82: \expandafter\edef\csname cmapOT1IT\endcsname#1{% Chris@82: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% Chris@82: }% Chris@82: % Chris@82: % \cmapOT1TT Chris@82: \begingroup Chris@82: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. Chris@82: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap Chris@82: %%DocumentNeededResources: ProcSet (CIDInit) Chris@82: %%IncludeResource: ProcSet (CIDInit) Chris@82: %%BeginResource: CMap (TeX-OT1TT-0) Chris@82: %%Title: (TeX-OT1TT-0 TeX OT1TT 0) Chris@82: %%Version: 1.000 Chris@82: %%EndComments Chris@82: /CIDInit /ProcSet findresource begin Chris@82: 12 dict begin Chris@82: begincmap Chris@82: /CIDSystemInfo Chris@82: << /Registry (TeX) Chris@82: /Ordering (OT1TT) Chris@82: /Supplement 0 Chris@82: >> def Chris@82: /CMapName /TeX-OT1TT-0 def Chris@82: /CMapType 2 def Chris@82: 1 begincodespacerange Chris@82: <00> <7F> Chris@82: endcodespacerange Chris@82: 5 beginbfrange Chris@82: <00> <01> <0393> Chris@82: <09> <0A> <03A8> Chris@82: <21> <26> <0021> Chris@82: <28> <5F> <0028> Chris@82: <61> <7E> <0061> Chris@82: endbfrange Chris@82: 32 beginbfchar Chris@82: <02> <0398> Chris@82: <03> <039B> Chris@82: <04> <039E> Chris@82: <05> <03A0> Chris@82: <06> <03A3> Chris@82: <07> <03D2> Chris@82: <08> <03A6> Chris@82: <0B> <2191> Chris@82: <0C> <2193> Chris@82: <0D> <0027> Chris@82: <0E> <00A1> Chris@82: <0F> <00BF> Chris@82: <10> <0131> Chris@82: <11> <0237> Chris@82: <12> <0060> Chris@82: <13> <00B4> Chris@82: <14> <02C7> Chris@82: <15> <02D8> Chris@82: <16> <00AF> Chris@82: <17> <02DA> Chris@82: <18> <00B8> Chris@82: <19> <00DF> Chris@82: <1A> <00E6> Chris@82: <1B> <0153> Chris@82: <1C> <00F8> Chris@82: <1D> <00C6> Chris@82: <1E> <0152> Chris@82: <1F> <00D8> Chris@82: <20> <2423> Chris@82: <27> <2019> Chris@82: <60> <2018> Chris@82: <7F> <00A8> Chris@82: endbfchar Chris@82: endcmap Chris@82: CMapName currentdict /CMap defineresource pop Chris@82: end Chris@82: end Chris@82: %%EndResource Chris@82: %%EOF Chris@82: }\endgroup Chris@82: \expandafter\edef\csname cmapOT1TT\endcsname#1{% Chris@82: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% Chris@82: }% Chris@82: \fi\fi Chris@82: Chris@82: Chris@82: % Set the font macro #1 to the font named \fontprefix#2. Chris@82: % #3 is the font's design size, #4 is a scale factor, #5 is the CMap Chris@82: % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). Chris@82: % Example: Chris@82: % #1 = \textrm Chris@82: % #2 = \rmshape Chris@82: % #3 = 10 Chris@82: % #4 = \mainmagstep Chris@82: % #5 = OT1 Chris@82: % Chris@82: \def\setfont#1#2#3#4#5{% Chris@82: \font#1=\fontprefix#2#3 scaled #4 Chris@82: \csname cmap#5\endcsname#1% Chris@82: } Chris@82: % This is what gets called when #5 of \setfont is empty. Chris@82: \let\cmap\gobble Chris@82: % Chris@82: % (end of cmaps) Chris@82: Chris@82: % Use cm as the default font prefix. Chris@82: % To specify the font prefix, you must define \fontprefix Chris@82: % before you read in texinfo.tex. Chris@82: \ifx\fontprefix\thisisundefined Chris@82: \def\fontprefix{cm} Chris@82: \fi Chris@82: % Support font families that don't use the same naming scheme as CM. Chris@82: \def\rmshape{r} Chris@82: \def\rmbshape{bx} % where the normal face is bold Chris@82: \def\bfshape{b} Chris@82: \def\bxshape{bx} Chris@82: \def\ttshape{tt} Chris@82: \def\ttbshape{tt} Chris@82: \def\ttslshape{sltt} Chris@82: \def\itshape{ti} Chris@82: \def\itbshape{bxti} Chris@82: \def\slshape{sl} Chris@82: \def\slbshape{bxsl} Chris@82: \def\sfshape{ss} Chris@82: \def\sfbshape{ss} Chris@82: \def\scshape{csc} Chris@82: \def\scbshape{csc} Chris@82: Chris@82: % Definitions for a main text size of 11pt. (The default in Texinfo.) Chris@82: % Chris@82: \def\definetextfontsizexi{% Chris@82: % Text fonts (11.2pt, magstep1). Chris@82: \def\textnominalsize{11pt} Chris@82: \edef\mainmagstep{\magstephalf} Chris@82: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} Chris@82: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} Chris@82: \setfont\textsl\slshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textsc\scshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} Chris@82: \font\texti=cmmi10 scaled \mainmagstep Chris@82: \font\textsy=cmsy10 scaled \mainmagstep Chris@82: \def\textecsize{1095} Chris@82: Chris@82: % A few fonts for @defun names and args. Chris@82: \setfont\defbf\bfshape{10}{\magstep1}{OT1} Chris@82: \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} Chris@82: \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} Chris@82: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} Chris@82: Chris@82: % Fonts for indices, footnotes, small examples (9pt). Chris@82: \def\smallnominalsize{9pt} Chris@82: \setfont\smallrm\rmshape{9}{1000}{OT1} Chris@82: \setfont\smalltt\ttshape{9}{1000}{OT1TT} Chris@82: \setfont\smallbf\bfshape{10}{900}{OT1} Chris@82: \setfont\smallit\itshape{9}{1000}{OT1IT} Chris@82: \setfont\smallsl\slshape{9}{1000}{OT1} Chris@82: \setfont\smallsf\sfshape{9}{1000}{OT1} Chris@82: \setfont\smallsc\scshape{10}{900}{OT1} Chris@82: \setfont\smallttsl\ttslshape{10}{900}{OT1TT} Chris@82: \font\smalli=cmmi9 Chris@82: \font\smallsy=cmsy9 Chris@82: \def\smallecsize{0900} Chris@82: Chris@82: % Fonts for small examples (8pt). Chris@82: \def\smallernominalsize{8pt} Chris@82: \setfont\smallerrm\rmshape{8}{1000}{OT1} Chris@82: \setfont\smallertt\ttshape{8}{1000}{OT1TT} Chris@82: \setfont\smallerbf\bfshape{10}{800}{OT1} Chris@82: \setfont\smallerit\itshape{8}{1000}{OT1IT} Chris@82: \setfont\smallersl\slshape{8}{1000}{OT1} Chris@82: \setfont\smallersf\sfshape{8}{1000}{OT1} Chris@82: \setfont\smallersc\scshape{10}{800}{OT1} Chris@82: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} Chris@82: \font\smalleri=cmmi8 Chris@82: \font\smallersy=cmsy8 Chris@82: \def\smallerecsize{0800} Chris@82: Chris@82: % Fonts for title page (20.4pt): Chris@82: \def\titlenominalsize{20pt} Chris@82: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} Chris@82: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} Chris@82: \setfont\titlesl\slbshape{10}{\magstep4}{OT1} Chris@82: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} Chris@82: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} Chris@82: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} Chris@82: \let\titlebf=\titlerm Chris@82: \setfont\titlesc\scbshape{10}{\magstep4}{OT1} Chris@82: \font\titlei=cmmi12 scaled \magstep3 Chris@82: \font\titlesy=cmsy10 scaled \magstep4 Chris@82: \def\titleecsize{2074} Chris@82: Chris@82: % Chapter (and unnumbered) fonts (17.28pt). Chris@82: \def\chapnominalsize{17pt} Chris@82: \setfont\chaprm\rmbshape{12}{\magstep2}{OT1} Chris@82: \setfont\chapit\itbshape{10}{\magstep3}{OT1IT} Chris@82: \setfont\chapsl\slbshape{10}{\magstep3}{OT1} Chris@82: \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} Chris@82: \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} Chris@82: \setfont\chapsf\sfbshape{17}{1000}{OT1} Chris@82: \let\chapbf=\chaprm Chris@82: \setfont\chapsc\scbshape{10}{\magstep3}{OT1} Chris@82: \font\chapi=cmmi12 scaled \magstep2 Chris@82: \font\chapsy=cmsy10 scaled \magstep3 Chris@82: \def\chapecsize{1728} Chris@82: Chris@82: % Section fonts (14.4pt). Chris@82: \def\secnominalsize{14pt} Chris@82: \setfont\secrm\rmbshape{12}{\magstep1}{OT1} Chris@82: \setfont\secit\itbshape{10}{\magstep2}{OT1IT} Chris@82: \setfont\secsl\slbshape{10}{\magstep2}{OT1} Chris@82: \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} Chris@82: \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} Chris@82: \setfont\secsf\sfbshape{12}{\magstep1}{OT1} Chris@82: \let\secbf\secrm Chris@82: \setfont\secsc\scbshape{10}{\magstep2}{OT1} Chris@82: \font\seci=cmmi12 scaled \magstep1 Chris@82: \font\secsy=cmsy10 scaled \magstep2 Chris@82: \def\sececsize{1440} Chris@82: Chris@82: % Subsection fonts (13.15pt). Chris@82: \def\ssecnominalsize{13pt} Chris@82: \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} Chris@82: \setfont\ssecit\itbshape{10}{1315}{OT1IT} Chris@82: \setfont\ssecsl\slbshape{10}{1315}{OT1} Chris@82: \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} Chris@82: \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} Chris@82: \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} Chris@82: \let\ssecbf\ssecrm Chris@82: \setfont\ssecsc\scbshape{10}{1315}{OT1} Chris@82: \font\sseci=cmmi12 scaled \magstephalf Chris@82: \font\ssecsy=cmsy10 scaled 1315 Chris@82: \def\ssececsize{1200} Chris@82: Chris@82: % Reduced fonts for @acro in text (10pt). Chris@82: \def\reducednominalsize{10pt} Chris@82: \setfont\reducedrm\rmshape{10}{1000}{OT1} Chris@82: \setfont\reducedtt\ttshape{10}{1000}{OT1TT} Chris@82: \setfont\reducedbf\bfshape{10}{1000}{OT1} Chris@82: \setfont\reducedit\itshape{10}{1000}{OT1IT} Chris@82: \setfont\reducedsl\slshape{10}{1000}{OT1} Chris@82: \setfont\reducedsf\sfshape{10}{1000}{OT1} Chris@82: \setfont\reducedsc\scshape{10}{1000}{OT1} Chris@82: \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} Chris@82: \font\reducedi=cmmi10 Chris@82: \font\reducedsy=cmsy10 Chris@82: \def\reducedecsize{1000} Chris@82: Chris@82: \textleading = 13.2pt % line spacing for 11pt CM Chris@82: \textfonts % reset the current fonts Chris@82: \rm Chris@82: } % end of 11pt text font size definitions, \definetextfontsizexi Chris@82: Chris@82: Chris@82: % Definitions to make the main text be 10pt Computer Modern, with Chris@82: % section, chapter, etc., sizes following suit. This is for the GNU Chris@82: % Press printing of the Emacs 22 manual. Maybe other manuals in the Chris@82: % future. Used with @smallbook, which sets the leading to 12pt. Chris@82: % Chris@82: \def\definetextfontsizex{% Chris@82: % Text fonts (10pt). Chris@82: \def\textnominalsize{10pt} Chris@82: \edef\mainmagstep{1000} Chris@82: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} Chris@82: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} Chris@82: \setfont\textsl\slshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textsc\scshape{10}{\mainmagstep}{OT1} Chris@82: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} Chris@82: \font\texti=cmmi10 scaled \mainmagstep Chris@82: \font\textsy=cmsy10 scaled \mainmagstep Chris@82: \def\textecsize{1000} Chris@82: Chris@82: % A few fonts for @defun names and args. Chris@82: \setfont\defbf\bfshape{10}{\magstephalf}{OT1} Chris@82: \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} Chris@82: \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} Chris@82: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} Chris@82: Chris@82: % Fonts for indices, footnotes, small examples (9pt). Chris@82: \def\smallnominalsize{9pt} Chris@82: \setfont\smallrm\rmshape{9}{1000}{OT1} Chris@82: \setfont\smalltt\ttshape{9}{1000}{OT1TT} Chris@82: \setfont\smallbf\bfshape{10}{900}{OT1} Chris@82: \setfont\smallit\itshape{9}{1000}{OT1IT} Chris@82: \setfont\smallsl\slshape{9}{1000}{OT1} Chris@82: \setfont\smallsf\sfshape{9}{1000}{OT1} Chris@82: \setfont\smallsc\scshape{10}{900}{OT1} Chris@82: \setfont\smallttsl\ttslshape{10}{900}{OT1TT} Chris@82: \font\smalli=cmmi9 Chris@82: \font\smallsy=cmsy9 Chris@82: \def\smallecsize{0900} Chris@82: Chris@82: % Fonts for small examples (8pt). Chris@82: \def\smallernominalsize{8pt} Chris@82: \setfont\smallerrm\rmshape{8}{1000}{OT1} Chris@82: \setfont\smallertt\ttshape{8}{1000}{OT1TT} Chris@82: \setfont\smallerbf\bfshape{10}{800}{OT1} Chris@82: \setfont\smallerit\itshape{8}{1000}{OT1IT} Chris@82: \setfont\smallersl\slshape{8}{1000}{OT1} Chris@82: \setfont\smallersf\sfshape{8}{1000}{OT1} Chris@82: \setfont\smallersc\scshape{10}{800}{OT1} Chris@82: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} Chris@82: \font\smalleri=cmmi8 Chris@82: \font\smallersy=cmsy8 Chris@82: \def\smallerecsize{0800} Chris@82: Chris@82: % Fonts for title page (20.4pt): Chris@82: \def\titlenominalsize{20pt} Chris@82: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} Chris@82: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} Chris@82: \setfont\titlesl\slbshape{10}{\magstep4}{OT1} Chris@82: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} Chris@82: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} Chris@82: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} Chris@82: \let\titlebf=\titlerm Chris@82: \setfont\titlesc\scbshape{10}{\magstep4}{OT1} Chris@82: \font\titlei=cmmi12 scaled \magstep3 Chris@82: \font\titlesy=cmsy10 scaled \magstep4 Chris@82: \def\titleecsize{2074} Chris@82: Chris@82: % Chapter fonts (14.4pt). Chris@82: \def\chapnominalsize{14pt} Chris@82: \setfont\chaprm\rmbshape{12}{\magstep1}{OT1} Chris@82: \setfont\chapit\itbshape{10}{\magstep2}{OT1IT} Chris@82: \setfont\chapsl\slbshape{10}{\magstep2}{OT1} Chris@82: \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} Chris@82: \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} Chris@82: \setfont\chapsf\sfbshape{12}{\magstep1}{OT1} Chris@82: \let\chapbf\chaprm Chris@82: \setfont\chapsc\scbshape{10}{\magstep2}{OT1} Chris@82: \font\chapi=cmmi12 scaled \magstep1 Chris@82: \font\chapsy=cmsy10 scaled \magstep2 Chris@82: \def\chapecsize{1440} Chris@82: Chris@82: % Section fonts (12pt). Chris@82: \def\secnominalsize{12pt} Chris@82: \setfont\secrm\rmbshape{12}{1000}{OT1} Chris@82: \setfont\secit\itbshape{10}{\magstep1}{OT1IT} Chris@82: \setfont\secsl\slbshape{10}{\magstep1}{OT1} Chris@82: \setfont\sectt\ttbshape{12}{1000}{OT1TT} Chris@82: \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} Chris@82: \setfont\secsf\sfbshape{12}{1000}{OT1} Chris@82: \let\secbf\secrm Chris@82: \setfont\secsc\scbshape{10}{\magstep1}{OT1} Chris@82: \font\seci=cmmi12 Chris@82: \font\secsy=cmsy10 scaled \magstep1 Chris@82: \def\sececsize{1200} Chris@82: Chris@82: % Subsection fonts (10pt). Chris@82: \def\ssecnominalsize{10pt} Chris@82: \setfont\ssecrm\rmbshape{10}{1000}{OT1} Chris@82: \setfont\ssecit\itbshape{10}{1000}{OT1IT} Chris@82: \setfont\ssecsl\slbshape{10}{1000}{OT1} Chris@82: \setfont\ssectt\ttbshape{10}{1000}{OT1TT} Chris@82: \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} Chris@82: \setfont\ssecsf\sfbshape{10}{1000}{OT1} Chris@82: \let\ssecbf\ssecrm Chris@82: \setfont\ssecsc\scbshape{10}{1000}{OT1} Chris@82: \font\sseci=cmmi10 Chris@82: \font\ssecsy=cmsy10 Chris@82: \def\ssececsize{1000} Chris@82: Chris@82: % Reduced fonts for @acro in text (9pt). Chris@82: \def\reducednominalsize{9pt} Chris@82: \setfont\reducedrm\rmshape{9}{1000}{OT1} Chris@82: \setfont\reducedtt\ttshape{9}{1000}{OT1TT} Chris@82: \setfont\reducedbf\bfshape{10}{900}{OT1} Chris@82: \setfont\reducedit\itshape{9}{1000}{OT1IT} Chris@82: \setfont\reducedsl\slshape{9}{1000}{OT1} Chris@82: \setfont\reducedsf\sfshape{9}{1000}{OT1} Chris@82: \setfont\reducedsc\scshape{10}{900}{OT1} Chris@82: \setfont\reducedttsl\ttslshape{10}{900}{OT1TT} Chris@82: \font\reducedi=cmmi9 Chris@82: \font\reducedsy=cmsy9 Chris@82: \def\reducedecsize{0900} Chris@82: Chris@82: \divide\parskip by 2 % reduce space between paragraphs Chris@82: \textleading = 12pt % line spacing for 10pt CM Chris@82: \textfonts % reset the current fonts Chris@82: \rm Chris@82: } % end of 10pt text font size definitions, \definetextfontsizex Chris@82: Chris@82: Chris@82: % We provide the user-level command Chris@82: % @fonttextsize 10 Chris@82: % (or 11) to redefine the text font size. pt is assumed. Chris@82: % Chris@82: \def\xiword{11} Chris@82: \def\xword{10} Chris@82: \def\xwordpt{10pt} Chris@82: % Chris@82: \parseargdef\fonttextsize{% Chris@82: \def\textsizearg{#1}% Chris@82: %\wlog{doing @fonttextsize \textsizearg}% Chris@82: % Chris@82: % Set \globaldefs so that documents can use this inside @tex, since Chris@82: % makeinfo 4.8 does not support it, but we need it nonetheless. Chris@82: % Chris@82: \begingroup \globaldefs=1 Chris@82: \ifx\textsizearg\xword \definetextfontsizex Chris@82: \else \ifx\textsizearg\xiword \definetextfontsizexi Chris@82: \else Chris@82: \errhelp=\EMsimple Chris@82: \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} Chris@82: \fi\fi Chris@82: \endgroup Chris@82: } Chris@82: Chris@82: Chris@82: % In order for the font changes to affect most math symbols and letters, Chris@82: % we have to define the \textfont of the standard families. Since Chris@82: % texinfo doesn't allow for producing subscripts and superscripts except Chris@82: % in the main text, we don't bother to reset \scriptfont and Chris@82: % \scriptscriptfont (which would also require loading a lot more fonts). Chris@82: % Chris@82: \def\resetmathfonts{% Chris@82: \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy Chris@82: \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf Chris@82: \textfont\ttfam=\tentt \textfont\sffam=\tensf Chris@82: } Chris@82: Chris@82: % The font-changing commands redefine the meanings of \tenSTYLE, instead Chris@82: % of just \STYLE. We do this because \STYLE needs to also set the Chris@82: % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire Chris@82: % \tenSTYLE to set the current font. Chris@82: % Chris@82: % Each font-changing command also sets the names \lsize (one size lower) Chris@82: % and \lllsize (three sizes lower). These relative commands are used in Chris@82: % the LaTeX logo and acronyms. Chris@82: % Chris@82: % This all needs generalizing, badly. Chris@82: % Chris@82: \def\textfonts{% Chris@82: \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl Chris@82: \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc Chris@82: \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy Chris@82: \let\tenttsl=\textttsl Chris@82: \def\curfontsize{text}% Chris@82: \def\lsize{reduced}\def\lllsize{smaller}% Chris@82: \resetmathfonts \setleading{\textleading}} Chris@82: \def\titlefonts{% Chris@82: \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl Chris@82: \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc Chris@82: \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy Chris@82: \let\tenttsl=\titlettsl Chris@82: \def\curfontsize{title}% Chris@82: \def\lsize{chap}\def\lllsize{subsec}% Chris@82: \resetmathfonts \setleading{27pt}} Chris@82: \def\titlefont#1{{\titlefonts\rmisbold #1}} Chris@82: \def\chapfonts{% Chris@82: \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl Chris@82: \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc Chris@82: \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy Chris@82: \let\tenttsl=\chapttsl Chris@82: \def\curfontsize{chap}% Chris@82: \def\lsize{sec}\def\lllsize{text}% Chris@82: \resetmathfonts \setleading{19pt}} Chris@82: \def\secfonts{% Chris@82: \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl Chris@82: \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc Chris@82: \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy Chris@82: \let\tenttsl=\secttsl Chris@82: \def\curfontsize{sec}% Chris@82: \def\lsize{subsec}\def\lllsize{reduced}% Chris@82: \resetmathfonts \setleading{16pt}} Chris@82: \def\subsecfonts{% Chris@82: \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl Chris@82: \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc Chris@82: \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy Chris@82: \let\tenttsl=\ssecttsl Chris@82: \def\curfontsize{ssec}% Chris@82: \def\lsize{text}\def\lllsize{small}% Chris@82: \resetmathfonts \setleading{15pt}} Chris@82: \let\subsubsecfonts = \subsecfonts Chris@82: \def\reducedfonts{% Chris@82: \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl Chris@82: \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc Chris@82: \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy Chris@82: \let\tenttsl=\reducedttsl Chris@82: \def\curfontsize{reduced}% Chris@82: \def\lsize{small}\def\lllsize{smaller}% Chris@82: \resetmathfonts \setleading{10.5pt}} Chris@82: \def\smallfonts{% Chris@82: \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl Chris@82: \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc Chris@82: \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy Chris@82: \let\tenttsl=\smallttsl Chris@82: \def\curfontsize{small}% Chris@82: \def\lsize{smaller}\def\lllsize{smaller}% Chris@82: \resetmathfonts \setleading{10.5pt}} Chris@82: \def\smallerfonts{% Chris@82: \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl Chris@82: \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc Chris@82: \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy Chris@82: \let\tenttsl=\smallerttsl Chris@82: \def\curfontsize{smaller}% Chris@82: \def\lsize{smaller}\def\lllsize{smaller}% Chris@82: \resetmathfonts \setleading{9.5pt}} Chris@82: Chris@82: % Fonts for short table of contents. Chris@82: \setfont\shortcontrm\rmshape{12}{1000}{OT1} Chris@82: \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 Chris@82: \setfont\shortcontsl\slshape{12}{1000}{OT1} Chris@82: \setfont\shortconttt\ttshape{12}{1000}{OT1TT} Chris@82: Chris@82: % Define these just so they can be easily changed for other fonts. Chris@82: \def\angleleft{$\langle$} Chris@82: \def\angleright{$\rangle$} Chris@82: Chris@82: % Set the fonts to use with the @small... environments. Chris@82: \let\smallexamplefonts = \smallfonts Chris@82: Chris@82: % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample Chris@82: % can fit this many characters: Chris@82: % 8.5x11=86 smallbook=72 a4=90 a5=69 Chris@82: % If we use \scriptfonts (8pt), then we can fit this many characters: Chris@82: % 8.5x11=90+ smallbook=80 a4=90+ a5=77 Chris@82: % For me, subjectively, the few extra characters that fit aren't worth Chris@82: % the additional smallness of 8pt. So I'm making the default 9pt. Chris@82: % Chris@82: % By the way, for comparison, here's what fits with @example (10pt): Chris@82: % 8.5x11=71 smallbook=60 a4=75 a5=58 Chris@82: % --karl, 24jan03. Chris@82: Chris@82: % Set up the default fonts, so we can use them for creating boxes. Chris@82: % Chris@82: \definetextfontsizexi Chris@82: Chris@82: Chris@82: \message{markup,} Chris@82: Chris@82: % Check if we are currently using a typewriter font. Since all the Chris@82: % Computer Modern typewriter fonts have zero interword stretch (and Chris@82: % shrink), and it is reasonable to expect all typewriter fonts to have Chris@82: % this property, we can check that font parameter. Chris@82: % Chris@82: \def\ifmonospace{\ifdim\fontdimen3\font=0pt } Chris@82: Chris@82: % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will Chris@82: % define and register \INITMACRO to be called on markup style changes. Chris@82: % \INITMACRO can check \currentmarkupstyle for the innermost Chris@82: % style and the set of \ifmarkupSTYLE switches for all styles Chris@82: % currently in effect. Chris@82: \newif\ifmarkupvar Chris@82: \newif\ifmarkupsamp Chris@82: \newif\ifmarkupkey Chris@82: %\newif\ifmarkupfile % @file == @samp. Chris@82: %\newif\ifmarkupoption % @option == @samp. Chris@82: \newif\ifmarkupcode Chris@82: \newif\ifmarkupkbd Chris@82: %\newif\ifmarkupenv % @env == @code. Chris@82: %\newif\ifmarkupcommand % @command == @code. Chris@82: \newif\ifmarkuptex % @tex (and part of @math, for now). Chris@82: \newif\ifmarkupexample Chris@82: \newif\ifmarkupverb Chris@82: \newif\ifmarkupverbatim Chris@82: Chris@82: \let\currentmarkupstyle\empty Chris@82: Chris@82: \def\setupmarkupstyle#1{% Chris@82: \csname markup#1true\endcsname Chris@82: \def\currentmarkupstyle{#1}% Chris@82: \markupstylesetup Chris@82: } Chris@82: Chris@82: \let\markupstylesetup\empty Chris@82: Chris@82: \def\defmarkupstylesetup#1{% Chris@82: \expandafter\def\expandafter\markupstylesetup Chris@82: \expandafter{\markupstylesetup #1}% Chris@82: \def#1% Chris@82: } Chris@82: Chris@82: % Markup style setup for left and right quotes. Chris@82: \defmarkupstylesetup\markupsetuplq{% Chris@82: \expandafter\let\expandafter \temp Chris@82: \csname markupsetuplq\currentmarkupstyle\endcsname Chris@82: \ifx\temp\relax \markupsetuplqdefault \else \temp \fi Chris@82: } Chris@82: Chris@82: \defmarkupstylesetup\markupsetuprq{% Chris@82: \expandafter\let\expandafter \temp Chris@82: \csname markupsetuprq\currentmarkupstyle\endcsname Chris@82: \ifx\temp\relax \markupsetuprqdefault \else \temp \fi Chris@82: } Chris@82: Chris@82: { Chris@82: \catcode`\'=\active Chris@82: \catcode`\`=\active Chris@82: Chris@82: \gdef\markupsetuplqdefault{\let`\lq} Chris@82: \gdef\markupsetuprqdefault{\let'\rq} Chris@82: Chris@82: \gdef\markupsetcodequoteleft{\let`\codequoteleft} Chris@82: \gdef\markupsetcodequoteright{\let'\codequoteright} Chris@82: } Chris@82: Chris@82: \let\markupsetuplqcode \markupsetcodequoteleft Chris@82: \let\markupsetuprqcode \markupsetcodequoteright Chris@82: % Chris@82: \let\markupsetuplqexample \markupsetcodequoteleft Chris@82: \let\markupsetuprqexample \markupsetcodequoteright Chris@82: % Chris@82: \let\markupsetuplqkbd \markupsetcodequoteleft Chris@82: \let\markupsetuprqkbd \markupsetcodequoteright Chris@82: % Chris@82: \let\markupsetuplqsamp \markupsetcodequoteleft Chris@82: \let\markupsetuprqsamp \markupsetcodequoteright Chris@82: % Chris@82: \let\markupsetuplqverb \markupsetcodequoteleft Chris@82: \let\markupsetuprqverb \markupsetcodequoteright Chris@82: % Chris@82: \let\markupsetuplqverbatim \markupsetcodequoteleft Chris@82: \let\markupsetuprqverbatim \markupsetcodequoteright Chris@82: Chris@82: % Allow an option to not use regular directed right quote/apostrophe Chris@82: % (char 0x27), but instead the undirected quote from cmtt (char 0x0d). Chris@82: % The undirected quote is ugly, so don't make it the default, but it Chris@82: % works for pasting with more pdf viewers (at least evince), the Chris@82: % lilypond developers report. xpdf does work with the regular 0x27. Chris@82: % Chris@82: \def\codequoteright{% Chris@82: \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax Chris@82: \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax Chris@82: '% Chris@82: \else \char'15 \fi Chris@82: \else \char'15 \fi Chris@82: } Chris@82: % Chris@82: % and a similar option for the left quote char vs. a grave accent. Chris@82: % Modern fonts display ASCII 0x60 as a grave accent, so some people like Chris@82: % the code environments to do likewise. Chris@82: % Chris@82: \def\codequoteleft{% Chris@82: \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax Chris@82: \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax Chris@82: % [Knuth] pp. 380,381,391 Chris@82: % \relax disables Spanish ligatures ?` and !` of \tt font. Chris@82: \relax`% Chris@82: \else \char'22 \fi Chris@82: \else \char'22 \fi Chris@82: } Chris@82: Chris@82: % Commands to set the quote options. Chris@82: % Chris@82: \parseargdef\codequoteundirected{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\onword Chris@82: \expandafter\let\csname SETtxicodequoteundirected\endcsname Chris@82: = t% Chris@82: \else\ifx\temp\offword Chris@82: \expandafter\let\csname SETtxicodequoteundirected\endcsname Chris@82: = \relax Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% Chris@82: \fi\fi Chris@82: } Chris@82: % Chris@82: \parseargdef\codequotebacktick{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\onword Chris@82: \expandafter\let\csname SETtxicodequotebacktick\endcsname Chris@82: = t% Chris@82: \else\ifx\temp\offword Chris@82: \expandafter\let\csname SETtxicodequotebacktick\endcsname Chris@82: = \relax Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. Chris@82: \def\noligaturesquoteleft{\relax\lq} Chris@82: Chris@82: % Count depth in font-changes, for error checks Chris@82: \newcount\fontdepth \fontdepth=0 Chris@82: Chris@82: % Font commands. Chris@82: Chris@82: % #1 is the font command (\sl or \it), #2 is the text to slant. Chris@82: % If we are in a monospaced environment, however, 1) always use \ttsl, Chris@82: % and 2) do not add an italic correction. Chris@82: \def\dosmartslant#1#2{% Chris@82: \ifusingtt Chris@82: {{\ttsl #2}\let\next=\relax}% Chris@82: {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% Chris@82: \next Chris@82: } Chris@82: \def\smartslanted{\dosmartslant\sl} Chris@82: \def\smartitalic{\dosmartslant\it} Chris@82: Chris@82: % Output an italic correction unless \next (presumed to be the following Chris@82: % character) is such as not to need one. Chris@82: \def\smartitaliccorrection{% Chris@82: \ifx\next,% Chris@82: \else\ifx\next-% Chris@82: \else\ifx\next.% Chris@82: \else\ptexslash Chris@82: \fi\fi\fi Chris@82: \aftersmartic Chris@82: } Chris@82: Chris@82: % Unconditional use \ttsl, and no ic. @var is set to this for defuns. Chris@82: \def\ttslanted#1{{\ttsl #1}} Chris@82: Chris@82: % @cite is like \smartslanted except unconditionally use \sl. We never want Chris@82: % ttsl for book titles, do we? Chris@82: \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} Chris@82: Chris@82: \def\aftersmartic{} Chris@82: \def\var#1{% Chris@82: \let\saveaftersmartic = \aftersmartic Chris@82: \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% Chris@82: \smartslanted{#1}% Chris@82: } Chris@82: Chris@82: \let\i=\smartitalic Chris@82: \let\slanted=\smartslanted Chris@82: \let\dfn=\smartslanted Chris@82: \let\emph=\smartitalic Chris@82: Chris@82: % Explicit font changes: @r, @sc, undocumented @ii. Chris@82: \def\r#1{{\rm #1}} % roman font Chris@82: \def\sc#1{{\smallcaps#1}} % smallcaps font Chris@82: \def\ii#1{{\it #1}} % italic font Chris@82: Chris@82: % @b, explicit bold. Also @strong. Chris@82: \def\b#1{{\bf #1}} Chris@82: \let\strong=\b Chris@82: Chris@82: % @sansserif, explicit sans. Chris@82: \def\sansserif#1{{\sf #1}} Chris@82: Chris@82: % We can't just use \exhyphenpenalty, because that only has effect at Chris@82: % the end of a paragraph. Restore normal hyphenation at the end of the Chris@82: % group within which \nohyphenation is presumably called. Chris@82: % Chris@82: \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} Chris@82: \def\restorehyphenation{\hyphenchar\font = `- } Chris@82: Chris@82: % Set sfcode to normal for the chars that usually have another value. Chris@82: % Can't use plain's \frenchspacing because it uses the `\x notation, and Chris@82: % sometimes \x has an active definition that messes things up. Chris@82: % Chris@82: \catcode`@=11 Chris@82: \def\plainfrenchspacing{% Chris@82: \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m Chris@82: \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m Chris@82: \def\endofsentencespacefactor{1000}% for @. and friends Chris@82: } Chris@82: \def\plainnonfrenchspacing{% Chris@82: \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 Chris@82: \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 Chris@82: \def\endofsentencespacefactor{3000}% for @. and friends Chris@82: } Chris@82: \catcode`@=\other Chris@82: \def\endofsentencespacefactor{3000}% default Chris@82: Chris@82: % @t, explicit typewriter. Chris@82: \def\t#1{% Chris@82: {\tt \rawbackslash \plainfrenchspacing #1}% Chris@82: \null Chris@82: } Chris@82: Chris@82: % @samp. Chris@82: \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} Chris@82: Chris@82: % @indicateurl is \samp, that is, with quotes. Chris@82: \let\indicateurl=\samp Chris@82: Chris@82: % @code (and similar) prints in typewriter, but with spaces the same Chris@82: % size as normal in the surrounding text, without hyphenation, etc. Chris@82: % This is a subroutine for that. Chris@82: \def\tclose#1{% Chris@82: {% Chris@82: % Change normal interword space to be same as for the current font. Chris@82: \spaceskip = \fontdimen2\font Chris@82: % Chris@82: % Switch to typewriter. Chris@82: \tt Chris@82: % Chris@82: % But `\ ' produces the large typewriter interword space. Chris@82: \def\ {{\spaceskip = 0pt{} }}% Chris@82: % Chris@82: % Turn off hyphenation. Chris@82: \nohyphenation Chris@82: % Chris@82: \rawbackslash Chris@82: \plainfrenchspacing Chris@82: #1% Chris@82: }% Chris@82: \null % reset spacefactor to 1000 Chris@82: } Chris@82: Chris@82: % We *must* turn on hyphenation at `-' and `_' in @code. Chris@82: % Otherwise, it is too hard to avoid overfull hboxes Chris@82: % in the Emacs manual, the Library manual, etc. Chris@82: % Chris@82: % Unfortunately, TeX uses one parameter (\hyphenchar) to control Chris@82: % both hyphenation at - and hyphenation within words. Chris@82: % We must therefore turn them both off (\tclose does that) Chris@82: % and arrange explicitly to hyphenate at a dash. Chris@82: % -- rms. Chris@82: { Chris@82: \catcode`\-=\active \catcode`\_=\active Chris@82: \catcode`\'=\active \catcode`\`=\active Chris@82: \global\let'=\rq \global\let`=\lq % default definitions Chris@82: % Chris@82: \global\def\code{\begingroup Chris@82: \setupmarkupstyle{code}% Chris@82: % The following should really be moved into \setupmarkupstyle handlers. Chris@82: \catcode\dashChar=\active \catcode\underChar=\active Chris@82: \ifallowcodebreaks Chris@82: \let-\codedash Chris@82: \let_\codeunder Chris@82: \else Chris@82: \let-\normaldash Chris@82: \let_\realunder Chris@82: \fi Chris@82: \codex Chris@82: } Chris@82: } Chris@82: Chris@82: \def\codex #1{\tclose{#1}\endgroup} Chris@82: Chris@82: \def\normaldash{-} Chris@82: \def\codedash{-\discretionary{}{}{}} Chris@82: \def\codeunder{% Chris@82: % this is all so @math{@code{var_name}+1} can work. In math mode, _ Chris@82: % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) Chris@82: % will therefore expand the active definition of _, which is us Chris@82: % (inside @code that is), therefore an endless loop. Chris@82: \ifusingtt{\ifmmode Chris@82: \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. Chris@82: \else\normalunderscore \fi Chris@82: \discretionary{}{}{}}% Chris@82: {\_}% Chris@82: } Chris@82: Chris@82: % An additional complication: the above will allow breaks after, e.g., Chris@82: % each of the four underscores in __typeof__. This is bad. Chris@82: % @allowcodebreaks provides a document-level way to turn breaking at - Chris@82: % and _ on and off. Chris@82: % Chris@82: \newif\ifallowcodebreaks \allowcodebreakstrue Chris@82: Chris@82: \def\keywordtrue{true} Chris@82: \def\keywordfalse{false} Chris@82: Chris@82: \parseargdef\allowcodebreaks{% Chris@82: \def\txiarg{#1}% Chris@82: \ifx\txiarg\keywordtrue Chris@82: \allowcodebreakstrue Chris@82: \else\ifx\txiarg\keywordfalse Chris@82: \allowcodebreaksfalse Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % For @command, @env, @file, @option quotes seem unnecessary, Chris@82: % so use \code rather than \samp. Chris@82: \let\command=\code Chris@82: \let\env=\code Chris@82: \let\file=\code Chris@82: \let\option=\code Chris@82: Chris@82: % @uref (abbreviation for `urlref') takes an optional (comma-separated) Chris@82: % second argument specifying the text to display and an optional third Chris@82: % arg as text to display instead of (rather than in addition to) the url Chris@82: % itself. First (mandatory) arg is the url. Chris@82: % (This \urefnobreak definition isn't used now, leaving it for a while Chris@82: % for comparison.) Chris@82: \def\urefnobreak#1{\dourefnobreak #1,,,\finish} Chris@82: \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup Chris@82: \unsepspaces Chris@82: \pdfurl{#1}% Chris@82: \setbox0 = \hbox{\ignorespaces #3}% Chris@82: \ifdim\wd0 > 0pt Chris@82: \unhbox0 % third arg given, show only that Chris@82: \else Chris@82: \setbox0 = \hbox{\ignorespaces #2}% Chris@82: \ifdim\wd0 > 0pt Chris@82: \ifpdf Chris@82: \unhbox0 % PDF: 2nd arg given, show only it Chris@82: \else Chris@82: \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url Chris@82: \fi Chris@82: \else Chris@82: \code{#1}% only url given, so show it Chris@82: \fi Chris@82: \fi Chris@82: \endlink Chris@82: \endgroup} Chris@82: Chris@82: % This \urefbreak definition is the active one. Chris@82: \def\urefbreak{\begingroup \urefcatcodes \dourefbreak} Chris@82: \let\uref=\urefbreak Chris@82: \def\dourefbreak#1{\urefbreakfinish #1,,,\finish} Chris@82: \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example Chris@82: \unsepspaces Chris@82: \pdfurl{#1}% Chris@82: \setbox0 = \hbox{\ignorespaces #3}% Chris@82: \ifdim\wd0 > 0pt Chris@82: \unhbox0 % third arg given, show only that Chris@82: \else Chris@82: \setbox0 = \hbox{\ignorespaces #2}% Chris@82: \ifdim\wd0 > 0pt Chris@82: \ifpdf Chris@82: \unhbox0 % PDF: 2nd arg given, show only it Chris@82: \else Chris@82: \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url Chris@82: \fi Chris@82: \else Chris@82: \urefcode{#1}% only url given, so show it Chris@82: \fi Chris@82: \fi Chris@82: \endlink Chris@82: \endgroup} Chris@82: Chris@82: % Allow line breaks around only a few characters (only). Chris@82: \def\urefcatcodes{% Chris@82: \catcode\ampChar=\active \catcode\dotChar=\active Chris@82: \catcode\hashChar=\active \catcode\questChar=\active Chris@82: \catcode\slashChar=\active Chris@82: } Chris@82: { Chris@82: \urefcatcodes Chris@82: % Chris@82: \global\def\urefcode{\begingroup Chris@82: \setupmarkupstyle{code}% Chris@82: \urefcatcodes Chris@82: \let&\urefcodeamp Chris@82: \let.\urefcodedot Chris@82: \let#\urefcodehash Chris@82: \let?\urefcodequest Chris@82: \let/\urefcodeslash Chris@82: \codex Chris@82: } Chris@82: % Chris@82: % By default, they are just regular characters. Chris@82: \global\def&{\normalamp} Chris@82: \global\def.{\normaldot} Chris@82: \global\def#{\normalhash} Chris@82: \global\def?{\normalquest} Chris@82: \global\def/{\normalslash} Chris@82: } Chris@82: Chris@82: % we put a little stretch before and after the breakable chars, to help Chris@82: % line breaking of long url's. The unequal skips make look better in Chris@82: % cmtt at least, especially for dots. Chris@82: \def\urefprestretch{\urefprebreak \hskip0pt plus.13em } Chris@82: \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } Chris@82: % Chris@82: \def\urefcodeamp{\urefprestretch \&\urefpoststretch} Chris@82: \def\urefcodedot{\urefprestretch .\urefpoststretch} Chris@82: \def\urefcodehash{\urefprestretch \#\urefpoststretch} Chris@82: \def\urefcodequest{\urefprestretch ?\urefpoststretch} Chris@82: \def\urefcodeslash{\futurelet\next\urefcodeslashfinish} Chris@82: { Chris@82: \catcode`\/=\active Chris@82: \global\def\urefcodeslashfinish{% Chris@82: \urefprestretch \slashChar Chris@82: % Allow line break only after the final / in a sequence of Chris@82: % slashes, to avoid line break between the slashes in http://. Chris@82: \ifx\next/\else \urefpoststretch \fi Chris@82: } Chris@82: } Chris@82: Chris@82: % One more complication: by default we'll break after the special Chris@82: % characters, but some people like to break before the special chars, so Chris@82: % allow that. Also allow no breaking at all, for manual control. Chris@82: % Chris@82: \parseargdef\urefbreakstyle{% Chris@82: \def\txiarg{#1}% Chris@82: \ifx\txiarg\wordnone Chris@82: \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} Chris@82: \else\ifx\txiarg\wordbefore Chris@82: \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} Chris@82: \else\ifx\txiarg\wordafter Chris@82: \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% Chris@82: \fi\fi\fi Chris@82: } Chris@82: \def\wordafter{after} Chris@82: \def\wordbefore{before} Chris@82: \def\wordnone{none} Chris@82: Chris@82: \urefbreakstyle after Chris@82: Chris@82: % @url synonym for @uref, since that's how everyone uses it. Chris@82: % Chris@82: \let\url=\uref Chris@82: Chris@82: % rms does not like angle brackets --karl, 17may97. Chris@82: % So now @email is just like @uref, unless we are pdf. Chris@82: % Chris@82: %\def\email#1{\angleleft{\tt #1}\angleright} Chris@82: \ifpdf Chris@82: \def\email#1{\doemail#1,,\finish} Chris@82: \def\doemail#1,#2,#3\finish{\begingroup Chris@82: \unsepspaces Chris@82: \pdfurl{mailto:#1}% Chris@82: \setbox0 = \hbox{\ignorespaces #2}% Chris@82: \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi Chris@82: \endlink Chris@82: \endgroup} Chris@82: \else Chris@82: \let\email=\uref Chris@82: \fi Chris@82: Chris@82: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), Chris@82: % `example' (@kbd uses ttsl only inside of @example and friends), Chris@82: % or `code' (@kbd uses normal tty font always). Chris@82: \parseargdef\kbdinputstyle{% Chris@82: \def\txiarg{#1}% Chris@82: \ifx\txiarg\worddistinct Chris@82: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% Chris@82: \else\ifx\txiarg\wordexample Chris@82: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% Chris@82: \else\ifx\txiarg\wordcode Chris@82: \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% Chris@82: \fi\fi\fi Chris@82: } Chris@82: \def\worddistinct{distinct} Chris@82: \def\wordexample{example} Chris@82: \def\wordcode{code} Chris@82: Chris@82: % Default is `distinct'. Chris@82: \kbdinputstyle distinct Chris@82: Chris@82: % @kbd is like @code, except that if the argument is just one @key command, Chris@82: % then @kbd has no effect. Chris@82: \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} Chris@82: Chris@82: \def\xkey{\key} Chris@82: \def\kbdsub#1#2#3\par{% Chris@82: \def\one{#1}\def\three{#3}\def\threex{??}% Chris@82: \ifx\one\xkey\ifx\threex\three \key{#2}% Chris@82: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi Chris@82: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi Chris@82: } Chris@82: Chris@82: % definition of @key that produces a lozenge. Doesn't adjust to text size. Chris@82: %\setfont\keyrm\rmshape{8}{1000}{OT1} Chris@82: %\font\keysy=cmsy9 Chris@82: %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% Chris@82: % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% Chris@82: % \vbox{\hrule\kern-0.4pt Chris@82: % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% Chris@82: % \kern-0.4pt\hrule}% Chris@82: % \kern-.06em\raise0.4pt\hbox{\angleright}}}} Chris@82: Chris@82: % definition of @key with no lozenge. If the current font is already Chris@82: % monospace, don't change it; that way, we respect @kbdinputstyle. But Chris@82: % if it isn't monospace, then use \tt. Chris@82: % Chris@82: \def\key#1{{\setupmarkupstyle{key}% Chris@82: \nohyphenation Chris@82: \ifmonospace\else\tt\fi Chris@82: #1}\null} Chris@82: Chris@82: % @clicksequence{File @click{} Open ...} Chris@82: \def\clicksequence#1{\begingroup #1\endgroup} Chris@82: Chris@82: % @clickstyle @arrow (by default) Chris@82: \parseargdef\clickstyle{\def\click{#1}} Chris@82: \def\click{\arrow} Chris@82: Chris@82: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the Chris@82: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. Chris@82: % Chris@82: \def\dmn#1{\thinspace #1} Chris@82: Chris@82: % @l was never documented to mean ``switch to the Lisp font'', Chris@82: % and it is not used as such in any manual I can find. We need it for Chris@82: % Polish suppressed-l. --karl, 22sep96. Chris@82: %\def\l#1{{\li #1}\null} Chris@82: Chris@82: % @acronym for "FBI", "NATO", and the like. Chris@82: % We print this one point size smaller, since it's intended for Chris@82: % all-uppercase. Chris@82: % Chris@82: \def\acronym#1{\doacronym #1,,\finish} Chris@82: \def\doacronym#1,#2,#3\finish{% Chris@82: {\selectfonts\lsize #1}% Chris@82: \def\temp{#2}% Chris@82: \ifx\temp\empty \else Chris@82: \space ({\unsepspaces \ignorespaces \temp \unskip})% Chris@82: \fi Chris@82: \null % reset \spacefactor=1000 Chris@82: } Chris@82: Chris@82: % @abbr for "Comput. J." and the like. Chris@82: % No font change, but don't do end-of-sentence spacing. Chris@82: % Chris@82: \def\abbr#1{\doabbr #1,,\finish} Chris@82: \def\doabbr#1,#2,#3\finish{% Chris@82: {\plainfrenchspacing #1}% Chris@82: \def\temp{#2}% Chris@82: \ifx\temp\empty \else Chris@82: \space ({\unsepspaces \ignorespaces \temp \unskip})% Chris@82: \fi Chris@82: \null % reset \spacefactor=1000 Chris@82: } Chris@82: Chris@82: % @asis just yields its argument. Used with @table, for example. Chris@82: % Chris@82: \def\asis#1{#1} Chris@82: Chris@82: % @math outputs its argument in math mode. Chris@82: % Chris@82: % One complication: _ usually means subscripts, but it could also mean Chris@82: % an actual _ character, as in @math{@var{some_variable} + 1}. So make Chris@82: % _ active, and distinguish by seeing if the current family is \slfam, Chris@82: % which is what @var uses. Chris@82: { Chris@82: \catcode`\_ = \active Chris@82: \gdef\mathunderscore{% Chris@82: \catcode`\_=\active Chris@82: \def_{\ifnum\fam=\slfam \_\else\sb\fi}% Chris@82: } Chris@82: } Chris@82: % Another complication: we want \\ (and @\) to output a math (or tt) \. Chris@82: % FYI, plain.tex uses \\ as a temporary control sequence (for no Chris@82: % particular reason), but this is not advertised and we don't care. Chris@82: % Chris@82: % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. Chris@82: \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} Chris@82: % Chris@82: \def\math{% Chris@82: \tex Chris@82: \mathunderscore Chris@82: \let\\ = \mathbackslash Chris@82: \mathactive Chris@82: % make the texinfo accent commands work in math mode Chris@82: \let\"=\ddot Chris@82: \let\'=\acute Chris@82: \let\==\bar Chris@82: \let\^=\hat Chris@82: \let\`=\grave Chris@82: \let\u=\breve Chris@82: \let\v=\check Chris@82: \let\~=\tilde Chris@82: \let\dotaccent=\dot Chris@82: $\finishmath Chris@82: } Chris@82: \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. Chris@82: Chris@82: % Some active characters (such as <) are spaced differently in math. Chris@82: % We have to reset their definitions in case the @math was an argument Chris@82: % to a command which sets the catcodes (such as @item or @section). Chris@82: % Chris@82: { Chris@82: \catcode`^ = \active Chris@82: \catcode`< = \active Chris@82: \catcode`> = \active Chris@82: \catcode`+ = \active Chris@82: \catcode`' = \active Chris@82: \gdef\mathactive{% Chris@82: \let^ = \ptexhat Chris@82: \let< = \ptexless Chris@82: \let> = \ptexgtr Chris@82: \let+ = \ptexplus Chris@82: \let' = \ptexquoteright Chris@82: } Chris@82: } Chris@82: Chris@82: % ctrl is no longer a Texinfo command, but leave this definition for fun. Chris@82: \def\ctrl #1{{\tt \rawbackslash \hat}#1} Chris@82: Chris@82: % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. Chris@82: % Ignore unless FMTNAME == tex; then it is like @iftex and @tex, Chris@82: % except specified as a normal braced arg, so no newlines to worry about. Chris@82: % Chris@82: \def\outfmtnametex{tex} Chris@82: % Chris@82: \long\def\inlinefmt#1{\doinlinefmt #1,\finish} Chris@82: \long\def\doinlinefmt#1,#2,\finish{% Chris@82: \def\inlinefmtname{#1}% Chris@82: \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi Chris@82: } Chris@82: % For raw, must switch into @tex before parsing the argument, to avoid Chris@82: % setting catcodes prematurely. Doing it this way means that, for Chris@82: % example, @inlineraw{html, foo{bar} gets a parse error instead of being Chris@82: % ignored. But this isn't important because if people want a literal Chris@82: % *right* brace they would have to use a command anyway, so they may as Chris@82: % well use a command to get a left brace too. We could re-use the Chris@82: % delimiter character idea from \verb, but it seems like overkill. Chris@82: % Chris@82: \long\def\inlineraw{\tex \doinlineraw} Chris@82: \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} Chris@82: \def\doinlinerawtwo#1,#2,\finish{% Chris@82: \def\inlinerawname{#1}% Chris@82: \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi Chris@82: \endgroup % close group opened by \tex. Chris@82: } Chris@82: Chris@82: Chris@82: \message{glyphs,} Chris@82: % and logos. Chris@82: Chris@82: % @@ prints an @, as does @atchar{}. Chris@82: \def\@{\char64 } Chris@82: \let\atchar=\@ Chris@82: Chris@82: % @{ @} @lbracechar{} @rbracechar{} all generate brace characters. Chris@82: % Unless we're in typewriter, use \ecfont because the CM text fonts do Chris@82: % not have braces, and we don't want to switch into math. Chris@82: \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} Chris@82: \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} Chris@82: \let\{=\mylbrace \let\lbracechar=\{ Chris@82: \let\}=\myrbrace \let\rbracechar=\} Chris@82: \begingroup Chris@82: % Definitions to produce \{ and \} commands for indices, Chris@82: % and @{ and @} for the aux/toc files. Chris@82: \catcode`\{ = \other \catcode`\} = \other Chris@82: \catcode`\[ = 1 \catcode`\] = 2 Chris@82: \catcode`\! = 0 \catcode`\\ = \other Chris@82: !gdef!lbracecmd[\{]% Chris@82: !gdef!rbracecmd[\}]% Chris@82: !gdef!lbraceatcmd[@{]% Chris@82: !gdef!rbraceatcmd[@}]% Chris@82: !endgroup Chris@82: Chris@82: % @comma{} to avoid , parsing problems. Chris@82: \let\comma = , Chris@82: Chris@82: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent Chris@82: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. Chris@82: \let\, = \ptexc Chris@82: \let\dotaccent = \ptexdot Chris@82: \def\ringaccent#1{{\accent23 #1}} Chris@82: \let\tieaccent = \ptext Chris@82: \let\ubaraccent = \ptexb Chris@82: \let\udotaccent = \d Chris@82: Chris@82: % Other special characters: @questiondown @exclamdown @ordf @ordm Chris@82: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. Chris@82: \def\questiondown{?`} Chris@82: \def\exclamdown{!`} Chris@82: \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} Chris@82: \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} Chris@82: Chris@82: % Dotless i and dotless j, used for accents. Chris@82: \def\imacro{i} Chris@82: \def\jmacro{j} Chris@82: \def\dotless#1{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi Chris@82: \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi Chris@82: \else \errmessage{@dotless can be used only with i or j}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % The \TeX{} logo, as in plain, but resetting the spacing so that a Chris@82: % period following counts as ending a sentence. (Idea found in latex.) Chris@82: % Chris@82: \edef\TeX{\TeX \spacefactor=1000 } Chris@82: Chris@82: % @LaTeX{} logo. Not quite the same results as the definition in Chris@82: % latex.ltx, since we use a different font for the raised A; it's most Chris@82: % convenient for us to use an explicitly smaller font, rather than using Chris@82: % the \scriptstyle font (since we don't reset \scriptstyle and Chris@82: % \scriptscriptstyle). Chris@82: % Chris@82: \def\LaTeX{% Chris@82: L\kern-.36em Chris@82: {\setbox0=\hbox{T}% Chris@82: \vbox to \ht0{\hbox{% Chris@82: \ifx\textnominalsize\xwordpt Chris@82: % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. Chris@82: % Revert to plain's \scriptsize, which is 7pt. Chris@82: \count255=\the\fam $\fam\count255 \scriptstyle A$% Chris@82: \else Chris@82: % For 11pt, we can use our lllsize. Chris@82: \selectfonts\lllsize A% Chris@82: \fi Chris@82: }% Chris@82: \vss Chris@82: }}% Chris@82: \kern-.15em Chris@82: \TeX Chris@82: } Chris@82: Chris@82: % Some math mode symbols. Chris@82: \def\bullet{$\ptexbullet$} Chris@82: \def\geq{\ifmmode \ge\else $\ge$\fi} Chris@82: \def\leq{\ifmmode \le\else $\le$\fi} Chris@82: \def\minus{\ifmmode -\else $-$\fi} Chris@82: Chris@82: % @dots{} outputs an ellipsis using the current font. Chris@82: % We do .5em per period so that it has the same spacing in the cm Chris@82: % typewriter fonts as three actual period characters; on the other hand, Chris@82: % in other typewriter fonts three periods are wider than 1.5em. So do Chris@82: % whichever is larger. Chris@82: % Chris@82: \def\dots{% Chris@82: \leavevmode Chris@82: \setbox0=\hbox{...}% get width of three periods Chris@82: \ifdim\wd0 > 1.5em Chris@82: \dimen0 = \wd0 Chris@82: \else Chris@82: \dimen0 = 1.5em Chris@82: \fi Chris@82: \hbox to \dimen0{% Chris@82: \hskip 0pt plus.25fil Chris@82: .\hskip 0pt plus1fil Chris@82: .\hskip 0pt plus1fil Chris@82: .\hskip 0pt plus.5fil Chris@82: }% Chris@82: } Chris@82: Chris@82: % @enddots{} is an end-of-sentence ellipsis. Chris@82: % Chris@82: \def\enddots{% Chris@82: \dots Chris@82: \spacefactor=\endofsentencespacefactor Chris@82: } Chris@82: Chris@82: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. Chris@82: % Chris@82: % Since these characters are used in examples, they should be an even number of Chris@82: % \tt widths. Each \tt character is 1en, so two makes it 1em. Chris@82: % Chris@82: \def\point{$\star$} Chris@82: \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} Chris@82: \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} Chris@82: \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} Chris@82: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} Chris@82: \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} Chris@82: Chris@82: % The @error{} command. Chris@82: % Adapted from the TeXbook's \boxit. Chris@82: % Chris@82: \newbox\errorbox Chris@82: % Chris@82: {\tentt \global\dimen0 = 3em}% Width of the box. Chris@82: \dimen2 = .55pt % Thickness of rules Chris@82: % The text. (`r' is open on the right, `e' somewhat less so on the left.) Chris@82: \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} Chris@82: % Chris@82: \setbox\errorbox=\hbox to \dimen0{\hfil Chris@82: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. Chris@82: \advance\hsize by -2\dimen2 % Rules. Chris@82: \vbox{% Chris@82: \hrule height\dimen2 Chris@82: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. Chris@82: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. Chris@82: \kern3pt\vrule width\dimen2}% Space to right. Chris@82: \hrule height\dimen2} Chris@82: \hfil} Chris@82: % Chris@82: \def\error{\leavevmode\lower.7ex\copy\errorbox} Chris@82: Chris@82: % @pounds{} is a sterling sign, which Knuth put in the CM italic font. Chris@82: % Chris@82: \def\pounds{{\it\$}} Chris@82: Chris@82: % @euro{} comes from a separate font, depending on the current style. Chris@82: % We use the free feym* fonts from the eurosym package by Henrik Chris@82: % Theiling, which support regular, slanted, bold and bold slanted (and Chris@82: % "outlined" (blackboard board, sort of) versions, which we don't need). Chris@82: % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. Chris@82: % Chris@82: % Although only regular is the truly official Euro symbol, we ignore Chris@82: % that. The Euro is designed to be slightly taller than the regular Chris@82: % font height. Chris@82: % Chris@82: % feymr - regular Chris@82: % feymo - slanted Chris@82: % feybr - bold Chris@82: % feybo - bold slanted Chris@82: % Chris@82: % There is no good (free) typewriter version, to my knowledge. Chris@82: % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. Chris@82: % Hmm. Chris@82: % Chris@82: % Also doesn't work in math. Do we need to do math with euro symbols? Chris@82: % Hope not. Chris@82: % Chris@82: % Chris@82: \def\euro{{\eurofont e}} Chris@82: \def\eurofont{% Chris@82: % We set the font at each command, rather than predefining it in Chris@82: % \textfonts and the other font-switching commands, so that Chris@82: % installations which never need the symbol don't have to have the Chris@82: % font installed. Chris@82: % Chris@82: % There is only one designed size (nominal 10pt), so we always scale Chris@82: % that to the current nominal size. Chris@82: % Chris@82: % By the way, simply using "at 1em" works for cmr10 and the like, but Chris@82: % does not work for cmbx10 and other extended/shrunken fonts. Chris@82: % Chris@82: \def\eurosize{\csname\curfontsize nominalsize\endcsname}% Chris@82: % Chris@82: \ifx\curfontstyle\bfstylename Chris@82: % bold: Chris@82: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize Chris@82: \else Chris@82: % regular: Chris@82: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize Chris@82: \fi Chris@82: \thiseurofont Chris@82: } Chris@82: Chris@82: % Glyphs from the EC fonts. We don't use \let for the aliases, because Chris@82: % sometimes we redefine the original macro, and the alias should reflect Chris@82: % the redefinition. Chris@82: % Chris@82: % Use LaTeX names for the Icelandic letters. Chris@82: \def\DH{{\ecfont \char"D0}} % Eth Chris@82: \def\dh{{\ecfont \char"F0}} % eth Chris@82: \def\TH{{\ecfont \char"DE}} % Thorn Chris@82: \def\th{{\ecfont \char"FE}} % thorn Chris@82: % Chris@82: \def\guillemetleft{{\ecfont \char"13}} Chris@82: \def\guillemotleft{\guillemetleft} Chris@82: \def\guillemetright{{\ecfont \char"14}} Chris@82: \def\guillemotright{\guillemetright} Chris@82: \def\guilsinglleft{{\ecfont \char"0E}} Chris@82: \def\guilsinglright{{\ecfont \char"0F}} Chris@82: \def\quotedblbase{{\ecfont \char"12}} Chris@82: \def\quotesinglbase{{\ecfont \char"0D}} Chris@82: % Chris@82: % This positioning is not perfect (see the ogonek LaTeX package), but Chris@82: % we have the precomposed glyphs for the most common cases. We put the Chris@82: % tests to use those glyphs in the single \ogonek macro so we have fewer Chris@82: % dummy definitions to worry about for index entries, etc. Chris@82: % Chris@82: % ogonek is also used with other letters in Lithuanian (IOU), but using Chris@82: % the precomposed glyphs for those is not so easy since they aren't in Chris@82: % the same EC font. Chris@82: \def\ogonek#1{{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\macrocharA\Aogonek Chris@82: \else\ifx\temp\macrochara\aogonek Chris@82: \else\ifx\temp\macrocharE\Eogonek Chris@82: \else\ifx\temp\macrochare\eogonek Chris@82: \else Chris@82: \ecfont \setbox0=\hbox{#1}% Chris@82: \ifdim\ht0=1ex\accent"0C #1% Chris@82: \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% Chris@82: \fi Chris@82: \fi\fi\fi\fi Chris@82: }% Chris@82: } Chris@82: \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} Chris@82: \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} Chris@82: \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} Chris@82: \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} Chris@82: % Chris@82: % Use the ec* fonts (cm-super in outline format) for non-CM glyphs. Chris@82: \def\ecfont{% Chris@82: % We can't distinguish serif/sans and italic/slanted, but this Chris@82: % is used for crude hacks anyway (like adding French and German Chris@82: % quotes to documents typeset with CM, where we lose kerning), so Chris@82: % hopefully nobody will notice/care. Chris@82: \edef\ecsize{\csname\curfontsize ecsize\endcsname}% Chris@82: \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% Chris@82: \ifmonospace Chris@82: % typewriter: Chris@82: \font\thisecfont = ectt\ecsize \space at \nominalsize Chris@82: \else Chris@82: \ifx\curfontstyle\bfstylename Chris@82: % bold: Chris@82: \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize Chris@82: \else Chris@82: % regular: Chris@82: \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize Chris@82: \fi Chris@82: \fi Chris@82: \thisecfont Chris@82: } Chris@82: Chris@82: % @registeredsymbol - R in a circle. The font for the R should really Chris@82: % be smaller yet, but lllsize is the best we can do for now. Chris@82: % Adapted from the plain.tex definition of \copyright. Chris@82: % Chris@82: \def\registeredsymbol{% Chris@82: $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% Chris@82: \hfil\crcr\Orb}}% Chris@82: }$% Chris@82: } Chris@82: Chris@82: % @textdegree - the normal degrees sign. Chris@82: % Chris@82: \def\textdegree{$^\circ$} Chris@82: Chris@82: % Laurent Siebenmann reports \Orb undefined with: Chris@82: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 Chris@82: % so we'll define it if necessary. Chris@82: % Chris@82: \ifx\Orb\thisisundefined Chris@82: \def\Orb{\mathhexbox20D} Chris@82: \fi Chris@82: Chris@82: % Quotes. Chris@82: \chardef\quotedblleft="5C Chris@82: \chardef\quotedblright=`\" Chris@82: \chardef\quoteleft=`\` Chris@82: \chardef\quoteright=`\' Chris@82: Chris@82: Chris@82: \message{page headings,} Chris@82: Chris@82: \newskip\titlepagetopglue \titlepagetopglue = 1.5in Chris@82: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc Chris@82: Chris@82: % First the title page. Must do @settitle before @titlepage. Chris@82: \newif\ifseenauthor Chris@82: \newif\iffinishedtitlepage Chris@82: Chris@82: % Do an implicit @contents or @shortcontents after @end titlepage if the Chris@82: % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. Chris@82: % Chris@82: \newif\ifsetcontentsaftertitlepage Chris@82: \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue Chris@82: \newif\ifsetshortcontentsaftertitlepage Chris@82: \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue Chris@82: Chris@82: \parseargdef\shorttitlepage{% Chris@82: \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% Chris@82: \endgroup\page\hbox{}\page} Chris@82: Chris@82: \envdef\titlepage{% Chris@82: % Open one extra group, as we want to close it in the middle of \Etitlepage. Chris@82: \begingroup Chris@82: \parindent=0pt \textfonts Chris@82: % Leave some space at the very top of the page. Chris@82: \vglue\titlepagetopglue Chris@82: % No rule at page bottom unless we print one at the top with @title. Chris@82: \finishedtitlepagetrue Chris@82: % Chris@82: % Most title ``pages'' are actually two pages long, with space Chris@82: % at the top of the second. We don't want the ragged left on the second. Chris@82: \let\oldpage = \page Chris@82: \def\page{% Chris@82: \iffinishedtitlepage\else Chris@82: \finishtitlepage Chris@82: \fi Chris@82: \let\page = \oldpage Chris@82: \page Chris@82: \null Chris@82: }% Chris@82: } Chris@82: Chris@82: \def\Etitlepage{% Chris@82: \iffinishedtitlepage\else Chris@82: \finishtitlepage Chris@82: \fi Chris@82: % It is important to do the page break before ending the group, Chris@82: % because the headline and footline are only empty inside the group. Chris@82: % If we use the new definition of \page, we always get a blank page Chris@82: % after the title page, which we certainly don't want. Chris@82: \oldpage Chris@82: \endgroup Chris@82: % Chris@82: % Need this before the \...aftertitlepage checks so that if they are Chris@82: % in effect the toc pages will come out with page numbers. Chris@82: \HEADINGSon Chris@82: % Chris@82: % If they want short, they certainly want long too. Chris@82: \ifsetshortcontentsaftertitlepage Chris@82: \shortcontents Chris@82: \contents Chris@82: \global\let\shortcontents = \relax Chris@82: \global\let\contents = \relax Chris@82: \fi Chris@82: % Chris@82: \ifsetcontentsaftertitlepage Chris@82: \contents Chris@82: \global\let\contents = \relax Chris@82: \global\let\shortcontents = \relax Chris@82: \fi Chris@82: } Chris@82: Chris@82: \def\finishtitlepage{% Chris@82: \vskip4pt \hrule height 2pt width \hsize Chris@82: \vskip\titlepagebottomglue Chris@82: \finishedtitlepagetrue Chris@82: } Chris@82: Chris@82: % Settings used for typesetting titles: no hyphenation, no indentation, Chris@82: % don't worry much about spacing, ragged right. This should be used Chris@82: % inside a \vbox, and fonts need to be set appropriately first. Because Chris@82: % it is always used for titles, nothing else, we call \rmisbold. \par Chris@82: % should be specified before the end of the \vbox, since a vbox is a group. Chris@82: % Chris@82: \def\raggedtitlesettings{% Chris@82: \rmisbold Chris@82: \hyphenpenalty=10000 Chris@82: \parindent=0pt Chris@82: \tolerance=5000 Chris@82: \ptexraggedright Chris@82: } Chris@82: Chris@82: % Macros to be used within @titlepage: Chris@82: Chris@82: \let\subtitlerm=\tenrm Chris@82: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} Chris@82: Chris@82: \parseargdef\title{% Chris@82: \checkenv\titlepage Chris@82: \vbox{\titlefonts \raggedtitlesettings #1\par}% Chris@82: % print a rule at the page bottom also. Chris@82: \finishedtitlepagefalse Chris@82: \vskip4pt \hrule height 4pt width \hsize \vskip4pt Chris@82: } Chris@82: Chris@82: \parseargdef\subtitle{% Chris@82: \checkenv\titlepage Chris@82: {\subtitlefont \rightline{#1}}% Chris@82: } Chris@82: Chris@82: % @author should come last, but may come many times. Chris@82: % It can also be used inside @quotation. Chris@82: % Chris@82: \parseargdef\author{% Chris@82: \def\temp{\quotation}% Chris@82: \ifx\thisenv\temp Chris@82: \def\quotationauthor{#1}% printed in \Equotation. Chris@82: \else Chris@82: \checkenv\titlepage Chris@82: \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi Chris@82: {\secfonts\rmisbold \leftline{#1}}% Chris@82: \fi Chris@82: } Chris@82: Chris@82: Chris@82: % Set up page headings and footings. Chris@82: Chris@82: \let\thispage=\folio Chris@82: Chris@82: \newtoks\evenheadline % headline on even pages Chris@82: \newtoks\oddheadline % headline on odd pages Chris@82: \newtoks\evenfootline % footline on even pages Chris@82: \newtoks\oddfootline % footline on odd pages Chris@82: Chris@82: % Now make TeX use those variables Chris@82: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline Chris@82: \else \the\evenheadline \fi}} Chris@82: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline Chris@82: \else \the\evenfootline \fi}\HEADINGShook} Chris@82: \let\HEADINGShook=\relax Chris@82: Chris@82: % Commands to set those variables. Chris@82: % For example, this is what @headings on does Chris@82: % @evenheading @thistitle|@thispage|@thischapter Chris@82: % @oddheading @thischapter|@thispage|@thistitle Chris@82: % @evenfooting @thisfile|| Chris@82: % @oddfooting ||@thisfile Chris@82: Chris@82: Chris@82: \def\evenheading{\parsearg\evenheadingxxx} Chris@82: \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} Chris@82: \def\evenheadingyyy #1\|#2\|#3\|#4\finish{% Chris@82: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} Chris@82: Chris@82: \def\oddheading{\parsearg\oddheadingxxx} Chris@82: \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} Chris@82: \def\oddheadingyyy #1\|#2\|#3\|#4\finish{% Chris@82: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} Chris@82: Chris@82: \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% Chris@82: Chris@82: \def\evenfooting{\parsearg\evenfootingxxx} Chris@82: \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} Chris@82: \def\evenfootingyyy #1\|#2\|#3\|#4\finish{% Chris@82: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} Chris@82: Chris@82: \def\oddfooting{\parsearg\oddfootingxxx} Chris@82: \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} Chris@82: \def\oddfootingyyy #1\|#2\|#3\|#4\finish{% Chris@82: \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% Chris@82: % Chris@82: % Leave some space for the footline. Hopefully ok to assume Chris@82: % @evenfooting will not be used by itself. Chris@82: \global\advance\pageheight by -12pt Chris@82: \global\advance\vsize by -12pt Chris@82: } Chris@82: Chris@82: \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} Chris@82: Chris@82: % @evenheadingmarks top \thischapter <- chapter at the top of a page Chris@82: % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page Chris@82: % Chris@82: % The same set of arguments for: Chris@82: % Chris@82: % @oddheadingmarks Chris@82: % @evenfootingmarks Chris@82: % @oddfootingmarks Chris@82: % @everyheadingmarks Chris@82: % @everyfootingmarks Chris@82: Chris@82: \def\evenheadingmarks{\headingmarks{even}{heading}} Chris@82: \def\oddheadingmarks{\headingmarks{odd}{heading}} Chris@82: \def\evenfootingmarks{\headingmarks{even}{footing}} Chris@82: \def\oddfootingmarks{\headingmarks{odd}{footing}} Chris@82: \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} Chris@82: \headingmarks{odd}{heading}{#1} } Chris@82: \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} Chris@82: \headingmarks{odd}{footing}{#1} } Chris@82: % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. Chris@82: \def\headingmarks#1#2#3 {% Chris@82: \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname Chris@82: \global\expandafter\let\csname get#1#2marks\endcsname \temp Chris@82: } Chris@82: Chris@82: \everyheadingmarks bottom Chris@82: \everyfootingmarks bottom Chris@82: Chris@82: % @headings double turns headings on for double-sided printing. Chris@82: % @headings single turns headings on for single-sided printing. Chris@82: % @headings off turns them off. Chris@82: % @headings on same as @headings double, retained for compatibility. Chris@82: % @headings after turns on double-sided headings after this page. Chris@82: % @headings doubleafter turns on double-sided headings after this page. Chris@82: % @headings singleafter turns on single-sided headings after this page. Chris@82: % By default, they are off at the start of a document, Chris@82: % and turned `on' after @end titlepage. Chris@82: Chris@82: \def\headings #1 {\csname HEADINGS#1\endcsname} Chris@82: Chris@82: \def\headingsoff{% non-global headings elimination Chris@82: \evenheadline={\hfil}\evenfootline={\hfil}% Chris@82: \oddheadline={\hfil}\oddfootline={\hfil}% Chris@82: } Chris@82: Chris@82: \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting Chris@82: \HEADINGSoff % it's the default Chris@82: Chris@82: % When we turn headings on, set the page number to 1. Chris@82: % For double-sided printing, put current file name in lower left corner, Chris@82: % chapter name on inside top of right hand pages, document Chris@82: % title on inside top of left hand pages, and page numbers on outside top Chris@82: % edge of all pages. Chris@82: \def\HEADINGSdouble{% Chris@82: \global\pageno=1 Chris@82: \global\evenfootline={\hfil} Chris@82: \global\oddfootline={\hfil} Chris@82: \global\evenheadline={\line{\folio\hfil\thistitle}} Chris@82: \global\oddheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\let\contentsalignmacro = \chapoddpage Chris@82: } Chris@82: \let\contentsalignmacro = \chappager Chris@82: Chris@82: % For single-sided printing, chapter title goes across top left of page, Chris@82: % page number on top right. Chris@82: \def\HEADINGSsingle{% Chris@82: \global\pageno=1 Chris@82: \global\evenfootline={\hfil} Chris@82: \global\oddfootline={\hfil} Chris@82: \global\evenheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\oddheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\let\contentsalignmacro = \chappager Chris@82: } Chris@82: \def\HEADINGSon{\HEADINGSdouble} Chris@82: Chris@82: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} Chris@82: \let\HEADINGSdoubleafter=\HEADINGSafter Chris@82: \def\HEADINGSdoublex{% Chris@82: \global\evenfootline={\hfil} Chris@82: \global\oddfootline={\hfil} Chris@82: \global\evenheadline={\line{\folio\hfil\thistitle}} Chris@82: \global\oddheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\let\contentsalignmacro = \chapoddpage Chris@82: } Chris@82: Chris@82: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} Chris@82: \def\HEADINGSsinglex{% Chris@82: \global\evenfootline={\hfil} Chris@82: \global\oddfootline={\hfil} Chris@82: \global\evenheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\oddheadline={\line{\thischapter\hfil\folio}} Chris@82: \global\let\contentsalignmacro = \chappager Chris@82: } Chris@82: Chris@82: % Subroutines used in generating headings Chris@82: % This produces Day Month Year style of output. Chris@82: % Only define if not already defined, in case a txi-??.tex file has set Chris@82: % up a different format (e.g., txi-cs.tex does this). Chris@82: \ifx\today\thisisundefined Chris@82: \def\today{% Chris@82: \number\day\space Chris@82: \ifcase\month Chris@82: \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr Chris@82: \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug Chris@82: \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec Chris@82: \fi Chris@82: \space\number\year} Chris@82: \fi Chris@82: Chris@82: % @settitle line... specifies the title of the document, for headings. Chris@82: % It generates no output of its own. Chris@82: \def\thistitle{\putwordNoTitle} Chris@82: \def\settitle{\parsearg{\gdef\thistitle}} Chris@82: Chris@82: Chris@82: \message{tables,} Chris@82: % Tables -- @table, @ftable, @vtable, @item(x). Chris@82: Chris@82: % default indentation of table text Chris@82: \newdimen\tableindent \tableindent=.8in Chris@82: % default indentation of @itemize and @enumerate text Chris@82: \newdimen\itemindent \itemindent=.3in Chris@82: % margin between end of table item and start of table text. Chris@82: \newdimen\itemmargin \itemmargin=.1in Chris@82: Chris@82: % used internally for \itemindent minus \itemmargin Chris@82: \newdimen\itemmax Chris@82: Chris@82: % Note @table, @ftable, and @vtable define @item, @itemx, etc., with Chris@82: % these defs. Chris@82: % They also define \itemindex Chris@82: % to index the item name in whatever manner is desired (perhaps none). Chris@82: Chris@82: \newif\ifitemxneedsnegativevskip Chris@82: Chris@82: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} Chris@82: Chris@82: \def\internalBitem{\smallbreak \parsearg\itemzzz} Chris@82: \def\internalBitemx{\itemxpar \parsearg\itemzzz} Chris@82: Chris@82: \def\itemzzz #1{\begingroup % Chris@82: \advance\hsize by -\rightskip Chris@82: \advance\hsize by -\tableindent Chris@82: \setbox0=\hbox{\itemindicate{#1}}% Chris@82: \itemindex{#1}% Chris@82: \nobreak % This prevents a break before @itemx. Chris@82: % Chris@82: % If the item text does not fit in the space we have, put it on a line Chris@82: % by itself, and do not allow a page break either before or after that Chris@82: % line. We do not start a paragraph here because then if the next Chris@82: % command is, e.g., @kindex, the whatsit would get put into the Chris@82: % horizontal list on a line by itself, resulting in extra blank space. Chris@82: \ifdim \wd0>\itemmax Chris@82: % Chris@82: % Make this a paragraph so we get the \parskip glue and wrapping, Chris@82: % but leave it ragged-right. Chris@82: \begingroup Chris@82: \advance\leftskip by-\tableindent Chris@82: \advance\hsize by\tableindent Chris@82: \advance\rightskip by0pt plus1fil\relax Chris@82: \leavevmode\unhbox0\par Chris@82: \endgroup Chris@82: % Chris@82: % We're going to be starting a paragraph, but we don't want the Chris@82: % \parskip glue -- logically it's part of the @item we just started. Chris@82: \nobreak \vskip-\parskip Chris@82: % Chris@82: % Stop a page break at the \parskip glue coming up. However, if Chris@82: % what follows is an environment such as @example, there will be no Chris@82: % \parskip glue; then the negative vskip we just inserted would Chris@82: % cause the example and the item to crash together. So we use this Chris@82: % bizarre value of 10001 as a signal to \aboveenvbreak to insert Chris@82: % \parskip glue after all. Section titles are handled this way also. Chris@82: % Chris@82: \penalty 10001 Chris@82: \endgroup Chris@82: \itemxneedsnegativevskipfalse Chris@82: \else Chris@82: % The item text fits into the space. Start a paragraph, so that the Chris@82: % following text (if any) will end up on the same line. Chris@82: \noindent Chris@82: % Do this with kerns and \unhbox so that if there is a footnote in Chris@82: % the item text, it can migrate to the main vertical list and Chris@82: % eventually be printed. Chris@82: \nobreak\kern-\tableindent Chris@82: \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 Chris@82: \unhbox0 Chris@82: \nobreak\kern\dimen0 Chris@82: \endgroup Chris@82: \itemxneedsnegativevskiptrue Chris@82: \fi Chris@82: } Chris@82: Chris@82: \def\item{\errmessage{@item while not in a list environment}} Chris@82: \def\itemx{\errmessage{@itemx while not in a list environment}} Chris@82: Chris@82: % @table, @ftable, @vtable. Chris@82: \envdef\table{% Chris@82: \let\itemindex\gobble Chris@82: \tablecheck{table}% Chris@82: } Chris@82: \envdef\ftable{% Chris@82: \def\itemindex ##1{\doind {fn}{\code{##1}}}% Chris@82: \tablecheck{ftable}% Chris@82: } Chris@82: \envdef\vtable{% Chris@82: \def\itemindex ##1{\doind {vr}{\code{##1}}}% Chris@82: \tablecheck{vtable}% Chris@82: } Chris@82: \def\tablecheck#1{% Chris@82: \ifnum \the\catcode`\^^M=\active Chris@82: \endgroup Chris@82: \errmessage{This command won't work in this context; perhaps the problem is Chris@82: that we are \inenvironment\thisenv}% Chris@82: \def\next{\doignore{#1}}% Chris@82: \else Chris@82: \let\next\tablex Chris@82: \fi Chris@82: \next Chris@82: } Chris@82: \def\tablex#1{% Chris@82: \def\itemindicate{#1}% Chris@82: \parsearg\tabley Chris@82: } Chris@82: \def\tabley#1{% Chris@82: {% Chris@82: \makevalueexpandable Chris@82: \edef\temp{\noexpand\tablez #1\space\space\space}% Chris@82: \expandafter Chris@82: }\temp \endtablez Chris@82: } Chris@82: \def\tablez #1 #2 #3 #4\endtablez{% Chris@82: \aboveenvbreak Chris@82: \ifnum 0#1>0 \advance \leftskip by #1\mil \fi Chris@82: \ifnum 0#2>0 \tableindent=#2\mil \fi Chris@82: \ifnum 0#3>0 \advance \rightskip by #3\mil \fi Chris@82: \itemmax=\tableindent Chris@82: \advance \itemmax by -\itemmargin Chris@82: \advance \leftskip by \tableindent Chris@82: \exdentamount=\tableindent Chris@82: \parindent = 0pt Chris@82: \parskip = \smallskipamount Chris@82: \ifdim \parskip=0pt \parskip=2pt \fi Chris@82: \let\item = \internalBitem Chris@82: \let\itemx = \internalBitemx Chris@82: } Chris@82: \def\Etable{\endgraf\afterenvbreak} Chris@82: \let\Eftable\Etable Chris@82: \let\Evtable\Etable Chris@82: \let\Eitemize\Etable Chris@82: \let\Eenumerate\Etable Chris@82: Chris@82: % This is the counter used by @enumerate, which is really @itemize Chris@82: Chris@82: \newcount \itemno Chris@82: Chris@82: \envdef\itemize{\parsearg\doitemize} Chris@82: Chris@82: \def\doitemize#1{% Chris@82: \aboveenvbreak Chris@82: \itemmax=\itemindent Chris@82: \advance\itemmax by -\itemmargin Chris@82: \advance\leftskip by \itemindent Chris@82: \exdentamount=\itemindent Chris@82: \parindent=0pt Chris@82: \parskip=\smallskipamount Chris@82: \ifdim\parskip=0pt \parskip=2pt \fi Chris@82: % Chris@82: % Try typesetting the item mark that if the document erroneously says Chris@82: % something like @itemize @samp (intending @table), there's an error Chris@82: % right away at the @itemize. It's not the best error message in the Chris@82: % world, but it's better than leaving it to the @item. This means if Chris@82: % the user wants an empty mark, they have to say @w{} not just @w. Chris@82: \def\itemcontents{#1}% Chris@82: \setbox0 = \hbox{\itemcontents}% Chris@82: % Chris@82: % @itemize with no arg is equivalent to @itemize @bullet. Chris@82: \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi Chris@82: % Chris@82: \let\item=\itemizeitem Chris@82: } Chris@82: Chris@82: % Definition of @item while inside @itemize and @enumerate. Chris@82: % Chris@82: \def\itemizeitem{% Chris@82: \advance\itemno by 1 % for enumerations Chris@82: {\let\par=\endgraf \smallbreak}% reasonable place to break Chris@82: {% Chris@82: % If the document has an @itemize directly after a section title, a Chris@82: % \nobreak will be last on the list, and \sectionheading will have Chris@82: % done a \vskip-\parskip. In that case, we don't want to zero Chris@82: % parskip, or the item text will crash with the heading. On the Chris@82: % other hand, when there is normal text preceding the item (as there Chris@82: % usually is), we do want to zero parskip, or there would be too much Chris@82: % space. In that case, we won't have a \nobreak before. At least Chris@82: % that's the theory. Chris@82: \ifnum\lastpenalty<10000 \parskip=0in \fi Chris@82: \noindent Chris@82: \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% Chris@82: % Chris@82: \vadjust{\penalty 1200}}% not good to break after first line of item. Chris@82: \flushcr Chris@82: } Chris@82: Chris@82: % \splitoff TOKENS\endmark defines \first to be the first token in Chris@82: % TOKENS, and \rest to be the remainder. Chris@82: % Chris@82: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% Chris@82: Chris@82: % Allow an optional argument of an uppercase letter, lowercase letter, Chris@82: % or number, to specify the first label in the enumerated list. No Chris@82: % argument is the same as `1'. Chris@82: % Chris@82: \envparseargdef\enumerate{\enumeratey #1 \endenumeratey} Chris@82: \def\enumeratey #1 #2\endenumeratey{% Chris@82: % If we were given no argument, pretend we were given `1'. Chris@82: \def\thearg{#1}% Chris@82: \ifx\thearg\empty \def\thearg{1}\fi Chris@82: % Chris@82: % Detect if the argument is a single token. If so, it might be a Chris@82: % letter. Otherwise, the only valid thing it can be is a number. Chris@82: % (We will always have one token, because of the test we just made. Chris@82: % This is a good thing, since \splitoff doesn't work given nothing at Chris@82: % all -- the first parameter is undelimited.) Chris@82: \expandafter\splitoff\thearg\endmark Chris@82: \ifx\rest\empty Chris@82: % Only one token in the argument. It could still be anything. Chris@82: % A ``lowercase letter'' is one whose \lccode is nonzero. Chris@82: % An ``uppercase letter'' is one whose \lccode is both nonzero, and Chris@82: % not equal to itself. Chris@82: % Otherwise, we assume it's a number. Chris@82: % Chris@82: % We need the \relax at the end of the \ifnum lines to stop TeX from Chris@82: % continuing to look for a . Chris@82: % Chris@82: \ifnum\lccode\expandafter`\thearg=0\relax Chris@82: \numericenumerate % a number (we hope) Chris@82: \else Chris@82: % It's a letter. Chris@82: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax Chris@82: \lowercaseenumerate % lowercase letter Chris@82: \else Chris@82: \uppercaseenumerate % uppercase letter Chris@82: \fi Chris@82: \fi Chris@82: \else Chris@82: % Multiple tokens in the argument. We hope it's a number. Chris@82: \numericenumerate Chris@82: \fi Chris@82: } Chris@82: Chris@82: % An @enumerate whose labels are integers. The starting integer is Chris@82: % given in \thearg. Chris@82: % Chris@82: \def\numericenumerate{% Chris@82: \itemno = \thearg Chris@82: \startenumeration{\the\itemno}% Chris@82: } Chris@82: Chris@82: % The starting (lowercase) letter is in \thearg. Chris@82: \def\lowercaseenumerate{% Chris@82: \itemno = \expandafter`\thearg Chris@82: \startenumeration{% Chris@82: % Be sure we're not beyond the end of the alphabet. Chris@82: \ifnum\itemno=0 Chris@82: \errmessage{No more lowercase letters in @enumerate; get a bigger Chris@82: alphabet}% Chris@82: \fi Chris@82: \char\lccode\itemno Chris@82: }% Chris@82: } Chris@82: Chris@82: % The starting (uppercase) letter is in \thearg. Chris@82: \def\uppercaseenumerate{% Chris@82: \itemno = \expandafter`\thearg Chris@82: \startenumeration{% Chris@82: % Be sure we're not beyond the end of the alphabet. Chris@82: \ifnum\itemno=0 Chris@82: \errmessage{No more uppercase letters in @enumerate; get a bigger Chris@82: alphabet} Chris@82: \fi Chris@82: \char\uccode\itemno Chris@82: }% Chris@82: } Chris@82: Chris@82: % Call \doitemize, adding a period to the first argument and supplying the Chris@82: % common last two arguments. Also subtract one from the initial value in Chris@82: % \itemno, since @item increments \itemno. Chris@82: % Chris@82: \def\startenumeration#1{% Chris@82: \advance\itemno by -1 Chris@82: \doitemize{#1.}\flushcr Chris@82: } Chris@82: Chris@82: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg Chris@82: % to @enumerate. Chris@82: % Chris@82: \def\alphaenumerate{\enumerate{a}} Chris@82: \def\capsenumerate{\enumerate{A}} Chris@82: \def\Ealphaenumerate{\Eenumerate} Chris@82: \def\Ecapsenumerate{\Eenumerate} Chris@82: Chris@82: Chris@82: % @multitable macros Chris@82: % Amy Hendrickson, 8/18/94, 3/6/96 Chris@82: % Chris@82: % @multitable ... @end multitable will make as many columns as desired. Chris@82: % Contents of each column will wrap at width given in preamble. Width Chris@82: % can be specified either with sample text given in a template line, Chris@82: % or in percent of \hsize, the current width of text on page. Chris@82: Chris@82: % Table can continue over pages but will only break between lines. Chris@82: Chris@82: % To make preamble: Chris@82: % Chris@82: % Either define widths of columns in terms of percent of \hsize: Chris@82: % @multitable @columnfractions .25 .3 .45 Chris@82: % @item ... Chris@82: % Chris@82: % Numbers following @columnfractions are the percent of the total Chris@82: % current hsize to be used for each column. You may use as many Chris@82: % columns as desired. Chris@82: Chris@82: Chris@82: % Or use a template: Chris@82: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} Chris@82: % @item ... Chris@82: % using the widest term desired in each column. Chris@82: Chris@82: % Each new table line starts with @item, each subsequent new column Chris@82: % starts with @tab. Empty columns may be produced by supplying @tab's Chris@82: % with nothing between them for as many times as empty columns are needed, Chris@82: % ie, @tab@tab@tab will produce two empty columns. Chris@82: Chris@82: % @item, @tab do not need to be on their own lines, but it will not hurt Chris@82: % if they are. Chris@82: Chris@82: % Sample multitable: Chris@82: Chris@82: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} Chris@82: % @item first col stuff @tab second col stuff @tab third col Chris@82: % @item Chris@82: % first col stuff Chris@82: % @tab Chris@82: % second col stuff Chris@82: % @tab Chris@82: % third col Chris@82: % @item first col stuff @tab second col stuff Chris@82: % @tab Many paragraphs of text may be used in any column. Chris@82: % Chris@82: % They will wrap at the width determined by the template. Chris@82: % @item@tab@tab This will be in third column. Chris@82: % @end multitable Chris@82: Chris@82: % Default dimensions may be reset by user. Chris@82: % @multitableparskip is vertical space between paragraphs in table. Chris@82: % @multitableparindent is paragraph indent in table. Chris@82: % @multitablecolmargin is horizontal space to be left between columns. Chris@82: % @multitablelinespace is space to leave between table items, baseline Chris@82: % to baseline. Chris@82: % 0pt means it depends on current normal line spacing. Chris@82: % Chris@82: \newskip\multitableparskip Chris@82: \newskip\multitableparindent Chris@82: \newdimen\multitablecolspace Chris@82: \newskip\multitablelinespace Chris@82: \multitableparskip=0pt Chris@82: \multitableparindent=6pt Chris@82: \multitablecolspace=12pt Chris@82: \multitablelinespace=0pt Chris@82: Chris@82: % Macros used to set up halign preamble: Chris@82: % Chris@82: \let\endsetuptable\relax Chris@82: \def\xendsetuptable{\endsetuptable} Chris@82: \let\columnfractions\relax Chris@82: \def\xcolumnfractions{\columnfractions} Chris@82: \newif\ifsetpercent Chris@82: Chris@82: % #1 is the @columnfraction, usually a decimal number like .5, but might Chris@82: % be just 1. We just use it, whatever it is. Chris@82: % Chris@82: \def\pickupwholefraction#1 {% Chris@82: \global\advance\colcount by 1 Chris@82: \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% Chris@82: \setuptable Chris@82: } Chris@82: Chris@82: \newcount\colcount Chris@82: \def\setuptable#1{% Chris@82: \def\firstarg{#1}% Chris@82: \ifx\firstarg\xendsetuptable Chris@82: \let\go = \relax Chris@82: \else Chris@82: \ifx\firstarg\xcolumnfractions Chris@82: \global\setpercenttrue Chris@82: \else Chris@82: \ifsetpercent Chris@82: \let\go\pickupwholefraction Chris@82: \else Chris@82: \global\advance\colcount by 1 Chris@82: \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a Chris@82: % separator; typically that is always in the input, anyway. Chris@82: \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% Chris@82: \fi Chris@82: \fi Chris@82: \ifx\go\pickupwholefraction Chris@82: % Put the argument back for the \pickupwholefraction call, so Chris@82: % we'll always have a period there to be parsed. Chris@82: \def\go{\pickupwholefraction#1}% Chris@82: \else Chris@82: \let\go = \setuptable Chris@82: \fi% Chris@82: \fi Chris@82: \go Chris@82: } Chris@82: Chris@82: % multitable-only commands. Chris@82: % Chris@82: % @headitem starts a heading row, which we typeset in bold. Chris@82: % Assignments have to be global since we are inside the implicit group Chris@82: % of an alignment entry. \everycr resets \everytab so we don't have to Chris@82: % undo it ourselves. Chris@82: \def\headitemfont{\b}% for people to use in the template row; not changeable Chris@82: \def\headitem{% Chris@82: \checkenv\multitable Chris@82: \crcr Chris@82: \global\everytab={\bf}% can't use \headitemfont since the parsing differs Chris@82: \the\everytab % for the first item Chris@82: }% Chris@82: % Chris@82: % A \tab used to include \hskip1sp. But then the space in a template Chris@82: % line is not enough. That is bad. So let's go back to just `&' until Chris@82: % we again encounter the problem the 1sp was intended to solve. Chris@82: % --karl, nathan@acm.org, 20apr99. Chris@82: \def\tab{\checkenv\multitable &\the\everytab}% Chris@82: Chris@82: % @multitable ... @end multitable definitions: Chris@82: % Chris@82: \newtoks\everytab % insert after every tab. Chris@82: % Chris@82: \envdef\multitable{% Chris@82: \vskip\parskip Chris@82: \startsavinginserts Chris@82: % Chris@82: % @item within a multitable starts a normal row. Chris@82: % We use \def instead of \let so that if one of the multitable entries Chris@82: % contains an @itemize, we don't choke on the \item (seen as \crcr aka Chris@82: % \endtemplate) expanding \doitemize. Chris@82: \def\item{\crcr}% Chris@82: % Chris@82: \tolerance=9500 Chris@82: \hbadness=9500 Chris@82: \setmultitablespacing Chris@82: \parskip=\multitableparskip Chris@82: \parindent=\multitableparindent Chris@82: \overfullrule=0pt Chris@82: \global\colcount=0 Chris@82: % Chris@82: \everycr = {% Chris@82: \noalign{% Chris@82: \global\everytab={}% Chris@82: \global\colcount=0 % Reset the column counter. Chris@82: % Check for saved footnotes, etc. Chris@82: \checkinserts Chris@82: % Keeps underfull box messages off when table breaks over pages. Chris@82: %\filbreak Chris@82: % Maybe so, but it also creates really weird page breaks when the Chris@82: % table breaks over pages. Wouldn't \vfil be better? Wait until the Chris@82: % problem manifests itself, so it can be fixed for real --karl. Chris@82: }% Chris@82: }% Chris@82: % Chris@82: \parsearg\domultitable Chris@82: } Chris@82: \def\domultitable#1{% Chris@82: % To parse everything between @multitable and @item: Chris@82: \setuptable#1 \endsetuptable Chris@82: % Chris@82: % This preamble sets up a generic column definition, which will Chris@82: % be used as many times as user calls for columns. Chris@82: % \vtop will set a single line and will also let text wrap and Chris@82: % continue for many paragraphs if desired. Chris@82: \halign\bgroup &% Chris@82: \global\advance\colcount by 1 Chris@82: \multistrut Chris@82: \vtop{% Chris@82: % Use the current \colcount to find the correct column width: Chris@82: \hsize=\expandafter\csname col\the\colcount\endcsname Chris@82: % Chris@82: % In order to keep entries from bumping into each other Chris@82: % we will add a \leftskip of \multitablecolspace to all columns after Chris@82: % the first one. Chris@82: % Chris@82: % If a template has been used, we will add \multitablecolspace Chris@82: % to the width of each template entry. Chris@82: % Chris@82: % If the user has set preamble in terms of percent of \hsize we will Chris@82: % use that dimension as the width of the column, and the \leftskip Chris@82: % will keep entries from bumping into each other. Table will start at Chris@82: % left margin and final column will justify at right margin. Chris@82: % Chris@82: % Make sure we don't inherit \rightskip from the outer environment. Chris@82: \rightskip=0pt Chris@82: \ifnum\colcount=1 Chris@82: % The first column will be indented with the surrounding text. Chris@82: \advance\hsize by\leftskip Chris@82: \else Chris@82: \ifsetpercent \else Chris@82: % If user has not set preamble in terms of percent of \hsize Chris@82: % we will advance \hsize by \multitablecolspace. Chris@82: \advance\hsize by \multitablecolspace Chris@82: \fi Chris@82: % In either case we will make \leftskip=\multitablecolspace: Chris@82: \leftskip=\multitablecolspace Chris@82: \fi Chris@82: % Ignoring space at the beginning and end avoids an occasional spurious Chris@82: % blank line, when TeX decides to break the line at the space before the Chris@82: % box from the multistrut, so the strut ends up on a line by itself. Chris@82: % For example: Chris@82: % @multitable @columnfractions .11 .89 Chris@82: % @item @code{#} Chris@82: % @tab Legal holiday which is valid in major parts of the whole country. Chris@82: % Is automatically provided with highlighting sequences respectively Chris@82: % marking characters. Chris@82: \noindent\ignorespaces##\unskip\multistrut Chris@82: }\cr Chris@82: } Chris@82: \def\Emultitable{% Chris@82: \crcr Chris@82: \egroup % end the \halign Chris@82: \global\setpercentfalse Chris@82: } Chris@82: Chris@82: \def\setmultitablespacing{% Chris@82: \def\multistrut{\strut}% just use the standard line spacing Chris@82: % Chris@82: % Compute \multitablelinespace (if not defined by user) for use in Chris@82: % \multitableparskip calculation. We used define \multistrut based on Chris@82: % this, but (ironically) that caused the spacing to be off. Chris@82: % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. Chris@82: \ifdim\multitablelinespace=0pt Chris@82: \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip Chris@82: \global\advance\multitablelinespace by-\ht0 Chris@82: \fi Chris@82: % Test to see if parskip is larger than space between lines of Chris@82: % table. If not, do nothing. Chris@82: % If so, set to same dimension as multitablelinespace. Chris@82: \ifdim\multitableparskip>\multitablelinespace Chris@82: \global\multitableparskip=\multitablelinespace Chris@82: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller Chris@82: % than skip between lines in the table. Chris@82: \fi% Chris@82: \ifdim\multitableparskip=0pt Chris@82: \global\multitableparskip=\multitablelinespace Chris@82: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller Chris@82: % than skip between lines in the table. Chris@82: \fi} Chris@82: Chris@82: Chris@82: \message{conditionals,} Chris@82: Chris@82: % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, Chris@82: % @ifnotxml always succeed. They currently do nothing; we don't Chris@82: % attempt to check whether the conditionals are properly nested. But we Chris@82: % have to remember that they are conditionals, so that @end doesn't Chris@82: % attempt to close an environment group. Chris@82: % Chris@82: \def\makecond#1{% Chris@82: \expandafter\let\csname #1\endcsname = \relax Chris@82: \expandafter\let\csname iscond.#1\endcsname = 1 Chris@82: } Chris@82: \makecond{iftex} Chris@82: \makecond{ifnotdocbook} Chris@82: \makecond{ifnothtml} Chris@82: \makecond{ifnotinfo} Chris@82: \makecond{ifnotplaintext} Chris@82: \makecond{ifnotxml} Chris@82: Chris@82: % Ignore @ignore, @ifhtml, @ifinfo, and the like. Chris@82: % Chris@82: \def\direntry{\doignore{direntry}} Chris@82: \def\documentdescription{\doignore{documentdescription}} Chris@82: \def\docbook{\doignore{docbook}} Chris@82: \def\html{\doignore{html}} Chris@82: \def\ifdocbook{\doignore{ifdocbook}} Chris@82: \def\ifhtml{\doignore{ifhtml}} Chris@82: \def\ifinfo{\doignore{ifinfo}} Chris@82: \def\ifnottex{\doignore{ifnottex}} Chris@82: \def\ifplaintext{\doignore{ifplaintext}} Chris@82: \def\ifxml{\doignore{ifxml}} Chris@82: \def\ignore{\doignore{ignore}} Chris@82: \def\menu{\doignore{menu}} Chris@82: \def\xml{\doignore{xml}} Chris@82: Chris@82: % Ignore text until a line `@end #1', keeping track of nested conditionals. Chris@82: % Chris@82: % A count to remember the depth of nesting. Chris@82: \newcount\doignorecount Chris@82: Chris@82: \def\doignore#1{\begingroup Chris@82: % Scan in ``verbatim'' mode: Chris@82: \obeylines Chris@82: \catcode`\@ = \other Chris@82: \catcode`\{ = \other Chris@82: \catcode`\} = \other Chris@82: % Chris@82: % Make sure that spaces turn into tokens that match what \doignoretext wants. Chris@82: \spaceisspace Chris@82: % Chris@82: % Count number of #1's that we've seen. Chris@82: \doignorecount = 0 Chris@82: % Chris@82: % Swallow text until we reach the matching `@end #1'. Chris@82: \dodoignore{#1}% Chris@82: } Chris@82: Chris@82: { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. Chris@82: \obeylines % Chris@82: % Chris@82: \gdef\dodoignore#1{% Chris@82: % #1 contains the command name as a string, e.g., `ifinfo'. Chris@82: % Chris@82: % Define a command to find the next `@end #1'. Chris@82: \long\def\doignoretext##1^^M@end #1{% Chris@82: \doignoretextyyy##1^^M@#1\_STOP_}% Chris@82: % Chris@82: % And this command to find another #1 command, at the beginning of a Chris@82: % line. (Otherwise, we would consider a line `@c @ifset', for Chris@82: % example, to count as an @ifset for nesting.) Chris@82: \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% Chris@82: % Chris@82: % And now expand that command. Chris@82: \doignoretext ^^M% Chris@82: }% Chris@82: } Chris@82: Chris@82: \def\doignoreyyy#1{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\empty % Nothing found. Chris@82: \let\next\doignoretextzzz Chris@82: \else % Found a nested condition, ... Chris@82: \advance\doignorecount by 1 Chris@82: \let\next\doignoretextyyy % ..., look for another. Chris@82: % If we're here, #1 ends with ^^M\ifinfo (for example). Chris@82: \fi Chris@82: \next #1% the token \_STOP_ is present just after this macro. Chris@82: } Chris@82: Chris@82: % We have to swallow the remaining "\_STOP_". Chris@82: % Chris@82: \def\doignoretextzzz#1{% Chris@82: \ifnum\doignorecount = 0 % We have just found the outermost @end. Chris@82: \let\next\enddoignore Chris@82: \else % Still inside a nested condition. Chris@82: \advance\doignorecount by -1 Chris@82: \let\next\doignoretext % Look for the next @end. Chris@82: \fi Chris@82: \next Chris@82: } Chris@82: Chris@82: % Finish off ignored text. Chris@82: { \obeylines% Chris@82: % Ignore anything after the last `@end #1'; this matters in verbatim Chris@82: % environments, where otherwise the newline after an ignored conditional Chris@82: % would result in a blank line in the output. Chris@82: \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% Chris@82: } Chris@82: Chris@82: Chris@82: % @set VAR sets the variable VAR to an empty value. Chris@82: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. Chris@82: % Chris@82: % Since we want to separate VAR from REST-OF-LINE (which might be Chris@82: % empty), we can't just use \parsearg; we have to insert a space of our Chris@82: % own to delimit the rest of the line, and then take it out again if we Chris@82: % didn't need it. Chris@82: % We rely on the fact that \parsearg sets \catcode`\ =10. Chris@82: % Chris@82: \parseargdef\set{\setyyy#1 \endsetyyy} Chris@82: \def\setyyy#1 #2\endsetyyy{% Chris@82: {% Chris@82: \makevalueexpandable Chris@82: \def\temp{#2}% Chris@82: \edef\next{\gdef\makecsname{SET#1}}% Chris@82: \ifx\temp\empty Chris@82: \next{}% Chris@82: \else Chris@82: \setzzz#2\endsetzzz Chris@82: \fi Chris@82: }% Chris@82: } Chris@82: % Remove the trailing space \setxxx inserted. Chris@82: \def\setzzz#1 \endsetzzz{\next{#1}} Chris@82: Chris@82: % @clear VAR clears (i.e., unsets) the variable VAR. Chris@82: % Chris@82: \parseargdef\clear{% Chris@82: {% Chris@82: \makevalueexpandable Chris@82: \global\expandafter\let\csname SET#1\endcsname=\relax Chris@82: }% Chris@82: } Chris@82: Chris@82: % @value{foo} gets the text saved in variable foo. Chris@82: \def\value{\begingroup\makevalueexpandable\valuexxx} Chris@82: \def\valuexxx#1{\expandablevalue{#1}\endgroup} Chris@82: { Chris@82: \catcode`\- = \active \catcode`\_ = \active Chris@82: % Chris@82: \gdef\makevalueexpandable{% Chris@82: \let\value = \expandablevalue Chris@82: % We don't want these characters active, ... Chris@82: \catcode`\-=\other \catcode`\_=\other Chris@82: % ..., but we might end up with active ones in the argument if Chris@82: % we're called from @code, as @code{@value{foo-bar_}}, though. Chris@82: % So \let them to their normal equivalents. Chris@82: \let-\normaldash \let_\normalunderscore Chris@82: } Chris@82: } Chris@82: Chris@82: % We have this subroutine so that we can handle at least some @value's Chris@82: % properly in indexes (we call \makevalueexpandable in \indexdummies). Chris@82: % The command has to be fully expandable (if the variable is set), since Chris@82: % the result winds up in the index file. This means that if the Chris@82: % variable's value contains other Texinfo commands, it's almost certain Chris@82: % it will fail (although perhaps we could fix that with sufficient work Chris@82: % to do a one-level expansion on the result, instead of complete). Chris@82: % Chris@82: \def\expandablevalue#1{% Chris@82: \expandafter\ifx\csname SET#1\endcsname\relax Chris@82: {[No value for ``#1'']}% Chris@82: \message{Variable `#1', used in @value, is not set.}% Chris@82: \else Chris@82: \csname SET#1\endcsname Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined Chris@82: % with @set. Chris@82: % Chris@82: % To get special treatment of `@end ifset,' call \makeond and the redefine. Chris@82: % Chris@82: \makecond{ifset} Chris@82: \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} Chris@82: \def\doifset#1#2{% Chris@82: {% Chris@82: \makevalueexpandable Chris@82: \let\next=\empty Chris@82: \expandafter\ifx\csname SET#2\endcsname\relax Chris@82: #1% If not set, redefine \next. Chris@82: \fi Chris@82: \expandafter Chris@82: }\next Chris@82: } Chris@82: \def\ifsetfail{\doignore{ifset}} Chris@82: Chris@82: % @ifclear VAR ... @end executes the `...' iff VAR has never been Chris@82: % defined with @set, or has been undefined with @clear. Chris@82: % Chris@82: % The `\else' inside the `\doifset' parameter is a trick to reuse the Chris@82: % above code: if the variable is not set, do nothing, if it is set, Chris@82: % then redefine \next to \ifclearfail. Chris@82: % Chris@82: \makecond{ifclear} Chris@82: \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} Chris@82: \def\ifclearfail{\doignore{ifclear}} Chris@82: Chris@82: % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written Chris@82: % without the @) is in fact defined. We can only feasibly check at the Chris@82: % TeX level, so something like `mathcode' is going to considered Chris@82: % defined even though it is not a Texinfo command. Chris@82: % Chris@82: \makecond{ifcommanddefined} Chris@82: \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} Chris@82: % Chris@82: \def\doifcmddefined#1#2{{% Chris@82: \makevalueexpandable Chris@82: \let\next=\empty Chris@82: \expandafter\ifx\csname #2\endcsname\relax Chris@82: #1% If not defined, \let\next as above. Chris@82: \fi Chris@82: \expandafter Chris@82: }\next Chris@82: } Chris@82: \def\ifcmddefinedfail{\doignore{ifcommanddefined}} Chris@82: Chris@82: % @ifcommandnotdefined CMD ... handled similar to @ifclear above. Chris@82: \makecond{ifcommandnotdefined} Chris@82: \def\ifcommandnotdefined{% Chris@82: \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} Chris@82: \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} Chris@82: Chris@82: % Set the `txicommandconditionals' variable, so documents have a way to Chris@82: % test if the @ifcommand...defined conditionals are available. Chris@82: \set txicommandconditionals Chris@82: Chris@82: % @dircategory CATEGORY -- specify a category of the dir file Chris@82: % which this file should belong to. Ignore this in TeX. Chris@82: \let\dircategory=\comment Chris@82: Chris@82: % @defininfoenclose. Chris@82: \let\definfoenclose=\comment Chris@82: Chris@82: Chris@82: \message{indexing,} Chris@82: % Index generation facilities Chris@82: Chris@82: % Define \newwrite to be identical to plain tex's \newwrite Chris@82: % except not \outer, so it can be used within macros and \if's. Chris@82: \edef\newwrite{\makecsname{ptexnewwrite}} Chris@82: Chris@82: % \newindex {foo} defines an index named foo. Chris@82: % It automatically defines \fooindex such that Chris@82: % \fooindex ...rest of line... puts an entry in the index foo. Chris@82: % It also defines \fooindfile to be the number of the output channel for Chris@82: % the file that accumulates this index. The file's extension is foo. Chris@82: % The name of an index should be no more than 2 characters long Chris@82: % for the sake of vms. Chris@82: % Chris@82: \def\newindex#1{% Chris@82: \iflinks Chris@82: \expandafter\newwrite \csname#1indfile\endcsname Chris@82: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file Chris@82: \fi Chris@82: \expandafter\xdef\csname#1index\endcsname{% % Define @#1index Chris@82: \noexpand\doindex{#1}} Chris@82: } Chris@82: Chris@82: % @defindex foo == \newindex{foo} Chris@82: % Chris@82: \def\defindex{\parsearg\newindex} Chris@82: Chris@82: % Define @defcodeindex, like @defindex except put all entries in @code. Chris@82: % Chris@82: \def\defcodeindex{\parsearg\newcodeindex} Chris@82: % Chris@82: \def\newcodeindex#1{% Chris@82: \iflinks Chris@82: \expandafter\newwrite \csname#1indfile\endcsname Chris@82: \openout \csname#1indfile\endcsname \jobname.#1 Chris@82: \fi Chris@82: \expandafter\xdef\csname#1index\endcsname{% Chris@82: \noexpand\docodeindex{#1}}% Chris@82: } Chris@82: Chris@82: Chris@82: % @synindex foo bar makes index foo feed into index bar. Chris@82: % Do this instead of @defindex foo if you don't want it as a separate index. Chris@82: % Chris@82: % @syncodeindex foo bar similar, but put all entries made for index foo Chris@82: % inside @code. Chris@82: % Chris@82: \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} Chris@82: \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} Chris@82: Chris@82: % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), Chris@82: % #3 the target index (bar). Chris@82: \def\dosynindex#1#2#3{% Chris@82: % Only do \closeout if we haven't already done it, else we'll end up Chris@82: % closing the target index. Chris@82: \expandafter \ifx\csname donesynindex#2\endcsname \relax Chris@82: % The \closeout helps reduce unnecessary open files; the limit on the Chris@82: % Acorn RISC OS is a mere 16 files. Chris@82: \expandafter\closeout\csname#2indfile\endcsname Chris@82: \expandafter\let\csname donesynindex#2\endcsname = 1 Chris@82: \fi Chris@82: % redefine \fooindfile: Chris@82: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname Chris@82: \expandafter\let\csname#2indfile\endcsname=\temp Chris@82: % redefine \fooindex: Chris@82: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% Chris@82: } Chris@82: Chris@82: % Define \doindex, the driver for all \fooindex macros. Chris@82: % Argument #1 is generated by the calling \fooindex macro, Chris@82: % and it is "foo", the name of the index. Chris@82: Chris@82: % \doindex just uses \parsearg; it calls \doind for the actual work. Chris@82: % This is because \doind is more useful to call from other macros. Chris@82: Chris@82: % There is also \dosubind {index}{topic}{subtopic} Chris@82: % which makes an entry in a two-level index such as the operation index. Chris@82: Chris@82: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} Chris@82: \def\singleindexer #1{\doind{\indexname}{#1}} Chris@82: Chris@82: % like the previous two, but they put @code around the argument. Chris@82: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} Chris@82: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} Chris@82: Chris@82: % Take care of Texinfo commands that can appear in an index entry. Chris@82: % Since there are some commands we want to expand, and others we don't, Chris@82: % we have to laboriously prevent expansion for those that we don't. Chris@82: % Chris@82: \def\indexdummies{% Chris@82: \escapechar = `\\ % use backslash in output files. Chris@82: \def\@{@}% change to @@ when we switch to @ as escape char in index files. Chris@82: \def\ {\realbackslash\space }% Chris@82: % Chris@82: % Need these unexpandable (because we define \tt as a dummy) Chris@82: % definitions when @{ or @} appear in index entry text. Also, more Chris@82: % complicated, when \tex is in effect and \{ is a \delimiter again. Chris@82: % We can't use \lbracecmd and \rbracecmd because texindex assumes Chris@82: % braces and backslashes are used only as delimiters. Perhaps we Chris@82: % should define @lbrace and @rbrace commands a la @comma. Chris@82: \def\{{{\tt\char123}}% Chris@82: \def\}{{\tt\char125}}% Chris@82: % Chris@82: % I don't entirely understand this, but when an index entry is Chris@82: % generated from a macro call, the \endinput which \scanmacro inserts Chris@82: % causes processing to be prematurely terminated. This is, Chris@82: % apparently, because \indexsorttmp is fully expanded, and \endinput Chris@82: % is an expandable command. The redefinition below makes \endinput Chris@82: % disappear altogether for that purpose -- although logging shows that Chris@82: % processing continues to some further point. On the other hand, it Chris@82: % seems \endinput does not hurt in the printed index arg, since that Chris@82: % is still getting written without apparent harm. Chris@82: % Chris@82: % Sample source (mac-idx3.tex, reported by Graham Percival to Chris@82: % help-texinfo, 22may06): Chris@82: % @macro funindex {WORD} Chris@82: % @findex xyz Chris@82: % @end macro Chris@82: % ... Chris@82: % @funindex commtest Chris@82: % Chris@82: % The above is not enough to reproduce the bug, but it gives the flavor. Chris@82: % Chris@82: % Sample whatsit resulting: Chris@82: % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} Chris@82: % Chris@82: % So: Chris@82: \let\endinput = \empty Chris@82: % Chris@82: % Do the redefinitions. Chris@82: \commondummies Chris@82: } Chris@82: Chris@82: % For the aux and toc files, @ is the escape character. So we want to Chris@82: % redefine everything using @ as the escape character (instead of Chris@82: % \realbackslash, still used for index files). When everything uses @, Chris@82: % this will be simpler. Chris@82: % Chris@82: \def\atdummies{% Chris@82: \def\@{@@}% Chris@82: \def\ {@ }% Chris@82: \let\{ = \lbraceatcmd Chris@82: \let\} = \rbraceatcmd Chris@82: % Chris@82: % Do the redefinitions. Chris@82: \commondummies Chris@82: \otherbackslash Chris@82: } Chris@82: Chris@82: % Called from \indexdummies and \atdummies. Chris@82: % Chris@82: \def\commondummies{% Chris@82: % Chris@82: % \definedummyword defines \#1 as \string\#1\space, thus effectively Chris@82: % preventing its expansion. This is used only for control words, Chris@82: % not control letters, because the \space would be incorrect for Chris@82: % control characters, but is needed to separate the control word Chris@82: % from whatever follows. Chris@82: % Chris@82: % For control letters, we have \definedummyletter, which omits the Chris@82: % space. Chris@82: % Chris@82: % These can be used both for control words that take an argument and Chris@82: % those that do not. If it is followed by {arg} in the input, then Chris@82: % that will dutifully get written to the index (or wherever). Chris@82: % Chris@82: \def\definedummyword ##1{\def##1{\string##1\space}}% Chris@82: \def\definedummyletter##1{\def##1{\string##1}}% Chris@82: \let\definedummyaccent\definedummyletter Chris@82: % Chris@82: \commondummiesnofonts Chris@82: % Chris@82: \definedummyletter\_% Chris@82: \definedummyletter\-% Chris@82: % Chris@82: % Non-English letters. Chris@82: \definedummyword\AA Chris@82: \definedummyword\AE Chris@82: \definedummyword\DH Chris@82: \definedummyword\L Chris@82: \definedummyword\O Chris@82: \definedummyword\OE Chris@82: \definedummyword\TH Chris@82: \definedummyword\aa Chris@82: \definedummyword\ae Chris@82: \definedummyword\dh Chris@82: \definedummyword\exclamdown Chris@82: \definedummyword\l Chris@82: \definedummyword\o Chris@82: \definedummyword\oe Chris@82: \definedummyword\ordf Chris@82: \definedummyword\ordm Chris@82: \definedummyword\questiondown Chris@82: \definedummyword\ss Chris@82: \definedummyword\th Chris@82: % Chris@82: % Although these internal commands shouldn't show up, sometimes they do. Chris@82: \definedummyword\bf Chris@82: \definedummyword\gtr Chris@82: \definedummyword\hat Chris@82: \definedummyword\less Chris@82: \definedummyword\sf Chris@82: \definedummyword\sl Chris@82: \definedummyword\tclose Chris@82: \definedummyword\tt Chris@82: % Chris@82: \definedummyword\LaTeX Chris@82: \definedummyword\TeX Chris@82: % Chris@82: % Assorted special characters. Chris@82: \definedummyword\arrow Chris@82: \definedummyword\bullet Chris@82: \definedummyword\comma Chris@82: \definedummyword\copyright Chris@82: \definedummyword\registeredsymbol Chris@82: \definedummyword\dots Chris@82: \definedummyword\enddots Chris@82: \definedummyword\entrybreak Chris@82: \definedummyword\equiv Chris@82: \definedummyword\error Chris@82: \definedummyword\euro Chris@82: \definedummyword\expansion Chris@82: \definedummyword\geq Chris@82: \definedummyword\guillemetleft Chris@82: \definedummyword\guillemetright Chris@82: \definedummyword\guilsinglleft Chris@82: \definedummyword\guilsinglright Chris@82: \definedummyword\lbracechar Chris@82: \definedummyword\leq Chris@82: \definedummyword\minus Chris@82: \definedummyword\ogonek Chris@82: \definedummyword\pounds Chris@82: \definedummyword\point Chris@82: \definedummyword\print Chris@82: \definedummyword\quotedblbase Chris@82: \definedummyword\quotedblleft Chris@82: \definedummyword\quotedblright Chris@82: \definedummyword\quoteleft Chris@82: \definedummyword\quoteright Chris@82: \definedummyword\quotesinglbase Chris@82: \definedummyword\rbracechar Chris@82: \definedummyword\result Chris@82: \definedummyword\textdegree Chris@82: % Chris@82: % We want to disable all macros so that they are not expanded by \write. Chris@82: \macrolist Chris@82: % Chris@82: \normalturnoffactive Chris@82: % Chris@82: % Handle some cases of @value -- where it does not contain any Chris@82: % (non-fully-expandable) commands. Chris@82: \makevalueexpandable Chris@82: } Chris@82: Chris@82: % \commondummiesnofonts: common to \commondummies and \indexnofonts. Chris@82: % Chris@82: \def\commondummiesnofonts{% Chris@82: % Control letters and accents. Chris@82: \definedummyletter\!% Chris@82: \definedummyaccent\"% Chris@82: \definedummyaccent\'% Chris@82: \definedummyletter\*% Chris@82: \definedummyaccent\,% Chris@82: \definedummyletter\.% Chris@82: \definedummyletter\/% Chris@82: \definedummyletter\:% Chris@82: \definedummyaccent\=% Chris@82: \definedummyletter\?% Chris@82: \definedummyaccent\^% Chris@82: \definedummyaccent\`% Chris@82: \definedummyaccent\~% Chris@82: \definedummyword\u Chris@82: \definedummyword\v Chris@82: \definedummyword\H Chris@82: \definedummyword\dotaccent Chris@82: \definedummyword\ogonek Chris@82: \definedummyword\ringaccent Chris@82: \definedummyword\tieaccent Chris@82: \definedummyword\ubaraccent Chris@82: \definedummyword\udotaccent Chris@82: \definedummyword\dotless Chris@82: % Chris@82: % Texinfo font commands. Chris@82: \definedummyword\b Chris@82: \definedummyword\i Chris@82: \definedummyword\r Chris@82: \definedummyword\sansserif Chris@82: \definedummyword\sc Chris@82: \definedummyword\slanted Chris@82: \definedummyword\t Chris@82: % Chris@82: % Commands that take arguments. Chris@82: \definedummyword\abbr Chris@82: \definedummyword\acronym Chris@82: \definedummyword\anchor Chris@82: \definedummyword\cite Chris@82: \definedummyword\code Chris@82: \definedummyword\command Chris@82: \definedummyword\dfn Chris@82: \definedummyword\dmn Chris@82: \definedummyword\email Chris@82: \definedummyword\emph Chris@82: \definedummyword\env Chris@82: \definedummyword\file Chris@82: \definedummyword\image Chris@82: \definedummyword\indicateurl Chris@82: \definedummyword\inforef Chris@82: \definedummyword\kbd Chris@82: \definedummyword\key Chris@82: \definedummyword\math Chris@82: \definedummyword\option Chris@82: \definedummyword\pxref Chris@82: \definedummyword\ref Chris@82: \definedummyword\samp Chris@82: \definedummyword\strong Chris@82: \definedummyword\tie Chris@82: \definedummyword\uref Chris@82: \definedummyword\url Chris@82: \definedummyword\var Chris@82: \definedummyword\verb Chris@82: \definedummyword\w Chris@82: \definedummyword\xref Chris@82: } Chris@82: Chris@82: % \indexnofonts is used when outputting the strings to sort the index Chris@82: % by, and when constructing control sequence names. It eliminates all Chris@82: % control sequences and just writes whatever the best ASCII sort string Chris@82: % would be for a given command (usually its argument). Chris@82: % Chris@82: \def\indexnofonts{% Chris@82: % Accent commands should become @asis. Chris@82: \def\definedummyaccent##1{\let##1\asis}% Chris@82: % We can just ignore other control letters. Chris@82: \def\definedummyletter##1{\let##1\empty}% Chris@82: % All control words become @asis by default; overrides below. Chris@82: \let\definedummyword\definedummyaccent Chris@82: % Chris@82: \commondummiesnofonts Chris@82: % Chris@82: % Don't no-op \tt, since it isn't a user-level command Chris@82: % and is used in the definitions of the active chars like <, >, |, etc. Chris@82: % Likewise with the other plain tex font commands. Chris@82: %\let\tt=\asis Chris@82: % Chris@82: \def\ { }% Chris@82: \def\@{@}% Chris@82: \def\_{\normalunderscore}% Chris@82: \def\-{}% @- shouldn't affect sorting Chris@82: % Chris@82: % Unfortunately, texindex is not prepared to handle braces in the Chris@82: % content at all. So for index sorting, we map @{ and @} to strings Chris@82: % starting with |, since that ASCII character is between ASCII { and }. Chris@82: \def\{{|a}% Chris@82: \def\lbracechar{|a}% Chris@82: % Chris@82: \def\}{|b}% Chris@82: \def\rbracechar{|b}% Chris@82: % Chris@82: % Non-English letters. Chris@82: \def\AA{AA}% Chris@82: \def\AE{AE}% Chris@82: \def\DH{DZZ}% Chris@82: \def\L{L}% Chris@82: \def\OE{OE}% Chris@82: \def\O{O}% Chris@82: \def\TH{ZZZ}% Chris@82: \def\aa{aa}% Chris@82: \def\ae{ae}% Chris@82: \def\dh{dzz}% Chris@82: \def\exclamdown{!}% Chris@82: \def\l{l}% Chris@82: \def\oe{oe}% Chris@82: \def\ordf{a}% Chris@82: \def\ordm{o}% Chris@82: \def\o{o}% Chris@82: \def\questiondown{?}% Chris@82: \def\ss{ss}% Chris@82: \def\th{zzz}% Chris@82: % Chris@82: \def\LaTeX{LaTeX}% Chris@82: \def\TeX{TeX}% Chris@82: % Chris@82: % Assorted special characters. Chris@82: % (The following {} will end up in the sort string, but that's ok.) Chris@82: \def\arrow{->}% Chris@82: \def\bullet{bullet}% Chris@82: \def\comma{,}% Chris@82: \def\copyright{copyright}% Chris@82: \def\dots{...}% Chris@82: \def\enddots{...}% Chris@82: \def\equiv{==}% Chris@82: \def\error{error}% Chris@82: \def\euro{euro}% Chris@82: \def\expansion{==>}% Chris@82: \def\geq{>=}% Chris@82: \def\guillemetleft{<<}% Chris@82: \def\guillemetright{>>}% Chris@82: \def\guilsinglleft{<}% Chris@82: \def\guilsinglright{>}% Chris@82: \def\leq{<=}% Chris@82: \def\minus{-}% Chris@82: \def\point{.}% Chris@82: \def\pounds{pounds}% Chris@82: \def\print{-|}% Chris@82: \def\quotedblbase{"}% Chris@82: \def\quotedblleft{"}% Chris@82: \def\quotedblright{"}% Chris@82: \def\quoteleft{`}% Chris@82: \def\quoteright{'}% Chris@82: \def\quotesinglbase{,}% Chris@82: \def\registeredsymbol{R}% Chris@82: \def\result{=>}% Chris@82: \def\textdegree{o}% Chris@82: % Chris@82: \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax Chris@82: \else \indexlquoteignore \fi Chris@82: % Chris@82: % We need to get rid of all macros, leaving only the arguments (if present). Chris@82: % Of course this is not nearly correct, but it is the best we can do for now. Chris@82: % makeinfo does not expand macros in the argument to @deffn, which ends up Chris@82: % writing an index entry, and texindex isn't prepared for an index sort entry Chris@82: % that starts with \. Chris@82: % Chris@82: % Since macro invocations are followed by braces, we can just redefine them Chris@82: % to take a single TeX argument. The case of a macro invocation that Chris@82: % goes to end-of-line is not handled. Chris@82: % Chris@82: \macrolist Chris@82: } Chris@82: Chris@82: % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us Chris@82: % ignore left quotes in the sort term. Chris@82: {\catcode`\`=\active Chris@82: \gdef\indexlquoteignore{\let`=\empty}} Chris@82: Chris@82: \let\indexbackslash=0 %overridden during \printindex. Chris@82: \let\SETmarginindex=\relax % put index entries in margin (undocumented)? Chris@82: Chris@82: % Most index entries go through here, but \dosubind is the general case. Chris@82: % #1 is the index name, #2 is the entry text. Chris@82: \def\doind#1#2{\dosubind{#1}{#2}{}} Chris@82: Chris@82: % Workhorse for all \fooindexes. Chris@82: % #1 is name of index, #2 is stuff to put there, #3 is subentry -- Chris@82: % empty if called from \doind, as we usually are (the main exception Chris@82: % is with most defuns, which call us directly). Chris@82: % Chris@82: \def\dosubind#1#2#3{% Chris@82: \iflinks Chris@82: {% Chris@82: % Store the main index entry text (including the third arg). Chris@82: \toks0 = {#2}% Chris@82: % If third arg is present, precede it with a space. Chris@82: \def\thirdarg{#3}% Chris@82: \ifx\thirdarg\empty \else Chris@82: \toks0 = \expandafter{\the\toks0 \space #3}% Chris@82: \fi Chris@82: % Chris@82: \edef\writeto{\csname#1indfile\endcsname}% Chris@82: % Chris@82: \safewhatsit\dosubindwrite Chris@82: }% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Write the entry in \toks0 to the index file: Chris@82: % Chris@82: \def\dosubindwrite{% Chris@82: % Put the index entry in the margin if desired. Chris@82: \ifx\SETmarginindex\relax\else Chris@82: \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% Chris@82: \fi Chris@82: % Chris@82: % Remember, we are within a group. Chris@82: \indexdummies % Must do this here, since \bf, etc expand at this stage Chris@82: \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now Chris@82: % so it will be output as is; and it will print as backslash. Chris@82: % Chris@82: % Process the index entry with all font commands turned off, to Chris@82: % get the string to sort by. Chris@82: {\indexnofonts Chris@82: \edef\temp{\the\toks0}% need full expansion Chris@82: \xdef\indexsorttmp{\temp}% Chris@82: }% Chris@82: % Chris@82: % Set up the complete index entry, with both the sort key and Chris@82: % the original text, including any font commands. We write Chris@82: % three arguments to \entry to the .?? file (four in the Chris@82: % subentry case), texindex reduces to two when writing the .??s Chris@82: % sorted result. Chris@82: \edef\temp{% Chris@82: \write\writeto{% Chris@82: \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% Chris@82: }% Chris@82: \temp Chris@82: } Chris@82: Chris@82: % Take care of unwanted page breaks/skips around a whatsit: Chris@82: % Chris@82: % If a skip is the last thing on the list now, preserve it Chris@82: % by backing up by \lastskip, doing the \write, then inserting Chris@82: % the skip again. Otherwise, the whatsit generated by the Chris@82: % \write or \pdfdest will make \lastskip zero. The result is that Chris@82: % sequences like this: Chris@82: % @end defun Chris@82: % @tindex whatever Chris@82: % @defun ... Chris@82: % will have extra space inserted, because the \medbreak in the Chris@82: % start of the @defun won't see the skip inserted by the @end of Chris@82: % the previous defun. Chris@82: % Chris@82: % But don't do any of this if we're not in vertical mode. We Chris@82: % don't want to do a \vskip and prematurely end a paragraph. Chris@82: % Chris@82: % Avoid page breaks due to these extra skips, too. Chris@82: % Chris@82: % But wait, there is a catch there: Chris@82: % We'll have to check whether \lastskip is zero skip. \ifdim is not Chris@82: % sufficient for this purpose, as it ignores stretch and shrink parts Chris@82: % of the skip. The only way seems to be to check the textual Chris@82: % representation of the skip. Chris@82: % Chris@82: % The following is almost like \def\zeroskipmacro{0.0pt} except that Chris@82: % the ``p'' and ``t'' characters have catcode \other, not 11 (letter). Chris@82: % Chris@82: \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} Chris@82: % Chris@82: \newskip\whatsitskip Chris@82: \newcount\whatsitpenalty Chris@82: % Chris@82: % ..., ready, GO: Chris@82: % Chris@82: \def\safewhatsit#1{\ifhmode Chris@82: #1% Chris@82: \else Chris@82: % \lastskip and \lastpenalty cannot both be nonzero simultaneously. Chris@82: \whatsitskip = \lastskip Chris@82: \edef\lastskipmacro{\the\lastskip}% Chris@82: \whatsitpenalty = \lastpenalty Chris@82: % Chris@82: % If \lastskip is nonzero, that means the last item was a Chris@82: % skip. And since a skip is discardable, that means this Chris@82: % -\whatsitskip glue we're inserting is preceded by a Chris@82: % non-discardable item, therefore it is not a potential Chris@82: % breakpoint, therefore no \nobreak needed. Chris@82: \ifx\lastskipmacro\zeroskipmacro Chris@82: \else Chris@82: \vskip-\whatsitskip Chris@82: \fi Chris@82: % Chris@82: #1% Chris@82: % Chris@82: \ifx\lastskipmacro\zeroskipmacro Chris@82: % If \lastskip was zero, perhaps the last item was a penalty, and Chris@82: % perhaps it was >=10000, e.g., a \nobreak. In that case, we want Chris@82: % to re-insert the same penalty (values >10000 are used for various Chris@82: % signals); since we just inserted a non-discardable item, any Chris@82: % following glue (such as a \parskip) would be a breakpoint. For example: Chris@82: % @deffn deffn-whatever Chris@82: % @vindex index-whatever Chris@82: % Description. Chris@82: % would allow a break between the index-whatever whatsit Chris@82: % and the "Description." paragraph. Chris@82: \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi Chris@82: \else Chris@82: % On the other hand, if we had a nonzero \lastskip, Chris@82: % this make-up glue would be preceded by a non-discardable item Chris@82: % (the whatsit from the \write), so we must insert a \nobreak. Chris@82: \nobreak\vskip\whatsitskip Chris@82: \fi Chris@82: \fi} Chris@82: Chris@82: % The index entry written in the file actually looks like Chris@82: % \entry {sortstring}{page}{topic} Chris@82: % or Chris@82: % \entry {sortstring}{page}{topic}{subtopic} Chris@82: % The texindex program reads in these files and writes files Chris@82: % containing these kinds of lines: Chris@82: % \initial {c} Chris@82: % before the first topic whose initial is c Chris@82: % \entry {topic}{pagelist} Chris@82: % for a topic that is used without subtopics Chris@82: % \primary {topic} Chris@82: % for the beginning of a topic that is used with subtopics Chris@82: % \secondary {subtopic}{pagelist} Chris@82: % for each subtopic. Chris@82: Chris@82: % Define the user-accessible indexing commands Chris@82: % @findex, @vindex, @kindex, @cindex. Chris@82: Chris@82: \def\findex {\fnindex} Chris@82: \def\kindex {\kyindex} Chris@82: \def\cindex {\cpindex} Chris@82: \def\vindex {\vrindex} Chris@82: \def\tindex {\tpindex} Chris@82: \def\pindex {\pgindex} Chris@82: Chris@82: \def\cindexsub {\begingroup\obeylines\cindexsub} Chris@82: {\obeylines % Chris@82: \gdef\cindexsub "#1" #2^^M{\endgroup % Chris@82: \dosubind{cp}{#2}{#1}}} Chris@82: Chris@82: % Define the macros used in formatting output of the sorted index material. Chris@82: Chris@82: % @printindex causes a particular index (the ??s file) to get printed. Chris@82: % It does not print any chapter heading (usually an @unnumbered). Chris@82: % Chris@82: \parseargdef\printindex{\begingroup Chris@82: \dobreak \chapheadingskip{10000}% Chris@82: % Chris@82: \smallfonts \rm Chris@82: \tolerance = 9500 Chris@82: \plainfrenchspacing Chris@82: \everypar = {}% don't want the \kern\-parindent from indentation suppression. Chris@82: % Chris@82: % See if the index file exists and is nonempty. Chris@82: % Change catcode of @ here so that if the index file contains Chris@82: % \initial {@} Chris@82: % as its first line, TeX doesn't complain about mismatched braces Chris@82: % (because it thinks @} is a control sequence). Chris@82: \catcode`\@ = 11 Chris@82: \openin 1 \jobname.#1s Chris@82: \ifeof 1 Chris@82: % \enddoublecolumns gets confused if there is no text in the index, Chris@82: % and it loses the chapter title and the aux file entries for the Chris@82: % index. The easiest way to prevent this problem is to make sure Chris@82: % there is some text. Chris@82: \putwordIndexNonexistent Chris@82: \else Chris@82: % Chris@82: % If the index file exists but is empty, then \openin leaves \ifeof Chris@82: % false. We have to make TeX try to read something from the file, so Chris@82: % it can discover if there is anything in it. Chris@82: \read 1 to \temp Chris@82: \ifeof 1 Chris@82: \putwordIndexIsEmpty Chris@82: \else Chris@82: % Index files are almost Texinfo source, but we use \ as the escape Chris@82: % character. It would be better to use @, but that's too big a change Chris@82: % to make right now. Chris@82: \def\indexbackslash{\backslashcurfont}% Chris@82: \catcode`\\ = 0 Chris@82: \escapechar = `\\ Chris@82: \begindoublecolumns Chris@82: \input \jobname.#1s Chris@82: \enddoublecolumns Chris@82: \fi Chris@82: \fi Chris@82: \closein 1 Chris@82: \endgroup} Chris@82: Chris@82: % These macros are used by the sorted index file itself. Chris@82: % Change them to control the appearance of the index. Chris@82: Chris@82: \def\initial#1{{% Chris@82: % Some minor font changes for the special characters. Chris@82: \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt Chris@82: % Chris@82: % Remove any glue we may have, we'll be inserting our own. Chris@82: \removelastskip Chris@82: % Chris@82: % We like breaks before the index initials, so insert a bonus. Chris@82: \nobreak Chris@82: \vskip 0pt plus 3\baselineskip Chris@82: \penalty 0 Chris@82: \vskip 0pt plus -3\baselineskip Chris@82: % Chris@82: % Typeset the initial. Making this add up to a whole number of Chris@82: % baselineskips increases the chance of the dots lining up from column Chris@82: % to column. It still won't often be perfect, because of the stretch Chris@82: % we need before each entry, but it's better. Chris@82: % Chris@82: % No shrink because it confuses \balancecolumns. Chris@82: \vskip 1.67\baselineskip plus .5\baselineskip Chris@82: \leftline{\secbf #1}% Chris@82: % Do our best not to break after the initial. Chris@82: \nobreak Chris@82: \vskip .33\baselineskip plus .1\baselineskip Chris@82: }} Chris@82: Chris@82: % \entry typesets a paragraph consisting of the text (#1), dot leaders, and Chris@82: % then page number (#2) flushed to the right margin. It is used for index Chris@82: % and table of contents entries. The paragraph is indented by \leftskip. Chris@82: % Chris@82: % A straightforward implementation would start like this: Chris@82: % \def\entry#1#2{... Chris@82: % But this freezes the catcodes in the argument, and can cause problems to Chris@82: % @code, which sets - active. This problem was fixed by a kludge--- Chris@82: % ``-'' was active throughout whole index, but this isn't really right. Chris@82: % The right solution is to prevent \entry from swallowing the whole text. Chris@82: % --kasal, 21nov03 Chris@82: \def\entry{% Chris@82: \begingroup Chris@82: % Chris@82: % Start a new paragraph if necessary, so our assignments below can't Chris@82: % affect previous text. Chris@82: \par Chris@82: % Chris@82: % Do not fill out the last line with white space. Chris@82: \parfillskip = 0in Chris@82: % Chris@82: % No extra space above this paragraph. Chris@82: \parskip = 0in Chris@82: % Chris@82: % Do not prefer a separate line ending with a hyphen to fewer lines. Chris@82: \finalhyphendemerits = 0 Chris@82: % Chris@82: % \hangindent is only relevant when the entry text and page number Chris@82: % don't both fit on one line. In that case, bob suggests starting the Chris@82: % dots pretty far over on the line. Unfortunately, a large Chris@82: % indentation looks wrong when the entry text itself is broken across Chris@82: % lines. So we use a small indentation and put up with long leaders. Chris@82: % Chris@82: % \hangafter is reset to 1 (which is the value we want) at the start Chris@82: % of each paragraph, so we need not do anything with that. Chris@82: \hangindent = 2em Chris@82: % Chris@82: % When the entry text needs to be broken, just fill out the first line Chris@82: % with blank space. Chris@82: \rightskip = 0pt plus1fil Chris@82: % Chris@82: % A bit of stretch before each entry for the benefit of balancing Chris@82: % columns. Chris@82: \vskip 0pt plus1pt Chris@82: % Chris@82: % When reading the text of entry, convert explicit line breaks Chris@82: % from @* into spaces. The user might give these in long section Chris@82: % titles, for instance. Chris@82: \def\*{\unskip\space\ignorespaces}% Chris@82: \def\entrybreak{\hfil\break}% Chris@82: % Chris@82: % Swallow the left brace of the text (first parameter): Chris@82: \afterassignment\doentry Chris@82: \let\temp = Chris@82: } Chris@82: \def\entrybreak{\unskip\space\ignorespaces}% Chris@82: \def\doentry{% Chris@82: \bgroup % Instead of the swallowed brace. Chris@82: \noindent Chris@82: \aftergroup\finishentry Chris@82: % And now comes the text of the entry. Chris@82: } Chris@82: \def\finishentry#1{% Chris@82: % #1 is the page number. Chris@82: % Chris@82: % The following is kludged to not output a line of dots in the index if Chris@82: % there are no page numbers. The next person who breaks this will be Chris@82: % cursed by a Unix daemon. Chris@82: \setbox\boxA = \hbox{#1}% Chris@82: \ifdim\wd\boxA = 0pt Chris@82: \ % Chris@82: \else Chris@82: % Chris@82: % If we must, put the page number on a line of its own, and fill out Chris@82: % this line with blank space. (The \hfil is overwhelmed with the Chris@82: % fill leaders glue in \indexdotfill if the page number does fit.) Chris@82: \hfil\penalty50 Chris@82: \null\nobreak\indexdotfill % Have leaders before the page number. Chris@82: % Chris@82: % The `\ ' here is removed by the implicit \unskip that TeX does as Chris@82: % part of (the primitive) \par. Without it, a spurious underfull Chris@82: % \hbox ensues. Chris@82: \ifpdf Chris@82: \pdfgettoks#1.% Chris@82: \ \the\toksA Chris@82: \else Chris@82: \ #1% Chris@82: \fi Chris@82: \fi Chris@82: \par Chris@82: \endgroup Chris@82: } Chris@82: Chris@82: % Like plain.tex's \dotfill, except uses up at least 1 em. Chris@82: \def\indexdotfill{\cleaders Chris@82: \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} Chris@82: Chris@82: \def\primary #1{\line{#1\hfil}} Chris@82: Chris@82: \newskip\secondaryindent \secondaryindent=0.5cm Chris@82: \def\secondary#1#2{{% Chris@82: \parfillskip=0in Chris@82: \parskip=0in Chris@82: \hangindent=1in Chris@82: \hangafter=1 Chris@82: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill Chris@82: \ifpdf Chris@82: \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. Chris@82: \else Chris@82: #2 Chris@82: \fi Chris@82: \par Chris@82: }} Chris@82: Chris@82: % Define two-column mode, which we use to typeset indexes. Chris@82: % Adapted from the TeXbook, page 416, which is to say, Chris@82: % the manmac.tex format used to print the TeXbook itself. Chris@82: \catcode`\@=11 Chris@82: Chris@82: \newbox\partialpage Chris@82: \newdimen\doublecolumnhsize Chris@82: Chris@82: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns Chris@82: % Grab any single-column material above us. Chris@82: \output = {% Chris@82: % Chris@82: % Here is a possibility not foreseen in manmac: if we accumulate a Chris@82: % whole lot of material, we might end up calling this \output Chris@82: % routine twice in a row (see the doublecol-lose test, which is Chris@82: % essentially a couple of indexes with @setchapternewpage off). In Chris@82: % that case we just ship out what is in \partialpage with the normal Chris@82: % output routine. Generally, \partialpage will be empty when this Chris@82: % runs and this will be a no-op. See the indexspread.tex test case. Chris@82: \ifvoid\partialpage \else Chris@82: \onepageout{\pagecontents\partialpage}% Chris@82: \fi Chris@82: % Chris@82: \global\setbox\partialpage = \vbox{% Chris@82: % Unvbox the main output page. Chris@82: \unvbox\PAGE Chris@82: \kern-\topskip \kern\baselineskip Chris@82: }% Chris@82: }% Chris@82: \eject % run that output routine to set \partialpage Chris@82: % Chris@82: % Use the double-column output routine for subsequent pages. Chris@82: \output = {\doublecolumnout}% Chris@82: % Chris@82: % Change the page size parameters. We could do this once outside this Chris@82: % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 Chris@82: % format, but then we repeat the same computation. Repeating a couple Chris@82: % of assignments once per index is clearly meaningless for the Chris@82: % execution time, so we may as well do it in one place. Chris@82: % Chris@82: % First we halve the line length, less a little for the gutter between Chris@82: % the columns. We compute the gutter based on the line length, so it Chris@82: % changes automatically with the paper format. The magic constant Chris@82: % below is chosen so that the gutter has the same value (well, +-<1pt) Chris@82: % as it did when we hard-coded it. Chris@82: % Chris@82: % We put the result in a separate register, \doublecolumhsize, so we Chris@82: % can restore it in \pagesofar, after \hsize itself has (potentially) Chris@82: % been clobbered. Chris@82: % Chris@82: \doublecolumnhsize = \hsize Chris@82: \advance\doublecolumnhsize by -.04154\hsize Chris@82: \divide\doublecolumnhsize by 2 Chris@82: \hsize = \doublecolumnhsize Chris@82: % Chris@82: % Double the \vsize as well. (We don't need a separate register here, Chris@82: % since nobody clobbers \vsize.) Chris@82: \vsize = 2\vsize Chris@82: } Chris@82: Chris@82: % The double-column output routine for all double-column pages except Chris@82: % the last. Chris@82: % Chris@82: \def\doublecolumnout{% Chris@82: \splittopskip=\topskip \splitmaxdepth=\maxdepth Chris@82: % Get the available space for the double columns -- the normal Chris@82: % (undoubled) page height minus any material left over from the Chris@82: % previous page. Chris@82: \dimen@ = \vsize Chris@82: \divide\dimen@ by 2 Chris@82: \advance\dimen@ by -\ht\partialpage Chris@82: % Chris@82: % box0 will be the left-hand column, box2 the right. Chris@82: \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ Chris@82: \onepageout\pagesofar Chris@82: \unvbox255 Chris@82: \penalty\outputpenalty Chris@82: } Chris@82: % Chris@82: % Re-output the contents of the output page -- any previous material, Chris@82: % followed by the two boxes we just split, in box0 and box2. Chris@82: \def\pagesofar{% Chris@82: \unvbox\partialpage Chris@82: % Chris@82: \hsize = \doublecolumnhsize Chris@82: \wd0=\hsize \wd2=\hsize Chris@82: \hbox to\pagewidth{\box0\hfil\box2}% Chris@82: } Chris@82: % Chris@82: % All done with double columns. Chris@82: \def\enddoublecolumns{% Chris@82: % The following penalty ensures that the page builder is exercised Chris@82: % _before_ we change the output routine. This is necessary in the Chris@82: % following situation: Chris@82: % Chris@82: % The last section of the index consists only of a single entry. Chris@82: % Before this section, \pagetotal is less than \pagegoal, so no Chris@82: % break occurs before the last section starts. However, the last Chris@82: % section, consisting of \initial and the single \entry, does not Chris@82: % fit on the page and has to be broken off. Without the following Chris@82: % penalty the page builder will not be exercised until \eject Chris@82: % below, and by that time we'll already have changed the output Chris@82: % routine to the \balancecolumns version, so the next-to-last Chris@82: % double-column page will be processed with \balancecolumns, which Chris@82: % is wrong: The two columns will go to the main vertical list, with Chris@82: % the broken-off section in the recent contributions. As soon as Chris@82: % the output routine finishes, TeX starts reconsidering the page Chris@82: % break. The two columns and the broken-off section both fit on the Chris@82: % page, because the two columns now take up only half of the page Chris@82: % goal. When TeX sees \eject from below which follows the final Chris@82: % section, it invokes the new output routine that we've set after Chris@82: % \balancecolumns below; \onepageout will try to fit the two columns Chris@82: % and the final section into the vbox of \pageheight (see Chris@82: % \pagebody), causing an overfull box. Chris@82: % Chris@82: % Note that glue won't work here, because glue does not exercise the Chris@82: % page builder, unlike penalties (see The TeXbook, pp. 280-281). Chris@82: \penalty0 Chris@82: % Chris@82: \output = {% Chris@82: % Split the last of the double-column material. Leave it on the Chris@82: % current page, no automatic page break. Chris@82: \balancecolumns Chris@82: % Chris@82: % If we end up splitting too much material for the current page, Chris@82: % though, there will be another page break right after this \output Chris@82: % invocation ends. Having called \balancecolumns once, we do not Chris@82: % want to call it again. Therefore, reset \output to its normal Chris@82: % definition right away. (We hope \balancecolumns will never be Chris@82: % called on to balance too much material, but if it is, this makes Chris@82: % the output somewhat more palatable.) Chris@82: \global\output = {\onepageout{\pagecontents\PAGE}}% Chris@82: }% Chris@82: \eject Chris@82: \endgroup % started in \begindoublecolumns Chris@82: % Chris@82: % \pagegoal was set to the doubled \vsize above, since we restarted Chris@82: % the current page. We're now back to normal single-column Chris@82: % typesetting, so reset \pagegoal to the normal \vsize (after the Chris@82: % \endgroup where \vsize got restored). Chris@82: \pagegoal = \vsize Chris@82: } Chris@82: % Chris@82: % Called at the end of the double column material. Chris@82: \def\balancecolumns{% Chris@82: \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. Chris@82: \dimen@ = \ht0 Chris@82: \advance\dimen@ by \topskip Chris@82: \advance\dimen@ by-\baselineskip Chris@82: \divide\dimen@ by 2 % target to split to Chris@82: %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% Chris@82: \splittopskip = \topskip Chris@82: % Loop until we get a decent breakpoint. Chris@82: {% Chris@82: \vbadness = 10000 Chris@82: \loop Chris@82: \global\setbox3 = \copy0 Chris@82: \global\setbox1 = \vsplit3 to \dimen@ Chris@82: \ifdim\ht3>\dimen@ Chris@82: \global\advance\dimen@ by 1pt Chris@82: \repeat Chris@82: }% Chris@82: %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% Chris@82: \setbox0=\vbox to\dimen@{\unvbox1}% Chris@82: \setbox2=\vbox to\dimen@{\unvbox3}% Chris@82: % Chris@82: \pagesofar Chris@82: } Chris@82: \catcode`\@ = \other Chris@82: Chris@82: Chris@82: \message{sectioning,} Chris@82: % Chapters, sections, etc. Chris@82: Chris@82: % Let's start with @part. Chris@82: \outer\parseargdef\part{\partzzz{#1}} Chris@82: \def\partzzz#1{% Chris@82: \chapoddpage Chris@82: \null Chris@82: \vskip.3\vsize % move it down on the page a bit Chris@82: \begingroup Chris@82: \noindent \titlefonts\rmisbold #1\par % the text Chris@82: \let\lastnode=\empty % no node to associate with Chris@82: \writetocentry{part}{#1}{}% but put it in the toc Chris@82: \headingsoff % no headline or footline on the part page Chris@82: \chapoddpage Chris@82: \endgroup Chris@82: } Chris@82: Chris@82: % \unnumberedno is an oxymoron. But we count the unnumbered Chris@82: % sections so that we can refer to them unambiguously in the pdf Chris@82: % outlines by their "section number". We avoid collisions with chapter Chris@82: % numbers by starting them at 10000. (If a document ever has 10000 Chris@82: % chapters, we're in trouble anyway, I'm sure.) Chris@82: \newcount\unnumberedno \unnumberedno = 10000 Chris@82: \newcount\chapno Chris@82: \newcount\secno \secno=0 Chris@82: \newcount\subsecno \subsecno=0 Chris@82: \newcount\subsubsecno \subsubsecno=0 Chris@82: Chris@82: % This counter is funny since it counts through charcodes of letters A, B, ... Chris@82: \newcount\appendixno \appendixno = `\@ Chris@82: % Chris@82: % \def\appendixletter{\char\the\appendixno} Chris@82: % We do the following ugly conditional instead of the above simple Chris@82: % construct for the sake of pdftex, which needs the actual Chris@82: % letter in the expansion, not just typeset. Chris@82: % Chris@82: \def\appendixletter{% Chris@82: \ifnum\appendixno=`A A% Chris@82: \else\ifnum\appendixno=`B B% Chris@82: \else\ifnum\appendixno=`C C% Chris@82: \else\ifnum\appendixno=`D D% Chris@82: \else\ifnum\appendixno=`E E% Chris@82: \else\ifnum\appendixno=`F F% Chris@82: \else\ifnum\appendixno=`G G% Chris@82: \else\ifnum\appendixno=`H H% Chris@82: \else\ifnum\appendixno=`I I% Chris@82: \else\ifnum\appendixno=`J J% Chris@82: \else\ifnum\appendixno=`K K% Chris@82: \else\ifnum\appendixno=`L L% Chris@82: \else\ifnum\appendixno=`M M% Chris@82: \else\ifnum\appendixno=`N N% Chris@82: \else\ifnum\appendixno=`O O% Chris@82: \else\ifnum\appendixno=`P P% Chris@82: \else\ifnum\appendixno=`Q Q% Chris@82: \else\ifnum\appendixno=`R R% Chris@82: \else\ifnum\appendixno=`S S% Chris@82: \else\ifnum\appendixno=`T T% Chris@82: \else\ifnum\appendixno=`U U% Chris@82: \else\ifnum\appendixno=`V V% Chris@82: \else\ifnum\appendixno=`W W% Chris@82: \else\ifnum\appendixno=`X X% Chris@82: \else\ifnum\appendixno=`Y Y% Chris@82: \else\ifnum\appendixno=`Z Z% Chris@82: % The \the is necessary, despite appearances, because \appendixletter is Chris@82: % expanded while writing the .toc file. \char\appendixno is not Chris@82: % expandable, thus it is written literally, thus all appendixes come out Chris@82: % with the same letter (or @) in the toc without it. Chris@82: \else\char\the\appendixno Chris@82: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi Chris@82: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} Chris@82: Chris@82: % Each @chapter defines these (using marks) as the number+name, number Chris@82: % and name of the chapter. Page headings and footings can use Chris@82: % these. @section does likewise. Chris@82: \def\thischapter{} Chris@82: \def\thischapternum{} Chris@82: \def\thischaptername{} Chris@82: \def\thissection{} Chris@82: \def\thissectionnum{} Chris@82: \def\thissectionname{} Chris@82: Chris@82: \newcount\absseclevel % used to calculate proper heading level Chris@82: \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count Chris@82: Chris@82: % @raisesections: treat @section as chapter, @subsection as section, etc. Chris@82: \def\raisesections{\global\advance\secbase by -1} Chris@82: \let\up=\raisesections % original BFox name Chris@82: Chris@82: % @lowersections: treat @chapter as section, @section as subsection, etc. Chris@82: \def\lowersections{\global\advance\secbase by 1} Chris@82: \let\down=\lowersections % original BFox name Chris@82: Chris@82: % we only have subsub. Chris@82: \chardef\maxseclevel = 3 Chris@82: % Chris@82: % A numbered section within an unnumbered changes to unnumbered too. Chris@82: % To achieve this, remember the "biggest" unnum. sec. we are currently in: Chris@82: \chardef\unnlevel = \maxseclevel Chris@82: % Chris@82: % Trace whether the current chapter is an appendix or not: Chris@82: % \chapheadtype is "N" or "A", unnumbered chapters are ignored. Chris@82: \def\chapheadtype{N} Chris@82: Chris@82: % Choose a heading macro Chris@82: % #1 is heading type Chris@82: % #2 is heading level Chris@82: % #3 is text for heading Chris@82: \def\genhead#1#2#3{% Chris@82: % Compute the abs. sec. level: Chris@82: \absseclevel=#2 Chris@82: \advance\absseclevel by \secbase Chris@82: % Make sure \absseclevel doesn't fall outside the range: Chris@82: \ifnum \absseclevel < 0 Chris@82: \absseclevel = 0 Chris@82: \else Chris@82: \ifnum \absseclevel > 3 Chris@82: \absseclevel = 3 Chris@82: \fi Chris@82: \fi Chris@82: % The heading type: Chris@82: \def\headtype{#1}% Chris@82: \if \headtype U% Chris@82: \ifnum \absseclevel < \unnlevel Chris@82: \chardef\unnlevel = \absseclevel Chris@82: \fi Chris@82: \else Chris@82: % Check for appendix sections: Chris@82: \ifnum \absseclevel = 0 Chris@82: \edef\chapheadtype{\headtype}% Chris@82: \else Chris@82: \if \headtype A\if \chapheadtype N% Chris@82: \errmessage{@appendix... within a non-appendix chapter}% Chris@82: \fi\fi Chris@82: \fi Chris@82: % Check for numbered within unnumbered: Chris@82: \ifnum \absseclevel > \unnlevel Chris@82: \def\headtype{U}% Chris@82: \else Chris@82: \chardef\unnlevel = 3 Chris@82: \fi Chris@82: \fi Chris@82: % Now print the heading: Chris@82: \if \headtype U% Chris@82: \ifcase\absseclevel Chris@82: \unnumberedzzz{#3}% Chris@82: \or \unnumberedseczzz{#3}% Chris@82: \or \unnumberedsubseczzz{#3}% Chris@82: \or \unnumberedsubsubseczzz{#3}% Chris@82: \fi Chris@82: \else Chris@82: \if \headtype A% Chris@82: \ifcase\absseclevel Chris@82: \appendixzzz{#3}% Chris@82: \or \appendixsectionzzz{#3}% Chris@82: \or \appendixsubseczzz{#3}% Chris@82: \or \appendixsubsubseczzz{#3}% Chris@82: \fi Chris@82: \else Chris@82: \ifcase\absseclevel Chris@82: \chapterzzz{#3}% Chris@82: \or \seczzz{#3}% Chris@82: \or \numberedsubseczzz{#3}% Chris@82: \or \numberedsubsubseczzz{#3}% Chris@82: \fi Chris@82: \fi Chris@82: \fi Chris@82: \suppressfirstparagraphindent Chris@82: } Chris@82: Chris@82: % an interface: Chris@82: \def\numhead{\genhead N} Chris@82: \def\apphead{\genhead A} Chris@82: \def\unnmhead{\genhead U} Chris@82: Chris@82: % @chapter, @appendix, @unnumbered. Increment top-level counter, reset Chris@82: % all lower-level sectioning counters to zero. Chris@82: % Chris@82: % Also set \chaplevelprefix, which we prepend to @float sequence numbers Chris@82: % (e.g., figures), q.v. By default (before any chapter), that is empty. Chris@82: \let\chaplevelprefix = \empty Chris@82: % Chris@82: \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz Chris@82: \def\chapterzzz#1{% Chris@82: % section resetting is \global in case the chapter is in a group, such Chris@82: % as an @include file. Chris@82: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 Chris@82: \global\advance\chapno by 1 Chris@82: % Chris@82: % Used for \float. Chris@82: \gdef\chaplevelprefix{\the\chapno.}% Chris@82: \resetallfloatnos Chris@82: % Chris@82: % \putwordChapter can contain complex things in translations. Chris@82: \toks0=\expandafter{\putwordChapter}% Chris@82: \message{\the\toks0 \space \the\chapno}% Chris@82: % Chris@82: % Write the actual heading. Chris@82: \chapmacro{#1}{Ynumbered}{\the\chapno}% Chris@82: % Chris@82: % So @section and the like are numbered underneath this chapter. Chris@82: \global\let\section = \numberedsec Chris@82: \global\let\subsection = \numberedsubsec Chris@82: \global\let\subsubsection = \numberedsubsubsec Chris@82: } Chris@82: Chris@82: \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz Chris@82: % Chris@82: \def\appendixzzz#1{% Chris@82: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 Chris@82: \global\advance\appendixno by 1 Chris@82: \gdef\chaplevelprefix{\appendixletter.}% Chris@82: \resetallfloatnos Chris@82: % Chris@82: % \putwordAppendix can contain complex things in translations. Chris@82: \toks0=\expandafter{\putwordAppendix}% Chris@82: \message{\the\toks0 \space \appendixletter}% Chris@82: % Chris@82: \chapmacro{#1}{Yappendix}{\appendixletter}% Chris@82: % Chris@82: \global\let\section = \appendixsec Chris@82: \global\let\subsection = \appendixsubsec Chris@82: \global\let\subsubsection = \appendixsubsubsec Chris@82: } Chris@82: Chris@82: % normally unnmhead0 calls unnumberedzzz: Chris@82: \outer\parseargdef\unnumbered{\unnmhead0{#1}} Chris@82: \def\unnumberedzzz#1{% Chris@82: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 Chris@82: \global\advance\unnumberedno by 1 Chris@82: % Chris@82: % Since an unnumbered has no number, no prefix for figures. Chris@82: \global\let\chaplevelprefix = \empty Chris@82: \resetallfloatnos Chris@82: % Chris@82: % This used to be simply \message{#1}, but TeX fully expands the Chris@82: % argument to \message. Therefore, if #1 contained @-commands, TeX Chris@82: % expanded them. For example, in `@unnumbered The @cite{Book}', TeX Chris@82: % expanded @cite (which turns out to cause errors because \cite is meant Chris@82: % to be executed, not expanded). Chris@82: % Chris@82: % Anyway, we don't want the fully-expanded definition of @cite to appear Chris@82: % as a result of the \message, we just want `@cite' itself. We use Chris@82: % \the to achieve this: TeX expands \the only once, Chris@82: % simply yielding the contents of . (We also do this for Chris@82: % the toc entries.) Chris@82: \toks0 = {#1}% Chris@82: \message{(\the\toks0)}% Chris@82: % Chris@82: \chapmacro{#1}{Ynothing}{\the\unnumberedno}% Chris@82: % Chris@82: \global\let\section = \unnumberedsec Chris@82: \global\let\subsection = \unnumberedsubsec Chris@82: \global\let\subsubsection = \unnumberedsubsubsec Chris@82: } Chris@82: Chris@82: % @centerchap is like @unnumbered, but the heading is centered. Chris@82: \outer\parseargdef\centerchap{% Chris@82: % Well, we could do the following in a group, but that would break Chris@82: % an assumption that \chapmacro is called at the outermost level. Chris@82: % Thus we are safer this way: --kasal, 24feb04 Chris@82: \let\centerparametersmaybe = \centerparameters Chris@82: \unnmhead0{#1}% Chris@82: \let\centerparametersmaybe = \relax Chris@82: } Chris@82: Chris@82: % @top is like @unnumbered. Chris@82: \let\top\unnumbered Chris@82: Chris@82: % Sections. Chris@82: % Chris@82: \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz Chris@82: \def\seczzz#1{% Chris@82: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 Chris@82: \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% Chris@82: } Chris@82: Chris@82: % normally calls appendixsectionzzz: Chris@82: \outer\parseargdef\appendixsection{\apphead1{#1}} Chris@82: \def\appendixsectionzzz#1{% Chris@82: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 Chris@82: \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% Chris@82: } Chris@82: \let\appendixsec\appendixsection Chris@82: Chris@82: % normally calls unnumberedseczzz: Chris@82: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} Chris@82: \def\unnumberedseczzz#1{% Chris@82: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 Chris@82: \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% Chris@82: } Chris@82: Chris@82: % Subsections. Chris@82: % Chris@82: % normally calls numberedsubseczzz: Chris@82: \outer\parseargdef\numberedsubsec{\numhead2{#1}} Chris@82: \def\numberedsubseczzz#1{% Chris@82: \global\subsubsecno=0 \global\advance\subsecno by 1 Chris@82: \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% Chris@82: } Chris@82: Chris@82: % normally calls appendixsubseczzz: Chris@82: \outer\parseargdef\appendixsubsec{\apphead2{#1}} Chris@82: \def\appendixsubseczzz#1{% Chris@82: \global\subsubsecno=0 \global\advance\subsecno by 1 Chris@82: \sectionheading{#1}{subsec}{Yappendix}% Chris@82: {\appendixletter.\the\secno.\the\subsecno}% Chris@82: } Chris@82: Chris@82: % normally calls unnumberedsubseczzz: Chris@82: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} Chris@82: \def\unnumberedsubseczzz#1{% Chris@82: \global\subsubsecno=0 \global\advance\subsecno by 1 Chris@82: \sectionheading{#1}{subsec}{Ynothing}% Chris@82: {\the\unnumberedno.\the\secno.\the\subsecno}% Chris@82: } Chris@82: Chris@82: % Subsubsections. Chris@82: % Chris@82: % normally numberedsubsubseczzz: Chris@82: \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} Chris@82: \def\numberedsubsubseczzz#1{% Chris@82: \global\advance\subsubsecno by 1 Chris@82: \sectionheading{#1}{subsubsec}{Ynumbered}% Chris@82: {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% Chris@82: } Chris@82: Chris@82: % normally appendixsubsubseczzz: Chris@82: \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} Chris@82: \def\appendixsubsubseczzz#1{% Chris@82: \global\advance\subsubsecno by 1 Chris@82: \sectionheading{#1}{subsubsec}{Yappendix}% Chris@82: {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% Chris@82: } Chris@82: Chris@82: % normally unnumberedsubsubseczzz: Chris@82: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} Chris@82: \def\unnumberedsubsubseczzz#1{% Chris@82: \global\advance\subsubsecno by 1 Chris@82: \sectionheading{#1}{subsubsec}{Ynothing}% Chris@82: {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% Chris@82: } Chris@82: Chris@82: % These macros control what the section commands do, according Chris@82: % to what kind of chapter we are in (ordinary, appendix, or unnumbered). Chris@82: % Define them by default for a numbered chapter. Chris@82: \let\section = \numberedsec Chris@82: \let\subsection = \numberedsubsec Chris@82: \let\subsubsection = \numberedsubsubsec Chris@82: Chris@82: % Define @majorheading, @heading and @subheading Chris@82: Chris@82: \def\majorheading{% Chris@82: {\advance\chapheadingskip by 10pt \chapbreak }% Chris@82: \parsearg\chapheadingzzz Chris@82: } Chris@82: Chris@82: \def\chapheading{\chapbreak \parsearg\chapheadingzzz} Chris@82: \def\chapheadingzzz#1{% Chris@82: \vbox{\chapfonts \raggedtitlesettings #1\par}% Chris@82: \nobreak\bigskip \nobreak Chris@82: \suppressfirstparagraphindent Chris@82: } Chris@82: Chris@82: % @heading, @subheading, @subsubheading. Chris@82: \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} Chris@82: \suppressfirstparagraphindent} Chris@82: \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} Chris@82: \suppressfirstparagraphindent} Chris@82: \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} Chris@82: \suppressfirstparagraphindent} Chris@82: Chris@82: % These macros generate a chapter, section, etc. heading only Chris@82: % (including whitespace, linebreaking, etc. around it), Chris@82: % given all the information in convenient, parsed form. Chris@82: Chris@82: % Args are the skip and penalty (usually negative) Chris@82: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} Chris@82: Chris@82: % Parameter controlling skip before chapter headings (if needed) Chris@82: \newskip\chapheadingskip Chris@82: Chris@82: % Define plain chapter starts, and page on/off switching for it. Chris@82: \def\chapbreak{\dobreak \chapheadingskip {-4000}} Chris@82: \def\chappager{\par\vfill\supereject} Chris@82: % Because \domark is called before \chapoddpage, the filler page will Chris@82: % get the headings for the next chapter, which is wrong. But we don't Chris@82: % care -- we just disable all headings on the filler page. Chris@82: \def\chapoddpage{% Chris@82: \chappager Chris@82: \ifodd\pageno \else Chris@82: \begingroup Chris@82: \headingsoff Chris@82: \null Chris@82: \chappager Chris@82: \endgroup Chris@82: \fi Chris@82: } Chris@82: Chris@82: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} Chris@82: Chris@82: \def\CHAPPAGoff{% Chris@82: \global\let\contentsalignmacro = \chappager Chris@82: \global\let\pchapsepmacro=\chapbreak Chris@82: \global\let\pagealignmacro=\chappager} Chris@82: Chris@82: \def\CHAPPAGon{% Chris@82: \global\let\contentsalignmacro = \chappager Chris@82: \global\let\pchapsepmacro=\chappager Chris@82: \global\let\pagealignmacro=\chappager Chris@82: \global\def\HEADINGSon{\HEADINGSsingle}} Chris@82: Chris@82: \def\CHAPPAGodd{% Chris@82: \global\let\contentsalignmacro = \chapoddpage Chris@82: \global\let\pchapsepmacro=\chapoddpage Chris@82: \global\let\pagealignmacro=\chapoddpage Chris@82: \global\def\HEADINGSon{\HEADINGSdouble}} Chris@82: Chris@82: \CHAPPAGon Chris@82: Chris@82: % Chapter opening. Chris@82: % Chris@82: % #1 is the text, #2 is the section type (Ynumbered, Ynothing, Chris@82: % Yappendix, Yomitfromtoc), #3 the chapter number. Chris@82: % Chris@82: % To test against our argument. Chris@82: \def\Ynothingkeyword{Ynothing} Chris@82: \def\Yomitfromtockeyword{Yomitfromtoc} Chris@82: \def\Yappendixkeyword{Yappendix} Chris@82: % Chris@82: \def\chapmacro#1#2#3{% Chris@82: % Insert the first mark before the heading break (see notes for \domark). Chris@82: \let\prevchapterdefs=\lastchapterdefs Chris@82: \let\prevsectiondefs=\lastsectiondefs Chris@82: \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% Chris@82: \gdef\thissection{}}% Chris@82: % Chris@82: \def\temptype{#2}% Chris@82: \ifx\temptype\Ynothingkeyword Chris@82: \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% Chris@82: \gdef\thischapter{\thischaptername}}% Chris@82: \else\ifx\temptype\Yomitfromtockeyword Chris@82: \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% Chris@82: \gdef\thischapter{}}% Chris@82: \else\ifx\temptype\Yappendixkeyword Chris@82: \toks0={#1}% Chris@82: \xdef\lastchapterdefs{% Chris@82: \gdef\noexpand\thischaptername{\the\toks0}% Chris@82: \gdef\noexpand\thischapternum{\appendixletter}% Chris@82: % \noexpand\putwordAppendix avoids expanding indigestible Chris@82: % commands in some of the translations. Chris@82: \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} Chris@82: \noexpand\thischapternum: Chris@82: \noexpand\thischaptername}% Chris@82: }% Chris@82: \else Chris@82: \toks0={#1}% Chris@82: \xdef\lastchapterdefs{% Chris@82: \gdef\noexpand\thischaptername{\the\toks0}% Chris@82: \gdef\noexpand\thischapternum{\the\chapno}% Chris@82: % \noexpand\putwordChapter avoids expanding indigestible Chris@82: % commands in some of the translations. Chris@82: \gdef\noexpand\thischapter{\noexpand\putwordChapter{} Chris@82: \noexpand\thischapternum: Chris@82: \noexpand\thischaptername}% Chris@82: }% Chris@82: \fi\fi\fi Chris@82: % Chris@82: % Output the mark. Pass it through \safewhatsit, to take care of Chris@82: % the preceding space. Chris@82: \safewhatsit\domark Chris@82: % Chris@82: % Insert the chapter heading break. Chris@82: \pchapsepmacro Chris@82: % Chris@82: % Now the second mark, after the heading break. No break points Chris@82: % between here and the heading. Chris@82: \let\prevchapterdefs=\lastchapterdefs Chris@82: \let\prevsectiondefs=\lastsectiondefs Chris@82: \domark Chris@82: % Chris@82: {% Chris@82: \chapfonts \rmisbold Chris@82: % Chris@82: % Have to define \lastsection before calling \donoderef, because the Chris@82: % xref code eventually uses it. On the other hand, it has to be called Chris@82: % after \pchapsepmacro, or the headline will change too soon. Chris@82: \gdef\lastsection{#1}% Chris@82: % Chris@82: % Only insert the separating space if we have a chapter/appendix Chris@82: % number, and don't print the unnumbered ``number''. Chris@82: \ifx\temptype\Ynothingkeyword Chris@82: \setbox0 = \hbox{}% Chris@82: \def\toctype{unnchap}% Chris@82: \else\ifx\temptype\Yomitfromtockeyword Chris@82: \setbox0 = \hbox{}% contents like unnumbered, but no toc entry Chris@82: \def\toctype{omit}% Chris@82: \else\ifx\temptype\Yappendixkeyword Chris@82: \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% Chris@82: \def\toctype{app}% Chris@82: \else Chris@82: \setbox0 = \hbox{#3\enspace}% Chris@82: \def\toctype{numchap}% Chris@82: \fi\fi\fi Chris@82: % Chris@82: % Write the toc entry for this chapter. Must come before the Chris@82: % \donoderef, because we include the current node name in the toc Chris@82: % entry, and \donoderef resets it to empty. Chris@82: \writetocentry{\toctype}{#1}{#3}% Chris@82: % Chris@82: % For pdftex, we have to write out the node definition (aka, make Chris@82: % the pdfdest) after any page break, but before the actual text has Chris@82: % been typeset. If the destination for the pdf outline is after the Chris@82: % text, then jumping from the outline may wind up with the text not Chris@82: % being visible, for instance under high magnification. Chris@82: \donoderef{#2}% Chris@82: % Chris@82: % Typeset the actual heading. Chris@82: \nobreak % Avoid page breaks at the interline glue. Chris@82: \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe Chris@82: \unhbox0 #1\par}% Chris@82: }% Chris@82: \nobreak\bigskip % no page break after a chapter title Chris@82: \nobreak Chris@82: } Chris@82: Chris@82: % @centerchap -- centered and unnumbered. Chris@82: \let\centerparametersmaybe = \relax Chris@82: \def\centerparameters{% Chris@82: \advance\rightskip by 3\rightskip Chris@82: \leftskip = \rightskip Chris@82: \parfillskip = 0pt Chris@82: } Chris@82: Chris@82: Chris@82: % I don't think this chapter style is supported any more, so I'm not Chris@82: % updating it with the new noderef stuff. We'll see. --karl, 11aug03. Chris@82: % Chris@82: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} Chris@82: % Chris@82: \def\unnchfopen #1{% Chris@82: \chapoddpage Chris@82: \vbox{\chapfonts \raggedtitlesettings #1\par}% Chris@82: \nobreak\bigskip\nobreak Chris@82: } Chris@82: \def\chfopen #1#2{\chapoddpage {\chapfonts Chris@82: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% Chris@82: \par\penalty 5000 % Chris@82: } Chris@82: \def\centerchfopen #1{% Chris@82: \chapoddpage Chris@82: \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}% Chris@82: \nobreak\bigskip \nobreak Chris@82: } Chris@82: \def\CHAPFopen{% Chris@82: \global\let\chapmacro=\chfopen Chris@82: \global\let\centerchapmacro=\centerchfopen} Chris@82: Chris@82: Chris@82: % Section titles. These macros combine the section number parts and Chris@82: % call the generic \sectionheading to do the printing. Chris@82: % Chris@82: \newskip\secheadingskip Chris@82: \def\secheadingbreak{\dobreak \secheadingskip{-1000}} Chris@82: Chris@82: % Subsection titles. Chris@82: \newskip\subsecheadingskip Chris@82: \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} Chris@82: Chris@82: % Subsubsection titles. Chris@82: \def\subsubsecheadingskip{\subsecheadingskip} Chris@82: \def\subsubsecheadingbreak{\subsecheadingbreak} Chris@82: Chris@82: Chris@82: % Print any size, any type, section title. Chris@82: % Chris@82: % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is Chris@82: % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the Chris@82: % section number. Chris@82: % Chris@82: \def\seckeyword{sec} Chris@82: % Chris@82: \def\sectionheading#1#2#3#4{% Chris@82: {% Chris@82: \checkenv{}% should not be in an environment. Chris@82: % Chris@82: % Switch to the right set of fonts. Chris@82: \csname #2fonts\endcsname \rmisbold Chris@82: % Chris@82: \def\sectionlevel{#2}% Chris@82: \def\temptype{#3}% Chris@82: % Chris@82: % Insert first mark before the heading break (see notes for \domark). Chris@82: \let\prevsectiondefs=\lastsectiondefs Chris@82: \ifx\temptype\Ynothingkeyword Chris@82: \ifx\sectionlevel\seckeyword Chris@82: \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% Chris@82: \gdef\thissection{\thissectionname}}% Chris@82: \fi Chris@82: \else\ifx\temptype\Yomitfromtockeyword Chris@82: % Don't redefine \thissection. Chris@82: \else\ifx\temptype\Yappendixkeyword Chris@82: \ifx\sectionlevel\seckeyword Chris@82: \toks0={#1}% Chris@82: \xdef\lastsectiondefs{% Chris@82: \gdef\noexpand\thissectionname{\the\toks0}% Chris@82: \gdef\noexpand\thissectionnum{#4}% Chris@82: % \noexpand\putwordSection avoids expanding indigestible Chris@82: % commands in some of the translations. Chris@82: \gdef\noexpand\thissection{\noexpand\putwordSection{} Chris@82: \noexpand\thissectionnum: Chris@82: \noexpand\thissectionname}% Chris@82: }% Chris@82: \fi Chris@82: \else Chris@82: \ifx\sectionlevel\seckeyword Chris@82: \toks0={#1}% Chris@82: \xdef\lastsectiondefs{% Chris@82: \gdef\noexpand\thissectionname{\the\toks0}% Chris@82: \gdef\noexpand\thissectionnum{#4}% Chris@82: % \noexpand\putwordSection avoids expanding indigestible Chris@82: % commands in some of the translations. Chris@82: \gdef\noexpand\thissection{\noexpand\putwordSection{} Chris@82: \noexpand\thissectionnum: Chris@82: \noexpand\thissectionname}% Chris@82: }% Chris@82: \fi Chris@82: \fi\fi\fi Chris@82: % Chris@82: % Go into vertical mode. Usually we'll already be there, but we Chris@82: % don't want the following whatsit to end up in a preceding paragraph Chris@82: % if the document didn't happen to have a blank line. Chris@82: \par Chris@82: % Chris@82: % Output the mark. Pass it through \safewhatsit, to take care of Chris@82: % the preceding space. Chris@82: \safewhatsit\domark Chris@82: % Chris@82: % Insert space above the heading. Chris@82: \csname #2headingbreak\endcsname Chris@82: % Chris@82: % Now the second mark, after the heading break. No break points Chris@82: % between here and the heading. Chris@82: \let\prevsectiondefs=\lastsectiondefs Chris@82: \domark Chris@82: % Chris@82: % Only insert the space after the number if we have a section number. Chris@82: \ifx\temptype\Ynothingkeyword Chris@82: \setbox0 = \hbox{}% Chris@82: \def\toctype{unn}% Chris@82: \gdef\lastsection{#1}% Chris@82: \else\ifx\temptype\Yomitfromtockeyword Chris@82: % for @headings -- no section number, don't include in toc, Chris@82: % and don't redefine \lastsection. Chris@82: \setbox0 = \hbox{}% Chris@82: \def\toctype{omit}% Chris@82: \let\sectionlevel=\empty Chris@82: \else\ifx\temptype\Yappendixkeyword Chris@82: \setbox0 = \hbox{#4\enspace}% Chris@82: \def\toctype{app}% Chris@82: \gdef\lastsection{#1}% Chris@82: \else Chris@82: \setbox0 = \hbox{#4\enspace}% Chris@82: \def\toctype{num}% Chris@82: \gdef\lastsection{#1}% Chris@82: \fi\fi\fi Chris@82: % Chris@82: % Write the toc entry (before \donoderef). See comments in \chapmacro. Chris@82: \writetocentry{\toctype\sectionlevel}{#1}{#4}% Chris@82: % Chris@82: % Write the node reference (= pdf destination for pdftex). Chris@82: % Again, see comments in \chapmacro. Chris@82: \donoderef{#3}% Chris@82: % Chris@82: % Interline glue will be inserted when the vbox is completed. Chris@82: % That glue will be a valid breakpoint for the page, since it'll be Chris@82: % preceded by a whatsit (usually from the \donoderef, or from the Chris@82: % \writetocentry if there was no node). We don't want to allow that Chris@82: % break, since then the whatsits could end up on page n while the Chris@82: % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. Chris@82: \nobreak Chris@82: % Chris@82: % Output the actual section heading. Chris@82: \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright Chris@82: \hangindent=\wd0 % zero if no section number Chris@82: \unhbox0 #1}% Chris@82: }% Chris@82: % Add extra space after the heading -- half of whatever came above it. Chris@82: % Don't allow stretch, though. Chris@82: \kern .5 \csname #2headingskip\endcsname Chris@82: % Chris@82: % Do not let the kern be a potential breakpoint, as it would be if it Chris@82: % was followed by glue. Chris@82: \nobreak Chris@82: % Chris@82: % We'll almost certainly start a paragraph next, so don't let that Chris@82: % glue accumulate. (Not a breakpoint because it's preceded by a Chris@82: % discardable item.) However, when a paragraph is not started next Chris@82: % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out Chris@82: % or the negative glue will cause weirdly wrong output, typically Chris@82: % obscuring the section heading with something else. Chris@82: \vskip-\parskip Chris@82: % Chris@82: % This is so the last item on the main vertical list is a known Chris@82: % \penalty > 10000, so \startdefun, etc., can recognize the situation Chris@82: % and do the needful. Chris@82: \penalty 10001 Chris@82: } Chris@82: Chris@82: Chris@82: \message{toc,} Chris@82: % Table of contents. Chris@82: \newwrite\tocfile Chris@82: Chris@82: % Write an entry to the toc file, opening it if necessary. Chris@82: % Called from @chapter, etc. Chris@82: % Chris@82: % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} Chris@82: % We append the current node name (if any) and page number as additional Chris@82: % arguments for the \{chap,sec,...}entry macros which will eventually Chris@82: % read this. The node name is used in the pdf outlines as the Chris@82: % destination to jump to. Chris@82: % Chris@82: % We open the .toc file for writing here instead of at @setfilename (or Chris@82: % any other fixed time) so that @contents can be anywhere in the document. Chris@82: % But if #1 is `omit', then we don't do anything. This is used for the Chris@82: % table of contents chapter openings themselves. Chris@82: % Chris@82: \newif\iftocfileopened Chris@82: \def\omitkeyword{omit}% Chris@82: % Chris@82: \def\writetocentry#1#2#3{% Chris@82: \edef\writetoctype{#1}% Chris@82: \ifx\writetoctype\omitkeyword \else Chris@82: \iftocfileopened\else Chris@82: \immediate\openout\tocfile = \jobname.toc Chris@82: \global\tocfileopenedtrue Chris@82: \fi Chris@82: % Chris@82: \iflinks Chris@82: {\atdummies Chris@82: \edef\temp{% Chris@82: \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% Chris@82: \temp Chris@82: }% Chris@82: \fi Chris@82: \fi Chris@82: % Chris@82: % Tell \shipout to create a pdf destination on each page, if we're Chris@82: % writing pdf. These are used in the table of contents. We can't Chris@82: % just write one on every page because the title pages are numbered Chris@82: % 1 and 2 (the page numbers aren't printed), and so are the first Chris@82: % two pages of the document. Thus, we'd have two destinations named Chris@82: % `1', and two named `2'. Chris@82: \ifpdf \global\pdfmakepagedesttrue \fi Chris@82: } Chris@82: Chris@82: Chris@82: % These characters do not print properly in the Computer Modern roman Chris@82: % fonts, so we must take special care. This is more or less redundant Chris@82: % with the Texinfo input format setup at the end of this file. Chris@82: % Chris@82: \def\activecatcodes{% Chris@82: \catcode`\"=\active Chris@82: \catcode`\$=\active Chris@82: \catcode`\<=\active Chris@82: \catcode`\>=\active Chris@82: \catcode`\\=\active Chris@82: \catcode`\^=\active Chris@82: \catcode`\_=\active Chris@82: \catcode`\|=\active Chris@82: \catcode`\~=\active Chris@82: } Chris@82: Chris@82: Chris@82: % Read the toc file, which is essentially Texinfo input. Chris@82: \def\readtocfile{% Chris@82: \setupdatafile Chris@82: \activecatcodes Chris@82: \input \tocreadfilename Chris@82: } Chris@82: Chris@82: \newskip\contentsrightmargin \contentsrightmargin=1in Chris@82: \newcount\savepageno Chris@82: \newcount\lastnegativepageno \lastnegativepageno = -1 Chris@82: Chris@82: % Prepare to read what we've written to \tocfile. Chris@82: % Chris@82: \def\startcontents#1{% Chris@82: % If @setchapternewpage on, and @headings double, the contents should Chris@82: % start on an odd page, unlike chapters. Thus, we maintain Chris@82: % \contentsalignmacro in parallel with \pagealignmacro. Chris@82: % From: Torbjorn Granlund Chris@82: \contentsalignmacro Chris@82: \immediate\closeout\tocfile Chris@82: % Chris@82: % Don't need to put `Contents' or `Short Contents' in the headline. Chris@82: % It is abundantly clear what they are. Chris@82: \chapmacro{#1}{Yomitfromtoc}{}% Chris@82: % Chris@82: \savepageno = \pageno Chris@82: \begingroup % Set up to handle contents files properly. Chris@82: \raggedbottom % Worry more about breakpoints than the bottom. Chris@82: \advance\hsize by -\contentsrightmargin % Don't use the full line length. Chris@82: % Chris@82: % Roman numerals for page numbers. Chris@82: \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi Chris@82: } Chris@82: Chris@82: % redefined for the two-volume lispref. We always output on Chris@82: % \jobname.toc even if this is redefined. Chris@82: % Chris@82: \def\tocreadfilename{\jobname.toc} Chris@82: Chris@82: % Normal (long) toc. Chris@82: % Chris@82: \def\contents{% Chris@82: \startcontents{\putwordTOC}% Chris@82: \openin 1 \tocreadfilename\space Chris@82: \ifeof 1 \else Chris@82: \readtocfile Chris@82: \fi Chris@82: \vfill \eject Chris@82: \contentsalignmacro % in case @setchapternewpage odd is in effect Chris@82: \ifeof 1 \else Chris@82: \pdfmakeoutlines Chris@82: \fi Chris@82: \closein 1 Chris@82: \endgroup Chris@82: \lastnegativepageno = \pageno Chris@82: \global\pageno = \savepageno Chris@82: } Chris@82: Chris@82: % And just the chapters. Chris@82: \def\summarycontents{% Chris@82: \startcontents{\putwordShortTOC}% Chris@82: % Chris@82: \let\partentry = \shortpartentry Chris@82: \let\numchapentry = \shortchapentry Chris@82: \let\appentry = \shortchapentry Chris@82: \let\unnchapentry = \shortunnchapentry Chris@82: % We want a true roman here for the page numbers. Chris@82: \secfonts Chris@82: \let\rm=\shortcontrm \let\bf=\shortcontbf Chris@82: \let\sl=\shortcontsl \let\tt=\shortconttt Chris@82: \rm Chris@82: \hyphenpenalty = 10000 Chris@82: \advance\baselineskip by 1pt % Open it up a little. Chris@82: \def\numsecentry##1##2##3##4{} Chris@82: \let\appsecentry = \numsecentry Chris@82: \let\unnsecentry = \numsecentry Chris@82: \let\numsubsecentry = \numsecentry Chris@82: \let\appsubsecentry = \numsecentry Chris@82: \let\unnsubsecentry = \numsecentry Chris@82: \let\numsubsubsecentry = \numsecentry Chris@82: \let\appsubsubsecentry = \numsecentry Chris@82: \let\unnsubsubsecentry = \numsecentry Chris@82: \openin 1 \tocreadfilename\space Chris@82: \ifeof 1 \else Chris@82: \readtocfile Chris@82: \fi Chris@82: \closein 1 Chris@82: \vfill \eject Chris@82: \contentsalignmacro % in case @setchapternewpage odd is in effect Chris@82: \endgroup Chris@82: \lastnegativepageno = \pageno Chris@82: \global\pageno = \savepageno Chris@82: } Chris@82: \let\shortcontents = \summarycontents Chris@82: Chris@82: % Typeset the label for a chapter or appendix for the short contents. Chris@82: % The arg is, e.g., `A' for an appendix, or `3' for a chapter. Chris@82: % Chris@82: \def\shortchaplabel#1{% Chris@82: % This space should be enough, since a single number is .5em, and the Chris@82: % widest letter (M) is 1em, at least in the Computer Modern fonts. Chris@82: % But use \hss just in case. Chris@82: % (This space doesn't include the extra space that gets added after Chris@82: % the label; that gets put in by \shortchapentry above.) Chris@82: % Chris@82: % We'd like to right-justify chapter numbers, but that looks strange Chris@82: % with appendix letters. And right-justifying numbers and Chris@82: % left-justifying letters looks strange when there is less than 10 Chris@82: % chapters. Have to read the whole toc once to know how many chapters Chris@82: % there are before deciding ... Chris@82: \hbox to 1em{#1\hss}% Chris@82: } Chris@82: Chris@82: % These macros generate individual entries in the table of contents. Chris@82: % The first argument is the chapter or section name. Chris@82: % The last argument is the page number. Chris@82: % The arguments in between are the chapter number, section number, ... Chris@82: Chris@82: % Parts, in the main contents. Replace the part number, which doesn't Chris@82: % exist, with an empty box. Let's hope all the numbers have the same width. Chris@82: % Also ignore the page number, which is conventionally not printed. Chris@82: \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} Chris@82: \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} Chris@82: % Chris@82: % Parts, in the short toc. Chris@82: \def\shortpartentry#1#2#3#4{% Chris@82: \penalty-300 Chris@82: \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip Chris@82: \shortchapentry{{\bf #1}}{\numeralbox}{}{}% Chris@82: } Chris@82: Chris@82: % Chapters, in the main contents. Chris@82: \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} Chris@82: % Chris@82: % Chapters, in the short toc. Chris@82: % See comments in \dochapentry re vbox and related settings. Chris@82: \def\shortchapentry#1#2#3#4{% Chris@82: \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% Chris@82: } Chris@82: Chris@82: % Appendices, in the main contents. Chris@82: % Need the word Appendix, and a fixed-size box. Chris@82: % Chris@82: \def\appendixbox#1{% Chris@82: % We use M since it's probably the widest letter. Chris@82: \setbox0 = \hbox{\putwordAppendix{} M}% Chris@82: \hbox to \wd0{\putwordAppendix{} #1\hss}} Chris@82: % Chris@82: \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} Chris@82: Chris@82: % Unnumbered chapters. Chris@82: \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} Chris@82: \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} Chris@82: Chris@82: % Sections. Chris@82: \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} Chris@82: \let\appsecentry=\numsecentry Chris@82: \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} Chris@82: Chris@82: % Subsections. Chris@82: \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} Chris@82: \let\appsubsecentry=\numsubsecentry Chris@82: \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} Chris@82: Chris@82: % And subsubsections. Chris@82: \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} Chris@82: \let\appsubsubsecentry=\numsubsubsecentry Chris@82: \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} Chris@82: Chris@82: % This parameter controls the indentation of the various levels. Chris@82: % Same as \defaultparindent. Chris@82: \newdimen\tocindent \tocindent = 15pt Chris@82: Chris@82: % Now for the actual typesetting. In all these, #1 is the text and #2 is the Chris@82: % page number. Chris@82: % Chris@82: % If the toc has to be broken over pages, we want it to be at chapters Chris@82: % if at all possible; hence the \penalty. Chris@82: \def\dochapentry#1#2{% Chris@82: \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip Chris@82: \begingroup Chris@82: \chapentryfonts Chris@82: \tocentry{#1}{\dopageno\bgroup#2\egroup}% Chris@82: \endgroup Chris@82: \nobreak\vskip .25\baselineskip plus.1\baselineskip Chris@82: } Chris@82: Chris@82: \def\dosecentry#1#2{\begingroup Chris@82: \secentryfonts \leftskip=\tocindent Chris@82: \tocentry{#1}{\dopageno\bgroup#2\egroup}% Chris@82: \endgroup} Chris@82: Chris@82: \def\dosubsecentry#1#2{\begingroup Chris@82: \subsecentryfonts \leftskip=2\tocindent Chris@82: \tocentry{#1}{\dopageno\bgroup#2\egroup}% Chris@82: \endgroup} Chris@82: Chris@82: \def\dosubsubsecentry#1#2{\begingroup Chris@82: \subsubsecentryfonts \leftskip=3\tocindent Chris@82: \tocentry{#1}{\dopageno\bgroup#2\egroup}% Chris@82: \endgroup} Chris@82: Chris@82: % We use the same \entry macro as for the index entries. Chris@82: \let\tocentry = \entry Chris@82: Chris@82: % Space between chapter (or whatever) number and the title. Chris@82: \def\labelspace{\hskip1em \relax} Chris@82: Chris@82: \def\dopageno#1{{\rm #1}} Chris@82: \def\doshortpageno#1{{\rm #1}} Chris@82: Chris@82: \def\chapentryfonts{\secfonts \rm} Chris@82: \def\secentryfonts{\textfonts} Chris@82: \def\subsecentryfonts{\textfonts} Chris@82: \def\subsubsecentryfonts{\textfonts} Chris@82: Chris@82: Chris@82: \message{environments,} Chris@82: % @foo ... @end foo. Chris@82: Chris@82: % @tex ... @end tex escapes into raw TeX temporarily. Chris@82: % One exception: @ is still an escape character, so that @end tex works. Chris@82: % But \@ or @@ will get a plain @ character. Chris@82: Chris@82: \envdef\tex{% Chris@82: \setupmarkupstyle{tex}% Chris@82: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 Chris@82: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 Chris@82: \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie Chris@82: \catcode `\%=14 Chris@82: \catcode `\+=\other Chris@82: \catcode `\"=\other Chris@82: \catcode `\|=\other Chris@82: \catcode `\<=\other Chris@82: \catcode `\>=\other Chris@82: \catcode`\`=\other Chris@82: \catcode`\'=\other Chris@82: \escapechar=`\\ Chris@82: % Chris@82: % ' is active in math mode (mathcode"8000). So reset it, and all our Chris@82: % other math active characters (just in case), to plain's definitions. Chris@82: \mathactive Chris@82: % Chris@82: \let\b=\ptexb Chris@82: \let\bullet=\ptexbullet Chris@82: \let\c=\ptexc Chris@82: \let\,=\ptexcomma Chris@82: \let\.=\ptexdot Chris@82: \let\dots=\ptexdots Chris@82: \let\equiv=\ptexequiv Chris@82: \let\!=\ptexexclam Chris@82: \let\i=\ptexi Chris@82: \let\indent=\ptexindent Chris@82: \let\noindent=\ptexnoindent Chris@82: \let\{=\ptexlbrace Chris@82: \let\+=\tabalign Chris@82: \let\}=\ptexrbrace Chris@82: \let\/=\ptexslash Chris@82: \let\*=\ptexstar Chris@82: \let\t=\ptext Chris@82: \expandafter \let\csname top\endcsname=\ptextop % outer Chris@82: \let\frenchspacing=\plainfrenchspacing Chris@82: % Chris@82: \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% Chris@82: \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% Chris@82: \def\@{@}% Chris@82: } Chris@82: % There is no need to define \Etex. Chris@82: Chris@82: % Define @lisp ... @end lisp. Chris@82: % @lisp environment forms a group so it can rebind things, Chris@82: % including the definition of @end lisp (which normally is erroneous). Chris@82: Chris@82: % Amount to narrow the margins by for @lisp. Chris@82: \newskip\lispnarrowing \lispnarrowing=0.4in Chris@82: Chris@82: % This is the definition that ^^M gets inside @lisp, @example, and other Chris@82: % such environments. \null is better than a space, since it doesn't Chris@82: % have any width. Chris@82: \def\lisppar{\null\endgraf} Chris@82: Chris@82: % This space is always present above and below environments. Chris@82: \newskip\envskipamount \envskipamount = 0pt Chris@82: Chris@82: % Make spacing and below environment symmetrical. We use \parskip here Chris@82: % to help in doing that, since in @example-like environments \parskip Chris@82: % is reset to zero; thus the \afterenvbreak inserts no space -- but the Chris@82: % start of the next paragraph will insert \parskip. Chris@82: % Chris@82: \def\aboveenvbreak{{% Chris@82: % =10000 instead of <10000 because of a special case in \itemzzz and Chris@82: % \sectionheading, q.v. Chris@82: \ifnum \lastpenalty=10000 \else Chris@82: \advance\envskipamount by \parskip Chris@82: \endgraf Chris@82: \ifdim\lastskip<\envskipamount Chris@82: \removelastskip Chris@82: % it's not a good place to break if the last penalty was \nobreak Chris@82: % or better ... Chris@82: \ifnum\lastpenalty<10000 \penalty-50 \fi Chris@82: \vskip\envskipamount Chris@82: \fi Chris@82: \fi Chris@82: }} Chris@82: Chris@82: \let\afterenvbreak = \aboveenvbreak Chris@82: Chris@82: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will Chris@82: % also clear it, so that its embedded environments do the narrowing again. Chris@82: \let\nonarrowing=\relax Chris@82: Chris@82: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around Chris@82: % environment contents. Chris@82: \font\circle=lcircle10 Chris@82: \newdimen\circthick Chris@82: \newdimen\cartouter\newdimen\cartinner Chris@82: \newskip\normbskip\newskip\normpskip\newskip\normlskip Chris@82: \circthick=\fontdimen8\circle Chris@82: % Chris@82: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth Chris@82: \def\ctr{{\hskip 6pt\circle\char'010}} Chris@82: \def\cbl{{\circle\char'012\hskip -6pt}} Chris@82: \def\cbr{{\hskip 6pt\circle\char'011}} Chris@82: \def\carttop{\hbox to \cartouter{\hskip\lskip Chris@82: \ctl\leaders\hrule height\circthick\hfil\ctr Chris@82: \hskip\rskip}} Chris@82: \def\cartbot{\hbox to \cartouter{\hskip\lskip Chris@82: \cbl\leaders\hrule height\circthick\hfil\cbr Chris@82: \hskip\rskip}} Chris@82: % Chris@82: \newskip\lskip\newskip\rskip Chris@82: Chris@82: \envdef\cartouche{% Chris@82: \ifhmode\par\fi % can't be in the midst of a paragraph. Chris@82: \startsavinginserts Chris@82: \lskip=\leftskip \rskip=\rightskip Chris@82: \leftskip=0pt\rightskip=0pt % we want these *outside*. Chris@82: \cartinner=\hsize \advance\cartinner by-\lskip Chris@82: \advance\cartinner by-\rskip Chris@82: \cartouter=\hsize Chris@82: \advance\cartouter by 18.4pt % allow for 3pt kerns on either Chris@82: % side, and for 6pt waste from Chris@82: % each corner char, and rule thickness Chris@82: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip Chris@82: % Flag to tell @lisp, etc., not to narrow margin. Chris@82: \let\nonarrowing = t% Chris@82: % Chris@82: % If this cartouche directly follows a sectioning command, we need the Chris@82: % \parskip glue (backspaced over by default) or the cartouche can Chris@82: % collide with the section heading. Chris@82: \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi Chris@82: % Chris@82: \vbox\bgroup Chris@82: \baselineskip=0pt\parskip=0pt\lineskip=0pt Chris@82: \carttop Chris@82: \hbox\bgroup Chris@82: \hskip\lskip Chris@82: \vrule\kern3pt Chris@82: \vbox\bgroup Chris@82: \kern3pt Chris@82: \hsize=\cartinner Chris@82: \baselineskip=\normbskip Chris@82: \lineskip=\normlskip Chris@82: \parskip=\normpskip Chris@82: \vskip -\parskip Chris@82: \comment % For explanation, see the end of def\group. Chris@82: } Chris@82: \def\Ecartouche{% Chris@82: \ifhmode\par\fi Chris@82: \kern3pt Chris@82: \egroup Chris@82: \kern3pt\vrule Chris@82: \hskip\rskip Chris@82: \egroup Chris@82: \cartbot Chris@82: \egroup Chris@82: \checkinserts Chris@82: } Chris@82: Chris@82: Chris@82: % This macro is called at the beginning of all the @example variants, Chris@82: % inside a group. Chris@82: \newdimen\nonfillparindent Chris@82: \def\nonfillstart{% Chris@82: \aboveenvbreak Chris@82: \hfuzz = 12pt % Don't be fussy Chris@82: \sepspaces % Make spaces be word-separators rather than space tokens. Chris@82: \let\par = \lisppar % don't ignore blank lines Chris@82: \obeylines % each line of input is a line of output Chris@82: \parskip = 0pt Chris@82: % Turn off paragraph indentation but redefine \indent to emulate Chris@82: % the normal \indent. Chris@82: \nonfillparindent=\parindent Chris@82: \parindent = 0pt Chris@82: \let\indent\nonfillindent Chris@82: % Chris@82: \emergencystretch = 0pt % don't try to avoid overfull boxes Chris@82: \ifx\nonarrowing\relax Chris@82: \advance \leftskip by \lispnarrowing Chris@82: \exdentamount=\lispnarrowing Chris@82: \else Chris@82: \let\nonarrowing = \relax Chris@82: \fi Chris@82: \let\exdent=\nofillexdent Chris@82: } Chris@82: Chris@82: \begingroup Chris@82: \obeyspaces Chris@82: % We want to swallow spaces (but not other tokens) after the fake Chris@82: % @indent in our nonfill-environments, where spaces are normally Chris@82: % active and set to @tie, resulting in them not being ignored after Chris@82: % @indent. Chris@82: \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% Chris@82: \gdef\nonfillindentcheck{% Chris@82: \ifx\temp % Chris@82: \expandafter\nonfillindentgobble% Chris@82: \else% Chris@82: \leavevmode\nonfillindentbox% Chris@82: \fi% Chris@82: }% Chris@82: \endgroup Chris@82: \def\nonfillindentgobble#1{\nonfillindent} Chris@82: \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} Chris@82: Chris@82: % If you want all examples etc. small: @set dispenvsize small. Chris@82: % If you want even small examples the full size: @set dispenvsize nosmall. Chris@82: % This affects the following displayed environments: Chris@82: % @example, @display, @format, @lisp Chris@82: % Chris@82: \def\smallword{small} Chris@82: \def\nosmallword{nosmall} Chris@82: \let\SETdispenvsize\relax Chris@82: \def\setnormaldispenv{% Chris@82: \ifx\SETdispenvsize\smallword Chris@82: % end paragraph for sake of leading, in case document has no blank Chris@82: % line. This is redundant with what happens in \aboveenvbreak, but Chris@82: % we need to do it before changing the fonts, and it's inconvenient Chris@82: % to change the fonts afterward. Chris@82: \ifnum \lastpenalty=10000 \else \endgraf \fi Chris@82: \smallexamplefonts \rm Chris@82: \fi Chris@82: } Chris@82: \def\setsmalldispenv{% Chris@82: \ifx\SETdispenvsize\nosmallword Chris@82: \else Chris@82: \ifnum \lastpenalty=10000 \else \endgraf \fi Chris@82: \smallexamplefonts \rm Chris@82: \fi Chris@82: } Chris@82: Chris@82: % We often define two environments, @foo and @smallfoo. Chris@82: % Let's do it in one command. #1 is the env name, #2 the definition. Chris@82: \def\makedispenvdef#1#2{% Chris@82: \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% Chris@82: \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% Chris@82: \expandafter\let\csname E#1\endcsname \afterenvbreak Chris@82: \expandafter\let\csname Esmall#1\endcsname \afterenvbreak Chris@82: } Chris@82: Chris@82: % Define two environment synonyms (#1 and #2) for an environment. Chris@82: \def\maketwodispenvdef#1#2#3{% Chris@82: \makedispenvdef{#1}{#3}% Chris@82: \makedispenvdef{#2}{#3}% Chris@82: } Chris@82: % Chris@82: % @lisp: indented, narrowed, typewriter font; Chris@82: % @example: same as @lisp. Chris@82: % Chris@82: % @smallexample and @smalllisp: use smaller fonts. Chris@82: % Originally contributed by Pavel@xerox. Chris@82: % Chris@82: \maketwodispenvdef{lisp}{example}{% Chris@82: \nonfillstart Chris@82: \tt\setupmarkupstyle{example}% Chris@82: \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. Chris@82: \gobble % eat return Chris@82: } Chris@82: % @display/@smalldisplay: same as @lisp except keep current font. Chris@82: % Chris@82: \makedispenvdef{display}{% Chris@82: \nonfillstart Chris@82: \gobble Chris@82: } Chris@82: Chris@82: % @format/@smallformat: same as @display except don't narrow margins. Chris@82: % Chris@82: \makedispenvdef{format}{% Chris@82: \let\nonarrowing = t% Chris@82: \nonfillstart Chris@82: \gobble Chris@82: } Chris@82: Chris@82: % @flushleft: same as @format, but doesn't obey \SETdispenvsize. Chris@82: \envdef\flushleft{% Chris@82: \let\nonarrowing = t% Chris@82: \nonfillstart Chris@82: \gobble Chris@82: } Chris@82: \let\Eflushleft = \afterenvbreak Chris@82: Chris@82: % @flushright. Chris@82: % Chris@82: \envdef\flushright{% Chris@82: \let\nonarrowing = t% Chris@82: \nonfillstart Chris@82: \advance\leftskip by 0pt plus 1fill\relax Chris@82: \gobble Chris@82: } Chris@82: \let\Eflushright = \afterenvbreak Chris@82: Chris@82: Chris@82: % @raggedright does more-or-less normal line breaking but no right Chris@82: % justification. From plain.tex. Chris@82: \envdef\raggedright{% Chris@82: \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax Chris@82: } Chris@82: \let\Eraggedright\par Chris@82: Chris@82: \envdef\raggedleft{% Chris@82: \parindent=0pt \leftskip0pt plus2em Chris@82: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt Chris@82: \hbadness=10000 % Last line will usually be underfull, so turn off Chris@82: % badness reporting. Chris@82: } Chris@82: \let\Eraggedleft\par Chris@82: Chris@82: \envdef\raggedcenter{% Chris@82: \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em Chris@82: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt Chris@82: \hbadness=10000 % Last line will usually be underfull, so turn off Chris@82: % badness reporting. Chris@82: } Chris@82: \let\Eraggedcenter\par Chris@82: Chris@82: Chris@82: % @quotation does normal linebreaking (hence we can't use \nonfillstart) Chris@82: % and narrows the margins. We keep \parskip nonzero in general, since Chris@82: % we're doing normal filling. So, when using \aboveenvbreak and Chris@82: % \afterenvbreak, temporarily make \parskip 0. Chris@82: % Chris@82: \makedispenvdef{quotation}{\quotationstart} Chris@82: % Chris@82: \def\quotationstart{% Chris@82: \indentedblockstart % same as \indentedblock, but increase right margin too. Chris@82: \ifx\nonarrowing\relax Chris@82: \advance\rightskip by \lispnarrowing Chris@82: \fi Chris@82: \parsearg\quotationlabel Chris@82: } Chris@82: Chris@82: % We have retained a nonzero parskip for the environment, since we're Chris@82: % doing normal filling. Chris@82: % Chris@82: \def\Equotation{% Chris@82: \par Chris@82: \ifx\quotationauthor\thisisundefined\else Chris@82: % indent a bit. Chris@82: \leftline{\kern 2\leftskip \sl ---\quotationauthor}% Chris@82: \fi Chris@82: {\parskip=0pt \afterenvbreak}% Chris@82: } Chris@82: \def\Esmallquotation{\Equotation} Chris@82: Chris@82: % If we're given an argument, typeset it in bold with a colon after. Chris@82: \def\quotationlabel#1{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\empty \else Chris@82: {\bf #1: }% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @indentedblock is like @quotation, but indents only on the left and Chris@82: % has no optional argument. Chris@82: % Chris@82: \makedispenvdef{indentedblock}{\indentedblockstart} Chris@82: % Chris@82: \def\indentedblockstart{% Chris@82: {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip Chris@82: \parindent=0pt Chris@82: % Chris@82: % @cartouche defines \nonarrowing to inhibit narrowing at next level down. Chris@82: \ifx\nonarrowing\relax Chris@82: \advance\leftskip by \lispnarrowing Chris@82: \exdentamount = \lispnarrowing Chris@82: \else Chris@82: \let\nonarrowing = \relax Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Keep a nonzero parskip for the environment, since we're doing normal filling. Chris@82: % Chris@82: \def\Eindentedblock{% Chris@82: \par Chris@82: {\parskip=0pt \afterenvbreak}% Chris@82: } Chris@82: \def\Esmallindentedblock{\Eindentedblock} Chris@82: Chris@82: Chris@82: % LaTeX-like @verbatim...@end verbatim and @verb{...} Chris@82: % If we want to allow any as delimiter, Chris@82: % we need the curly braces so that makeinfo sees the @verb command, eg: Chris@82: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org Chris@82: % Chris@82: % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. Chris@82: % Chris@82: % [Knuth] p.344; only we need to do the other characters Texinfo sets Chris@82: % active too. Otherwise, they get lost as the first character on a Chris@82: % verbatim line. Chris@82: \def\dospecials{% Chris@82: \do\ \do\\\do\{\do\}\do\$\do\&% Chris@82: \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% Chris@82: \do\<\do\>\do\|\do\@\do+\do\"% Chris@82: % Don't do the quotes -- if we do, @set txicodequoteundirected and Chris@82: % @set txicodequotebacktick will not have effect on @verb and Chris@82: % @verbatim, and ?` and !` ligatures won't get disabled. Chris@82: %\do\`\do\'% Chris@82: } Chris@82: % Chris@82: % [Knuth] p. 380 Chris@82: \def\uncatcodespecials{% Chris@82: \def\do##1{\catcode`##1=\other}\dospecials} Chris@82: % Chris@82: % Setup for the @verb command. Chris@82: % Chris@82: % Eight spaces for a tab Chris@82: \begingroup Chris@82: \catcode`\^^I=\active Chris@82: \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} Chris@82: \endgroup Chris@82: % Chris@82: \def\setupverb{% Chris@82: \tt % easiest (and conventionally used) font for verbatim Chris@82: \def\par{\leavevmode\endgraf}% Chris@82: \setupmarkupstyle{verb}% Chris@82: \tabeightspaces Chris@82: % Respect line breaks, Chris@82: % print special symbols as themselves, and Chris@82: % make each space count Chris@82: % must do in this order: Chris@82: \obeylines \uncatcodespecials \sepspaces Chris@82: } Chris@82: Chris@82: % Setup for the @verbatim environment Chris@82: % Chris@82: % Real tab expansion. Chris@82: \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount Chris@82: % Chris@82: % We typeset each line of the verbatim in an \hbox, so we can handle Chris@82: % tabs. The \global is in case the verbatim line starts with an accent, Chris@82: % or some other command that starts with a begin-group. Otherwise, the Chris@82: % entire \verbbox would disappear at the corresponding end-group, before Chris@82: % it is typeset. Meanwhile, we can't have nested verbatim commands Chris@82: % (can we?), so the \global won't be overwriting itself. Chris@82: \newbox\verbbox Chris@82: \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} Chris@82: % Chris@82: \begingroup Chris@82: \catcode`\^^I=\active Chris@82: \gdef\tabexpand{% Chris@82: \catcode`\^^I=\active Chris@82: \def^^I{\leavevmode\egroup Chris@82: \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab Chris@82: \divide\dimen\verbbox by\tabw Chris@82: \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw Chris@82: \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw Chris@82: \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox Chris@82: }% Chris@82: } Chris@82: \endgroup Chris@82: Chris@82: % start the verbatim environment. Chris@82: \def\setupverbatim{% Chris@82: \let\nonarrowing = t% Chris@82: \nonfillstart Chris@82: \tt % easiest (and conventionally used) font for verbatim Chris@82: % The \leavevmode here is for blank lines. Otherwise, we would Chris@82: % never \starttabox and the \egroup would end verbatim mode. Chris@82: \def\par{\leavevmode\egroup\box\verbbox\endgraf}% Chris@82: \tabexpand Chris@82: \setupmarkupstyle{verbatim}% Chris@82: % Respect line breaks, Chris@82: % print special symbols as themselves, and Chris@82: % make each space count. Chris@82: % Must do in this order: Chris@82: \obeylines \uncatcodespecials \sepspaces Chris@82: \everypar{\starttabbox}% Chris@82: } Chris@82: Chris@82: % Do the @verb magic: verbatim text is quoted by unique Chris@82: % delimiter characters. Before first delimiter expect a Chris@82: % right brace, after last delimiter expect closing brace: Chris@82: % Chris@82: % \def\doverb'{'#1'}'{#1} Chris@82: % Chris@82: % [Knuth] p. 382; only eat outer {} Chris@82: \begingroup Chris@82: \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other Chris@82: \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] Chris@82: \endgroup Chris@82: % Chris@82: \def\verb{\begingroup\setupverb\doverb} Chris@82: % Chris@82: % Chris@82: % Do the @verbatim magic: define the macro \doverbatim so that Chris@82: % the (first) argument ends when '@end verbatim' is reached, ie: Chris@82: % Chris@82: % \def\doverbatim#1@end verbatim{#1} Chris@82: % Chris@82: % For Texinfo it's a lot easier than for LaTeX, Chris@82: % because texinfo's \verbatim doesn't stop at '\end{verbatim}': Chris@82: % we need not redefine '\', '{' and '}'. Chris@82: % Chris@82: % Inspired by LaTeX's verbatim command set [latex.ltx] Chris@82: % Chris@82: \begingroup Chris@82: \catcode`\ =\active Chris@82: \obeylines % Chris@82: % ignore everything up to the first ^^M, that's the newline at the end Chris@82: % of the @verbatim input line itself. Otherwise we get an extra blank Chris@82: % line in the output. Chris@82: \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% Chris@82: % We really want {...\end verbatim} in the body of the macro, but Chris@82: % without the active space; thus we have to use \xdef and \gobble. Chris@82: \endgroup Chris@82: % Chris@82: \envdef\verbatim{% Chris@82: \setupverbatim\doverbatim Chris@82: } Chris@82: \let\Everbatim = \afterenvbreak Chris@82: Chris@82: Chris@82: % @verbatiminclude FILE - insert text of file in verbatim environment. Chris@82: % Chris@82: \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} Chris@82: % Chris@82: \def\doverbatiminclude#1{% Chris@82: {% Chris@82: \makevalueexpandable Chris@82: \setupverbatim Chris@82: \indexnofonts % Allow `@@' and other weird things in file names. Chris@82: \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% Chris@82: \input #1 Chris@82: \afterenvbreak Chris@82: }% Chris@82: } Chris@82: Chris@82: % @copying ... @end copying. Chris@82: % Save the text away for @insertcopying later. Chris@82: % Chris@82: % We save the uninterpreted tokens, rather than creating a box. Chris@82: % Saving the text in a box would be much easier, but then all the Chris@82: % typesetting commands (@smallbook, font changes, etc.) have to be done Chris@82: % beforehand -- and a) we want @copying to be done first in the source Chris@82: % file; b) letting users define the frontmatter in as flexible order as Chris@82: % possible is very desirable. Chris@82: % Chris@82: \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} Chris@82: \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} Chris@82: % Chris@82: \def\insertcopying{% Chris@82: \begingroup Chris@82: \parindent = 0pt % paragraph indentation looks wrong on title page Chris@82: \scanexp\copyingtext Chris@82: \endgroup Chris@82: } Chris@82: Chris@82: Chris@82: \message{defuns,} Chris@82: % @defun etc. Chris@82: Chris@82: \newskip\defbodyindent \defbodyindent=.4in Chris@82: \newskip\defargsindent \defargsindent=50pt Chris@82: \newskip\deflastargmargin \deflastargmargin=18pt Chris@82: \newcount\defunpenalty Chris@82: Chris@82: % Start the processing of @deffn: Chris@82: \def\startdefun{% Chris@82: \ifnum\lastpenalty<10000 Chris@82: \medbreak Chris@82: \defunpenalty=10003 % Will keep this @deffn together with the Chris@82: % following @def command, see below. Chris@82: \else Chris@82: % If there are two @def commands in a row, we'll have a \nobreak, Chris@82: % which is there to keep the function description together with its Chris@82: % header. But if there's nothing but headers, we need to allow a Chris@82: % break somewhere. Check specifically for penalty 10002, inserted Chris@82: % by \printdefunline, instead of 10000, since the sectioning Chris@82: % commands also insert a nobreak penalty, and we don't want to allow Chris@82: % a break between a section heading and a defun. Chris@82: % Chris@82: % As a further refinement, we avoid "club" headers by signalling Chris@82: % with penalty of 10003 after the very first @deffn in the Chris@82: % sequence (see above), and penalty of 10002 after any following Chris@82: % @def command. Chris@82: \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi Chris@82: % Chris@82: % Similarly, after a section heading, do not allow a break. Chris@82: % But do insert the glue. Chris@82: \medskip % preceded by discardable penalty, so not a breakpoint Chris@82: \fi Chris@82: % Chris@82: \parindent=0in Chris@82: \advance\leftskip by \defbodyindent Chris@82: \exdentamount=\defbodyindent Chris@82: } Chris@82: Chris@82: \def\dodefunx#1{% Chris@82: % First, check whether we are in the right environment: Chris@82: \checkenv#1% Chris@82: % Chris@82: % As above, allow line break if we have multiple x headers in a row. Chris@82: % It's not a great place, though. Chris@82: \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi Chris@82: % Chris@82: % And now, it's time to reuse the body of the original defun: Chris@82: \expandafter\gobbledefun#1% Chris@82: } Chris@82: \def\gobbledefun#1\startdefun{} Chris@82: Chris@82: % \printdefunline \deffnheader{text} Chris@82: % Chris@82: \def\printdefunline#1#2{% Chris@82: \begingroup Chris@82: % call \deffnheader: Chris@82: #1#2 \endheader Chris@82: % common ending: Chris@82: \interlinepenalty = 10000 Chris@82: \advance\rightskip by 0pt plus 1fil\relax Chris@82: \endgraf Chris@82: \nobreak\vskip -\parskip Chris@82: \penalty\defunpenalty % signal to \startdefun and \dodefunx Chris@82: % Some of the @defun-type tags do not enable magic parentheses, Chris@82: % rendering the following check redundant. But we don't optimize. Chris@82: \checkparencounts Chris@82: \endgroup Chris@82: } Chris@82: Chris@82: \def\Edefun{\endgraf\medbreak} Chris@82: Chris@82: % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; Chris@82: % the only thing remaining is to define \deffnheader. Chris@82: % Chris@82: \def\makedefun#1{% Chris@82: \expandafter\let\csname E#1\endcsname = \Edefun Chris@82: \edef\temp{\noexpand\domakedefun Chris@82: \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% Chris@82: \temp Chris@82: } Chris@82: Chris@82: % \domakedefun \deffn \deffnx \deffnheader Chris@82: % Chris@82: % Define \deffn and \deffnx, without parameters. Chris@82: % \deffnheader has to be defined explicitly. Chris@82: % Chris@82: \def\domakedefun#1#2#3{% Chris@82: \envdef#1{% Chris@82: \startdefun Chris@82: \doingtypefnfalse % distinguish typed functions from all else Chris@82: \parseargusing\activeparens{\printdefunline#3}% Chris@82: }% Chris@82: \def#2{\dodefunx#1}% Chris@82: \def#3% Chris@82: } Chris@82: Chris@82: \newif\ifdoingtypefn % doing typed function? Chris@82: \newif\ifrettypeownline % typeset return type on its own line? Chris@82: Chris@82: % @deftypefnnewline on|off says whether the return type of typed functions Chris@82: % are printed on their own line. This affects @deftypefn, @deftypefun, Chris@82: % @deftypeop, and @deftypemethod. Chris@82: % Chris@82: \parseargdef\deftypefnnewline{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\onword Chris@82: \expandafter\let\csname SETtxideftypefnnl\endcsname Chris@82: = \empty Chris@82: \else\ifx\temp\offword Chris@82: \expandafter\let\csname SETtxideftypefnnl\endcsname Chris@82: = \relax Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @txideftypefnnl value `\temp', Chris@82: must be on|off}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % Untyped functions: Chris@82: Chris@82: % @deffn category name args Chris@82: \makedefun{deffn}{\deffngeneral{}} Chris@82: Chris@82: % @deffn category class name args Chris@82: \makedefun{defop}#1 {\defopon{#1\ \putwordon}} Chris@82: Chris@82: % \defopon {category on}class name args Chris@82: \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } Chris@82: Chris@82: % \deffngeneral {subind}category name args Chris@82: % Chris@82: \def\deffngeneral#1#2 #3 #4\endheader{% Chris@82: % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. Chris@82: \dosubind{fn}{\code{#3}}{#1}% Chris@82: \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% Chris@82: } Chris@82: Chris@82: % Typed functions: Chris@82: Chris@82: % @deftypefn category type name args Chris@82: \makedefun{deftypefn}{\deftypefngeneral{}} Chris@82: Chris@82: % @deftypeop category class type name args Chris@82: \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} Chris@82: Chris@82: % \deftypeopon {category on}class type name args Chris@82: \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } Chris@82: Chris@82: % \deftypefngeneral {subind}category type name args Chris@82: % Chris@82: \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% Chris@82: \dosubind{fn}{\code{#4}}{#1}% Chris@82: \doingtypefntrue Chris@82: \defname{#2}{#3}{#4}\defunargs{#5\unskip}% Chris@82: } Chris@82: Chris@82: % Typed variables: Chris@82: Chris@82: % @deftypevr category type var args Chris@82: \makedefun{deftypevr}{\deftypecvgeneral{}} Chris@82: Chris@82: % @deftypecv category class type var args Chris@82: \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} Chris@82: Chris@82: % \deftypecvof {category of}class type var args Chris@82: \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } Chris@82: Chris@82: % \deftypecvgeneral {subind}category type var args Chris@82: % Chris@82: \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% Chris@82: \dosubind{vr}{\code{#4}}{#1}% Chris@82: \defname{#2}{#3}{#4}\defunargs{#5\unskip}% Chris@82: } Chris@82: Chris@82: % Untyped variables: Chris@82: Chris@82: % @defvr category var args Chris@82: \makedefun{defvr}#1 {\deftypevrheader{#1} {} } Chris@82: Chris@82: % @defcv category class var args Chris@82: \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} Chris@82: Chris@82: % \defcvof {category of}class var args Chris@82: \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } Chris@82: Chris@82: % Types: Chris@82: Chris@82: % @deftp category name args Chris@82: \makedefun{deftp}#1 #2 #3\endheader{% Chris@82: \doind{tp}{\code{#2}}% Chris@82: \defname{#1}{}{#2}\defunargs{#3\unskip}% Chris@82: } Chris@82: Chris@82: % Remaining @defun-like shortcuts: Chris@82: \makedefun{defun}{\deffnheader{\putwordDeffunc} } Chris@82: \makedefun{defmac}{\deffnheader{\putwordDefmac} } Chris@82: \makedefun{defspec}{\deffnheader{\putwordDefspec} } Chris@82: \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } Chris@82: \makedefun{defvar}{\defvrheader{\putwordDefvar} } Chris@82: \makedefun{defopt}{\defvrheader{\putwordDefopt} } Chris@82: \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } Chris@82: \makedefun{defmethod}{\defopon\putwordMethodon} Chris@82: \makedefun{deftypemethod}{\deftypeopon\putwordMethodon} Chris@82: \makedefun{defivar}{\defcvof\putwordInstanceVariableof} Chris@82: \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} Chris@82: Chris@82: % \defname, which formats the name of the @def (not the args). Chris@82: % #1 is the category, such as "Function". Chris@82: % #2 is the return type, if any. Chris@82: % #3 is the function name. Chris@82: % Chris@82: % We are followed by (but not passed) the arguments, if any. Chris@82: % Chris@82: \def\defname#1#2#3{% Chris@82: \par Chris@82: % Get the values of \leftskip and \rightskip as they were outside the @def... Chris@82: \advance\leftskip by -\defbodyindent Chris@82: % Chris@82: % Determine if we are typesetting the return type of a typed function Chris@82: % on a line by itself. Chris@82: \rettypeownlinefalse Chris@82: \ifdoingtypefn % doing a typed function specifically? Chris@82: % then check user option for putting return type on its own line: Chris@82: \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else Chris@82: \rettypeownlinetrue Chris@82: \fi Chris@82: \fi Chris@82: % Chris@82: % How we'll format the category name. Putting it in brackets helps Chris@82: % distinguish it from the body text that may end up on the next line Chris@82: % just below it. Chris@82: \def\temp{#1}% Chris@82: \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} Chris@82: % Chris@82: % Figure out line sizes for the paragraph shape. We'll always have at Chris@82: % least two. Chris@82: \tempnum = 2 Chris@82: % Chris@82: % The first line needs space for \box0; but if \rightskip is nonzero, Chris@82: % we need only space for the part of \box0 which exceeds it: Chris@82: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip Chris@82: % Chris@82: % If doing a return type on its own line, we'll have another line. Chris@82: \ifrettypeownline Chris@82: \advance\tempnum by 1 Chris@82: \def\maybeshapeline{0in \hsize}% Chris@82: \else Chris@82: \def\maybeshapeline{}% Chris@82: \fi Chris@82: % Chris@82: % The continuations: Chris@82: \dimen2=\hsize \advance\dimen2 by -\defargsindent Chris@82: % Chris@82: % The final paragraph shape: Chris@82: \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 Chris@82: % Chris@82: % Put the category name at the right margin. Chris@82: \noindent Chris@82: \hbox to 0pt{% Chris@82: \hfil\box0 \kern-\hsize Chris@82: % \hsize has to be shortened this way: Chris@82: \kern\leftskip Chris@82: % Intentionally do not respect \rightskip, since we need the space. Chris@82: }% Chris@82: % Chris@82: % Allow all lines to be underfull without complaint: Chris@82: \tolerance=10000 \hbadness=10000 Chris@82: \exdentamount=\defbodyindent Chris@82: {% Chris@82: % defun fonts. We use typewriter by default (used to be bold) because: Chris@82: % . we're printing identifiers, they should be in tt in principle. Chris@82: % . in languages with many accents, such as Czech or French, it's Chris@82: % common to leave accents off identifiers. The result looks ok in Chris@82: % tt, but exceedingly strange in rm. Chris@82: % . we don't want -- and --- to be treated as ligatures. Chris@82: % . this still does not fix the ?` and !` ligatures, but so far no Chris@82: % one has made identifiers using them :). Chris@82: \df \tt Chris@82: \def\temp{#2}% text of the return type Chris@82: \ifx\temp\empty\else Chris@82: \tclose{\temp}% typeset the return type Chris@82: \ifrettypeownline Chris@82: % put return type on its own line; prohibit line break following: Chris@82: \hfil\vadjust{\nobreak}\break Chris@82: \else Chris@82: \space % type on same line, so just followed by a space Chris@82: \fi Chris@82: \fi % no return type Chris@82: #3% output function name Chris@82: }% Chris@82: {\rm\enskip}% hskip 0.5 em of \tenrm Chris@82: % Chris@82: \boldbrax Chris@82: % arguments will be output next, if any. Chris@82: } Chris@82: Chris@82: % Print arguments in slanted roman (not ttsl), inconsistently with using Chris@82: % tt for the name. This is because literal text is sometimes needed in Chris@82: % the argument list (groff manual), and ttsl and tt are not very Chris@82: % distinguishable. Prevent hyphenation at `-' chars. Chris@82: % Chris@82: \def\defunargs#1{% Chris@82: % use sl by default (not ttsl), Chris@82: % tt for the names. Chris@82: \df \sl \hyphenchar\font=0 Chris@82: % Chris@82: % On the other hand, if an argument has two dashes (for instance), we Chris@82: % want a way to get ttsl. We used to recommend @var for that, so Chris@82: % leave the code in, but it's strange for @var to lead to typewriter. Chris@82: % Nowadays we recommend @code, since the difference between a ttsl hyphen Chris@82: % and a tt hyphen is pretty tiny. @code also disables ?` !`. Chris@82: \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% Chris@82: #1% Chris@82: \sl\hyphenchar\font=45 Chris@82: } Chris@82: Chris@82: % We want ()&[] to print specially on the defun line. Chris@82: % Chris@82: \def\activeparens{% Chris@82: \catcode`\(=\active \catcode`\)=\active Chris@82: \catcode`\[=\active \catcode`\]=\active Chris@82: \catcode`\&=\active Chris@82: } Chris@82: Chris@82: % Make control sequences which act like normal parenthesis chars. Chris@82: \let\lparen = ( \let\rparen = ) Chris@82: Chris@82: % Be sure that we always have a definition for `(', etc. For example, Chris@82: % if the fn name has parens in it, \boldbrax will not be in effect yet, Chris@82: % so TeX would otherwise complain about undefined control sequence. Chris@82: { Chris@82: \activeparens Chris@82: \global\let(=\lparen \global\let)=\rparen Chris@82: \global\let[=\lbrack \global\let]=\rbrack Chris@82: \global\let& = \& Chris@82: Chris@82: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} Chris@82: \gdef\magicamp{\let&=\amprm} Chris@82: } Chris@82: Chris@82: \newcount\parencount Chris@82: Chris@82: % If we encounter &foo, then turn on ()-hacking afterwards Chris@82: \newif\ifampseen Chris@82: \def\amprm#1 {\ampseentrue{\bf\ }} Chris@82: Chris@82: \def\parenfont{% Chris@82: \ifampseen Chris@82: % At the first level, print parens in roman, Chris@82: % otherwise use the default font. Chris@82: \ifnum \parencount=1 \rm \fi Chris@82: \else Chris@82: % The \sf parens (in \boldbrax) actually are a little bolder than Chris@82: % the contained text. This is especially needed for [ and ] . Chris@82: \sf Chris@82: \fi Chris@82: } Chris@82: \def\infirstlevel#1{% Chris@82: \ifampseen Chris@82: \ifnum\parencount=1 Chris@82: #1% Chris@82: \fi Chris@82: \fi Chris@82: } Chris@82: \def\bfafterword#1 {#1 \bf} Chris@82: Chris@82: \def\opnr{% Chris@82: \global\advance\parencount by 1 Chris@82: {\parenfont(}% Chris@82: \infirstlevel \bfafterword Chris@82: } Chris@82: \def\clnr{% Chris@82: {\parenfont)}% Chris@82: \infirstlevel \sl Chris@82: \global\advance\parencount by -1 Chris@82: } Chris@82: Chris@82: \newcount\brackcount Chris@82: \def\lbrb{% Chris@82: \global\advance\brackcount by 1 Chris@82: {\bf[}% Chris@82: } Chris@82: \def\rbrb{% Chris@82: {\bf]}% Chris@82: \global\advance\brackcount by -1 Chris@82: } Chris@82: Chris@82: \def\checkparencounts{% Chris@82: \ifnum\parencount=0 \else \badparencount \fi Chris@82: \ifnum\brackcount=0 \else \badbrackcount \fi Chris@82: } Chris@82: % these should not use \errmessage; the glibc manual, at least, actually Chris@82: % has such constructs (when documenting function pointers). Chris@82: \def\badparencount{% Chris@82: \message{Warning: unbalanced parentheses in @def...}% Chris@82: \global\parencount=0 Chris@82: } Chris@82: \def\badbrackcount{% Chris@82: \message{Warning: unbalanced square brackets in @def...}% Chris@82: \global\brackcount=0 Chris@82: } Chris@82: Chris@82: Chris@82: \message{macros,} Chris@82: % @macro. Chris@82: Chris@82: % To do this right we need a feature of e-TeX, \scantokens, Chris@82: % which we arrange to emulate with a temporary file in ordinary TeX. Chris@82: \ifx\eTeXversion\thisisundefined Chris@82: \newwrite\macscribble Chris@82: \def\scantokens#1{% Chris@82: \toks0={#1}% Chris@82: \immediate\openout\macscribble=\jobname.tmp Chris@82: \immediate\write\macscribble{\the\toks0}% Chris@82: \immediate\closeout\macscribble Chris@82: \input \jobname.tmp Chris@82: } Chris@82: \fi Chris@82: Chris@82: \def\scanmacro#1{\begingroup Chris@82: \newlinechar`\^^M Chris@82: \let\xeatspaces\eatspaces Chris@82: % Chris@82: % Undo catcode changes of \startcontents and \doprintindex Chris@82: % When called from @insertcopying or (short)caption, we need active Chris@82: % backslash to get it printed correctly. Previously, we had Chris@82: % \catcode`\\=\other instead. We'll see whether a problem appears Chris@82: % with macro expansion. --kasal, 19aug04 Chris@82: \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ Chris@82: % Chris@82: % ... and for \example: Chris@82: \spaceisspace Chris@82: % Chris@82: % The \empty here causes a following catcode 5 newline to be eaten as Chris@82: % part of reading whitespace after a control sequence. It does not Chris@82: % eat a catcode 13 newline. There's no good way to handle the two Chris@82: % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX Chris@82: % would then have different behavior). See the Macro Details node in Chris@82: % the manual for the workaround we recommend for macros and Chris@82: % line-oriented commands. Chris@82: % Chris@82: \scantokens{#1\empty}% Chris@82: \endgroup} Chris@82: Chris@82: \def\scanexp#1{% Chris@82: \edef\temp{\noexpand\scanmacro{#1}}% Chris@82: \temp Chris@82: } Chris@82: Chris@82: \newcount\paramno % Count of parameters Chris@82: \newtoks\macname % Macro name Chris@82: \newif\ifrecursive % Is it recursive? Chris@82: Chris@82: % List of all defined macros in the form Chris@82: % \definedummyword\macro1\definedummyword\macro2... Chris@82: % Currently is also contains all @aliases; the list can be split Chris@82: % if there is a need. Chris@82: \def\macrolist{} Chris@82: Chris@82: % Add the macro to \macrolist Chris@82: \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} Chris@82: \def\addtomacrolistxxx#1{% Chris@82: \toks0 = \expandafter{\macrolist\definedummyword#1}% Chris@82: \xdef\macrolist{\the\toks0}% Chris@82: } Chris@82: Chris@82: % Utility routines. Chris@82: % This does \let #1 = #2, with \csnames; that is, Chris@82: % \let \csname#1\endcsname = \csname#2\endcsname Chris@82: % (except of course we have to play expansion games). Chris@82: % Chris@82: \def\cslet#1#2{% Chris@82: \expandafter\let Chris@82: \csname#1\expandafter\endcsname Chris@82: \csname#2\endcsname Chris@82: } Chris@82: Chris@82: % Trim leading and trailing spaces off a string. Chris@82: % Concepts from aro-bend problem 15 (see CTAN). Chris@82: {\catcode`\@=11 Chris@82: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} Chris@82: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} Chris@82: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} Chris@82: \def\unbrace#1{#1} Chris@82: \unbrace{\gdef\trim@@@ #1 } #2@{#1} Chris@82: } Chris@82: Chris@82: % Trim a single trailing ^^M off a string. Chris@82: {\catcode`\^^M=\other \catcode`\Q=3% Chris@82: \gdef\eatcr #1{\eatcra #1Q^^MQ}% Chris@82: \gdef\eatcra#1^^MQ{\eatcrb#1Q}% Chris@82: \gdef\eatcrb#1Q#2Q{#1}% Chris@82: } Chris@82: Chris@82: % Macro bodies are absorbed as an argument in a context where Chris@82: % all characters are catcode 10, 11 or 12, except \ which is active Chris@82: % (as in normal texinfo). It is necessary to change the definition of \ Chris@82: % to recognize macro arguments; this is the job of \mbodybackslash. Chris@82: % Chris@82: % Non-ASCII encodings make 8-bit characters active, so un-activate Chris@82: % them to avoid their expansion. Must do this non-globally, to Chris@82: % confine the change to the current group. Chris@82: % Chris@82: % It's necessary to have hard CRs when the macro is executed. This is Chris@82: % done by making ^^M (\endlinechar) catcode 12 when reading the macro Chris@82: % body, and then making it the \newlinechar in \scanmacro. Chris@82: % Chris@82: \def\scanctxt{% used as subroutine Chris@82: \catcode`\"=\other Chris@82: \catcode`\+=\other Chris@82: \catcode`\<=\other Chris@82: \catcode`\>=\other Chris@82: \catcode`\@=\other Chris@82: \catcode`\^=\other Chris@82: \catcode`\_=\other Chris@82: \catcode`\|=\other Chris@82: \catcode`\~=\other Chris@82: \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi Chris@82: } Chris@82: Chris@82: \def\scanargctxt{% used for copying and captions, not macros. Chris@82: \scanctxt Chris@82: \catcode`\\=\other Chris@82: \catcode`\^^M=\other Chris@82: } Chris@82: Chris@82: \def\macrobodyctxt{% used for @macro definitions Chris@82: \scanctxt Chris@82: \catcode`\{=\other Chris@82: \catcode`\}=\other Chris@82: \catcode`\^^M=\other Chris@82: \usembodybackslash Chris@82: } Chris@82: Chris@82: \def\macroargctxt{% used when scanning invocations Chris@82: \scanctxt Chris@82: \catcode`\\=0 Chris@82: } Chris@82: % why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" Chris@82: % for the single characters \ { }. Thus, we end up with the "commands" Chris@82: % that would be written @\ @{ @} in a Texinfo document. Chris@82: % Chris@82: % We already have @{ and @}. For @\, we define it here, and only for Chris@82: % this purpose, to produce a typewriter backslash (so, the @\ that we Chris@82: % define for @math can't be used with @macro calls): Chris@82: % Chris@82: \def\\{\normalbackslash}% Chris@82: % Chris@82: % We would like to do this for \, too, since that is what makeinfo does. Chris@82: % But it is not possible, because Texinfo already has a command @, for a Chris@82: % cedilla accent. Documents must use @comma{} instead. Chris@82: % Chris@82: % \anythingelse will almost certainly be an error of some kind. Chris@82: Chris@82: Chris@82: % \mbodybackslash is the definition of \ in @macro bodies. Chris@82: % It maps \foo\ => \csname macarg.foo\endcsname => #N Chris@82: % where N is the macro parameter number. Chris@82: % We define \csname macarg.\endcsname to be \realbackslash, so Chris@82: % \\ in macro replacement text gets you a backslash. Chris@82: % Chris@82: {\catcode`@=0 @catcode`@\=@active Chris@82: @gdef@usembodybackslash{@let\=@mbodybackslash} Chris@82: @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} Chris@82: } Chris@82: \expandafter\def\csname macarg.\endcsname{\realbackslash} Chris@82: Chris@82: \def\margbackslash#1{\char`\#1 } Chris@82: Chris@82: \def\macro{\recursivefalse\parsearg\macroxxx} Chris@82: \def\rmacro{\recursivetrue\parsearg\macroxxx} Chris@82: Chris@82: \def\macroxxx#1{% Chris@82: \getargs{#1}% now \macname is the macname and \argl the arglist Chris@82: \ifx\argl\empty % no arguments Chris@82: \paramno=0\relax Chris@82: \else Chris@82: \expandafter\parsemargdef \argl;% Chris@82: \if\paramno>256\relax Chris@82: \ifx\eTeXversion\thisisundefined Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} Chris@82: \fi Chris@82: \fi Chris@82: \fi Chris@82: \if1\csname ismacro.\the\macname\endcsname Chris@82: \message{Warning: redefining \the\macname}% Chris@82: \else Chris@82: \expandafter\ifx\csname \the\macname\endcsname \relax Chris@82: \else \errmessage{Macro name \the\macname\space already defined}\fi Chris@82: \global\cslet{macsave.\the\macname}{\the\macname}% Chris@82: \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% Chris@82: \addtomacrolist{\the\macname}% Chris@82: \fi Chris@82: \begingroup \macrobodyctxt Chris@82: \ifrecursive \expandafter\parsermacbody Chris@82: \else \expandafter\parsemacbody Chris@82: \fi} Chris@82: Chris@82: \parseargdef\unmacro{% Chris@82: \if1\csname ismacro.#1\endcsname Chris@82: \global\cslet{#1}{macsave.#1}% Chris@82: \global\expandafter\let \csname ismacro.#1\endcsname=0% Chris@82: % Remove the macro name from \macrolist: Chris@82: \begingroup Chris@82: \expandafter\let\csname#1\endcsname \relax Chris@82: \let\definedummyword\unmacrodo Chris@82: \xdef\macrolist{\macrolist}% Chris@82: \endgroup Chris@82: \else Chris@82: \errmessage{Macro #1 not defined}% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Called by \do from \dounmacro on each macro. The idea is to omit any Chris@82: % macro definitions that have been changed to \relax. Chris@82: % Chris@82: \def\unmacrodo#1{% Chris@82: \ifx #1\relax Chris@82: % remove this Chris@82: \else Chris@82: \noexpand\definedummyword \noexpand#1% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % This makes use of the obscure feature that if the last token of a Chris@82: % is #, then the preceding argument is delimited by Chris@82: % an opening brace, and that opening brace is not consumed. Chris@82: \def\getargs#1{\getargsxxx#1{}} Chris@82: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} Chris@82: \def\getmacname#1 #2\relax{\macname={#1}} Chris@82: \def\getmacargs#1{\def\argl{#1}} Chris@82: Chris@82: % For macro processing make @ a letter so that we can make Texinfo private macro names. Chris@82: \edef\texiatcatcode{\the\catcode`\@} Chris@82: \catcode `@=11\relax Chris@82: Chris@82: % Parse the optional {params} list. Set up \paramno and \paramlist Chris@82: % so \defmacro knows what to do. Define \macarg.BLAH for each BLAH Chris@82: % in the params list to some hook where the argument si to be expanded. If Chris@82: % there are less than 10 arguments that hook is to be replaced by ##N where N Chris@82: % is the position in that list, that is to say the macro arguments are to be Chris@82: % defined `a la TeX in the macro body. Chris@82: % Chris@82: % That gets used by \mbodybackslash (above). Chris@82: % Chris@82: % We need to get `macro parameter char #' into several definitions. Chris@82: % The technique used is stolen from LaTeX: let \hash be something Chris@82: % unexpandable, insert that wherever you need a #, and then redefine Chris@82: % it to # just before using the token list produced. Chris@82: % Chris@82: % The same technique is used to protect \eatspaces till just before Chris@82: % the macro is used. Chris@82: % Chris@82: % If there are 10 or more arguments, a different technique is used, where the Chris@82: % hook remains in the body, and when macro is to be expanded the body is Chris@82: % processed again to replace the arguments. Chris@82: % Chris@82: % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the Chris@82: % argument N value and then \edef the body (nothing else will expand because of Chris@82: % the catcode regime underwhich the body was input). Chris@82: % Chris@82: % If you compile with TeX (not eTeX), and you have macros with 10 or more Chris@82: % arguments, you need that no macro has more than 256 arguments, otherwise an Chris@82: % error is produced. Chris@82: \def\parsemargdef#1;{% Chris@82: \paramno=0\def\paramlist{}% Chris@82: \let\hash\relax Chris@82: \let\xeatspaces\relax Chris@82: \parsemargdefxxx#1,;,% Chris@82: % In case that there are 10 or more arguments we parse again the arguments Chris@82: % list to set new definitions for the \macarg.BLAH macros corresponding to Chris@82: % each BLAH argument. It was anyhow needed to parse already once this list Chris@82: % in order to count the arguments, and as macros with at most 9 arguments Chris@82: % are by far more frequent than macro with 10 or more arguments, defining Chris@82: % twice the \macarg.BLAH macros does not cost too much processing power. Chris@82: \ifnum\paramno<10\relax\else Chris@82: \paramno0\relax Chris@82: \parsemmanyargdef@@#1,;,% 10 or more arguments Chris@82: \fi Chris@82: } Chris@82: \def\parsemargdefxxx#1,{% Chris@82: \if#1;\let\next=\relax Chris@82: \else \let\next=\parsemargdefxxx Chris@82: \advance\paramno by 1 Chris@82: \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname Chris@82: {\xeatspaces{\hash\the\paramno}}% Chris@82: \edef\paramlist{\paramlist\hash\the\paramno,}% Chris@82: \fi\next} Chris@82: Chris@82: \def\parsemmanyargdef@@#1,{% Chris@82: \if#1;\let\next=\relax Chris@82: \else Chris@82: \let\next=\parsemmanyargdef@@ Chris@82: \edef\tempb{\eatspaces{#1}}% Chris@82: \expandafter\def\expandafter\tempa Chris@82: \expandafter{\csname macarg.\tempb\endcsname}% Chris@82: % Note that we need some extra \noexpand\noexpand, this is because we Chris@82: % don't want \the to be expanded in the \parsermacbody as it uses an Chris@82: % \xdef . Chris@82: \expandafter\edef\tempa Chris@82: {\noexpand\noexpand\noexpand\the\toks\the\paramno}% Chris@82: \advance\paramno by 1\relax Chris@82: \fi\next} Chris@82: Chris@82: % These two commands read recursive and nonrecursive macro bodies. Chris@82: % (They're different since rec and nonrec macros end differently.) Chris@82: % Chris@82: Chris@82: \catcode `\@\texiatcatcode Chris@82: \long\def\parsemacbody#1@end macro% Chris@82: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% Chris@82: \long\def\parsermacbody#1@end rmacro% Chris@82: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% Chris@82: \catcode `\@=11\relax Chris@82: Chris@82: \let\endargs@\relax Chris@82: \let\nil@\relax Chris@82: \def\nilm@{\nil@}% Chris@82: \long\def\nillm@{\nil@}% Chris@82: Chris@82: % This macro is expanded during the Texinfo macro expansion, not during its Chris@82: % definition. It gets all the arguments values and assigns them to macros Chris@82: % macarg.ARGNAME Chris@82: % Chris@82: % #1 is the macro name Chris@82: % #2 is the list of argument names Chris@82: % #3 is the list of argument values Chris@82: \def\getargvals@#1#2#3{% Chris@82: \def\macargdeflist@{}% Chris@82: \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. Chris@82: \def\paramlist{#2,\nil@}% Chris@82: \def\macroname{#1}% Chris@82: \begingroup Chris@82: \macroargctxt Chris@82: \def\argvaluelist{#3,\nil@}% Chris@82: \def\@tempa{#3}% Chris@82: \ifx\@tempa\empty Chris@82: \setemptyargvalues@ Chris@82: \else Chris@82: \getargvals@@ Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Chris@82: \def\getargvals@@{% Chris@82: \ifx\paramlist\nilm@ Chris@82: % Some sanity check needed here that \argvaluelist is also empty. Chris@82: \ifx\argvaluelist\nillm@ Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Too many arguments in macro `\macroname'!}% Chris@82: \fi Chris@82: \let\next\macargexpandinbody@ Chris@82: \else Chris@82: \ifx\argvaluelist\nillm@ Chris@82: % No more arguments values passed to macro. Set remaining named-arg Chris@82: % macros to empty. Chris@82: \let\next\setemptyargvalues@ Chris@82: \else Chris@82: % pop current arg name into \@tempb Chris@82: \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% Chris@82: \expandafter\@tempa\expandafter{\paramlist}% Chris@82: % pop current argument value into \@tempc Chris@82: \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% Chris@82: \expandafter\@tempa\expandafter{\argvaluelist}% Chris@82: % Here \@tempb is the current arg name and \@tempc is the current arg value. Chris@82: % First place the new argument macro definition into \@tempd Chris@82: \expandafter\macname\expandafter{\@tempc}% Chris@82: \expandafter\let\csname macarg.\@tempb\endcsname\relax Chris@82: \expandafter\def\expandafter\@tempe\expandafter{% Chris@82: \csname macarg.\@tempb\endcsname}% Chris@82: \edef\@tempd{\long\def\@tempe{\the\macname}}% Chris@82: \push@\@tempd\macargdeflist@ Chris@82: \let\next\getargvals@@ Chris@82: \fi Chris@82: \fi Chris@82: \next Chris@82: } Chris@82: Chris@82: \def\push@#1#2{% Chris@82: \expandafter\expandafter\expandafter\def Chris@82: \expandafter\expandafter\expandafter#2% Chris@82: \expandafter\expandafter\expandafter{% Chris@82: \expandafter#1#2}% Chris@82: } Chris@82: Chris@82: % Replace arguments by their values in the macro body, and place the result Chris@82: % in macro \@tempa Chris@82: \def\macvalstoargs@{% Chris@82: % To do this we use the property that token registers that are \the'ed Chris@82: % within an \edef expand only once. So we are going to place all argument Chris@82: % values into respective token registers. Chris@82: % Chris@82: % First we save the token context, and initialize argument numbering. Chris@82: \begingroup Chris@82: \paramno0\relax Chris@82: % Then, for each argument number #N, we place the corresponding argument Chris@82: % value into a new token list register \toks#N Chris@82: \expandafter\putargsintokens@\saveparamlist@,;,% Chris@82: % Then, we expand the body so that argument are replaced by their Chris@82: % values. The trick for values not to be expanded themselves is that they Chris@82: % are within tokens and that tokens expand only once in an \edef . Chris@82: \edef\@tempc{\csname mac.\macroname .body\endcsname}% Chris@82: % Now we restore the token stack pointer to free the token list registers Chris@82: % which we have used, but we make sure that expanded body is saved after Chris@82: % group. Chris@82: \expandafter Chris@82: \endgroup Chris@82: \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% Chris@82: } Chris@82: Chris@82: \def\macargexpandinbody@{% Chris@82: %% Define the named-macro outside of this group and then close this group. Chris@82: \expandafter Chris@82: \endgroup Chris@82: \macargdeflist@ Chris@82: % First the replace in body the macro arguments by their values, the result Chris@82: % is in \@tempa . Chris@82: \macvalstoargs@ Chris@82: % Then we point at the \norecurse or \gobble (for recursive) macro value Chris@82: % with \@tempb . Chris@82: \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname Chris@82: % Depending on whether it is recursive or not, we need some tailing Chris@82: % \egroup . Chris@82: \ifx\@tempb\gobble Chris@82: \let\@tempc\relax Chris@82: \else Chris@82: \let\@tempc\egroup Chris@82: \fi Chris@82: % And now we do the real job: Chris@82: \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% Chris@82: \@tempd Chris@82: } Chris@82: Chris@82: \def\putargsintokens@#1,{% Chris@82: \if#1;\let\next\relax Chris@82: \else Chris@82: \let\next\putargsintokens@ Chris@82: % First we allocate the new token list register, and give it a temporary Chris@82: % alias \@tempb . Chris@82: \toksdef\@tempb\the\paramno Chris@82: % Then we place the argument value into that token list register. Chris@82: \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname Chris@82: \expandafter\@tempb\expandafter{\@tempa}% Chris@82: \advance\paramno by 1\relax Chris@82: \fi Chris@82: \next Chris@82: } Chris@82: Chris@82: % Save the token stack pointer into macro #1 Chris@82: \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} Chris@82: % Restore the token stack pointer from number in macro #1 Chris@82: \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} Chris@82: % newtoks that can be used non \outer . Chris@82: \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} Chris@82: Chris@82: % Tailing missing arguments are set to empty Chris@82: \def\setemptyargvalues@{% Chris@82: \ifx\paramlist\nilm@ Chris@82: \let\next\macargexpandinbody@ Chris@82: \else Chris@82: \expandafter\setemptyargvaluesparser@\paramlist\endargs@ Chris@82: \let\next\setemptyargvalues@ Chris@82: \fi Chris@82: \next Chris@82: } Chris@82: Chris@82: \def\setemptyargvaluesparser@#1,#2\endargs@{% Chris@82: \expandafter\def\expandafter\@tempa\expandafter{% Chris@82: \expandafter\def\csname macarg.#1\endcsname{}}% Chris@82: \push@\@tempa\macargdeflist@ Chris@82: \def\paramlist{#2}% Chris@82: } Chris@82: Chris@82: % #1 is the element target macro Chris@82: % #2 is the list macro Chris@82: % #3,#4\endargs@ is the list value Chris@82: \def\pop@#1#2#3,#4\endargs@{% Chris@82: \def#1{#3}% Chris@82: \def#2{#4}% Chris@82: } Chris@82: \long\def\longpop@#1#2#3,#4\endargs@{% Chris@82: \long\def#1{#3}% Chris@82: \long\def#2{#4}% Chris@82: } Chris@82: Chris@82: % This defines a Texinfo @macro. There are eight cases: recursive and Chris@82: % nonrecursive macros of zero, one, up to nine, and many arguments. Chris@82: % Much magic with \expandafter here. Chris@82: % \xdef is used so that macro definitions will survive the file Chris@82: % they're defined in; @include reads the file inside a group. Chris@82: % Chris@82: \def\defmacro{% Chris@82: \let\hash=##% convert placeholders to macro parameter chars Chris@82: \ifrecursive Chris@82: \ifcase\paramno Chris@82: % 0 Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \noexpand\scanmacro{\temp}}% Chris@82: \or % 1 Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \bgroup\noexpand\macroargctxt Chris@82: \noexpand\braceorline Chris@82: \expandafter\noexpand\csname\the\macname xxx\endcsname}% Chris@82: \expandafter\xdef\csname\the\macname xxx\endcsname##1{% Chris@82: \egroup\noexpand\scanmacro{\temp}}% Chris@82: \else Chris@82: \ifnum\paramno<10\relax % at most 9 Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \bgroup\noexpand\macroargctxt Chris@82: \noexpand\csname\the\macname xx\endcsname}% Chris@82: \expandafter\xdef\csname\the\macname xx\endcsname##1{% Chris@82: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% Chris@82: \expandafter\expandafter Chris@82: \expandafter\xdef Chris@82: \expandafter\expandafter Chris@82: \csname\the\macname xxx\endcsname Chris@82: \paramlist{\egroup\noexpand\scanmacro{\temp}}% Chris@82: \else % 10 or more Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \noexpand\getargvals@{\the\macname}{\argl}% Chris@82: }% Chris@82: \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp Chris@82: \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble Chris@82: \fi Chris@82: \fi Chris@82: \else Chris@82: \ifcase\paramno Chris@82: % 0 Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \noexpand\norecurse{\the\macname}% Chris@82: \noexpand\scanmacro{\temp}\egroup}% Chris@82: \or % 1 Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \bgroup\noexpand\macroargctxt Chris@82: \noexpand\braceorline Chris@82: \expandafter\noexpand\csname\the\macname xxx\endcsname}% Chris@82: \expandafter\xdef\csname\the\macname xxx\endcsname##1{% Chris@82: \egroup Chris@82: \noexpand\norecurse{\the\macname}% Chris@82: \noexpand\scanmacro{\temp}\egroup}% Chris@82: \else % at most 9 Chris@82: \ifnum\paramno<10\relax Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \bgroup\noexpand\macroargctxt Chris@82: \expandafter\noexpand\csname\the\macname xx\endcsname}% Chris@82: \expandafter\xdef\csname\the\macname xx\endcsname##1{% Chris@82: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% Chris@82: \expandafter\expandafter Chris@82: \expandafter\xdef Chris@82: \expandafter\expandafter Chris@82: \csname\the\macname xxx\endcsname Chris@82: \paramlist{% Chris@82: \egroup Chris@82: \noexpand\norecurse{\the\macname}% Chris@82: \noexpand\scanmacro{\temp}\egroup}% Chris@82: \else % 10 or more: Chris@82: \expandafter\xdef\csname\the\macname\endcsname{% Chris@82: \noexpand\getargvals@{\the\macname}{\argl}% Chris@82: }% Chris@82: \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp Chris@82: \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse Chris@82: \fi Chris@82: \fi Chris@82: \fi} Chris@82: Chris@82: \catcode `\@\texiatcatcode\relax Chris@82: Chris@82: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} Chris@82: Chris@82: % \braceorline decides whether the next nonwhitespace character is a Chris@82: % {. If so it reads up to the closing }, if not, it reads the whole Chris@82: % line. Whatever was read is then fed to the next control sequence Chris@82: % as an argument (by \parsebrace or \parsearg). Chris@82: % Chris@82: \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} Chris@82: \def\braceorlinexxx{% Chris@82: \ifx\nchar\bgroup\else Chris@82: \expandafter\parsearg Chris@82: \fi \macnamexxx} Chris@82: Chris@82: Chris@82: % @alias. Chris@82: % We need some trickery to remove the optional spaces around the equal Chris@82: % sign. Make them active and then expand them all to nothing. Chris@82: % Chris@82: \def\alias{\parseargusing\obeyspaces\aliasxxx} Chris@82: \def\aliasxxx #1{\aliasyyy#1\relax} Chris@82: \def\aliasyyy #1=#2\relax{% Chris@82: {% Chris@82: \expandafter\let\obeyedspace=\empty Chris@82: \addtomacrolist{#1}% Chris@82: \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% Chris@82: }% Chris@82: \next Chris@82: } Chris@82: Chris@82: Chris@82: \message{cross references,} Chris@82: Chris@82: \newwrite\auxfile Chris@82: \newif\ifhavexrefs % True if xref values are known. Chris@82: \newif\ifwarnedxrefs % True if we warned once that they aren't known. Chris@82: Chris@82: % @inforef is relatively simple. Chris@82: \def\inforef #1{\inforefzzz #1,,,,**} Chris@82: \def\inforefzzz #1,#2,#3,#4**{% Chris@82: \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, Chris@82: node \samp{\ignorespaces#1{}}} Chris@82: Chris@82: % @node's only job in TeX is to define \lastnode, which is used in Chris@82: % cross-references. The @node line might or might not have commas, and Chris@82: % might or might not have spaces before the first comma, like: Chris@82: % @node foo , bar , ... Chris@82: % We don't want such trailing spaces in the node name. Chris@82: % Chris@82: \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} Chris@82: % Chris@82: % also remove a trailing comma, in case of something like this: Chris@82: % @node Help-Cross, , , Cross-refs Chris@82: \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} Chris@82: \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} Chris@82: Chris@82: \let\nwnode=\node Chris@82: \let\lastnode=\empty Chris@82: Chris@82: % Write a cross-reference definition for the current node. #1 is the Chris@82: % type (Ynumbered, Yappendix, Ynothing). Chris@82: % Chris@82: \def\donoderef#1{% Chris@82: \ifx\lastnode\empty\else Chris@82: \setref{\lastnode}{#1}% Chris@82: \global\let\lastnode=\empty Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @anchor{NAME} -- define xref target at arbitrary point. Chris@82: % Chris@82: \newcount\savesfregister Chris@82: % Chris@82: \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} Chris@82: \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} Chris@82: \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} Chris@82: Chris@82: % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an Chris@82: % anchor), which consists of three parts: Chris@82: % 1) NAME-title - the current sectioning name taken from \lastsection, Chris@82: % or the anchor name. Chris@82: % 2) NAME-snt - section number and type, passed as the SNT arg, or Chris@82: % empty for anchors. Chris@82: % 3) NAME-pg - the page number. Chris@82: % Chris@82: % This is called from \donoderef, \anchor, and \dofloat. In the case of Chris@82: % floats, there is an additional part, which is not written here: Chris@82: % 4) NAME-lof - the text as it should appear in a @listoffloats. Chris@82: % Chris@82: \def\setref#1#2{% Chris@82: \pdfmkdest{#1}% Chris@82: \iflinks Chris@82: {% Chris@82: \atdummies % preserve commands, but don't expand them Chris@82: \edef\writexrdef##1##2{% Chris@82: \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef Chris@82: ##1}{##2}}% these are parameters of \writexrdef Chris@82: }% Chris@82: \toks0 = \expandafter{\lastsection}% Chris@82: \immediate \writexrdef{title}{\the\toks0 }% Chris@82: \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. Chris@82: \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout Chris@82: }% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % @xrefautosectiontitle on|off says whether @section(ing) names are used Chris@82: % automatically in xrefs, if the third arg is not explicitly specified. Chris@82: % This was provided as a "secret" @set xref-automatic-section-title Chris@82: % variable, now it's official. Chris@82: % Chris@82: \parseargdef\xrefautomaticsectiontitle{% Chris@82: \def\temp{#1}% Chris@82: \ifx\temp\onword Chris@82: \expandafter\let\csname SETxref-automatic-section-title\endcsname Chris@82: = \empty Chris@82: \else\ifx\temp\offword Chris@82: \expandafter\let\csname SETxref-automatic-section-title\endcsname Chris@82: = \relax Chris@82: \else Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', Chris@82: must be on|off}% Chris@82: \fi\fi Chris@82: } Chris@82: Chris@82: % Chris@82: % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is Chris@82: % the node name, #2 the name of the Info cross-reference, #3 the printed Chris@82: % node name, #4 the name of the Info file, #5 the name of the printed Chris@82: % manual. All but the node name can be omitted. Chris@82: % Chris@82: \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} Chris@82: \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} Chris@82: \def\ref#1{\xrefX[#1,,,,,,,]} Chris@82: % Chris@82: \newbox\toprefbox Chris@82: \newbox\printedrefnamebox Chris@82: \newbox\infofilenamebox Chris@82: \newbox\printedmanualbox Chris@82: % Chris@82: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup Chris@82: \unsepspaces Chris@82: % Chris@82: % Get args without leading/trailing spaces. Chris@82: \def\printedrefname{\ignorespaces #3}% Chris@82: \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% Chris@82: % Chris@82: \def\infofilename{\ignorespaces #4}% Chris@82: \setbox\infofilenamebox = \hbox{\infofilename\unskip}% Chris@82: % Chris@82: \def\printedmanual{\ignorespaces #5}% Chris@82: \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% Chris@82: % Chris@82: % If the printed reference name (arg #3) was not explicitly given in Chris@82: % the @xref, figure out what we want to use. Chris@82: \ifdim \wd\printedrefnamebox = 0pt Chris@82: % No printed node name was explicitly given. Chris@82: \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax Chris@82: % Not auto section-title: use node name inside the square brackets. Chris@82: \def\printedrefname{\ignorespaces #1}% Chris@82: \else Chris@82: % Auto section-title: use chapter/section title inside Chris@82: % the square brackets if we have it. Chris@82: \ifdim \wd\printedmanualbox > 0pt Chris@82: % It is in another manual, so we don't have it; use node name. Chris@82: \def\printedrefname{\ignorespaces #1}% Chris@82: \else Chris@82: \ifhavexrefs Chris@82: % We (should) know the real title if we have the xref values. Chris@82: \def\printedrefname{\refx{#1-title}{}}% Chris@82: \else Chris@82: % Otherwise just copy the Info node name. Chris@82: \def\printedrefname{\ignorespaces #1}% Chris@82: \fi% Chris@82: \fi Chris@82: \fi Chris@82: \fi Chris@82: % Chris@82: % Make link in pdf output. Chris@82: \ifpdf Chris@82: {\indexnofonts Chris@82: \turnoffactive Chris@82: \makevalueexpandable Chris@82: % This expands tokens, so do it after making catcode changes, so _ Chris@82: % etc. don't get their TeX definitions. This ignores all spaces in Chris@82: % #4, including (wrongly) those in the middle of the filename. Chris@82: \getfilename{#4}% Chris@82: % Chris@82: % This (wrongly) does not take account of leading or trailing Chris@82: % spaces in #1, which should be ignored. Chris@82: \edef\pdfxrefdest{#1}% Chris@82: \ifx\pdfxrefdest\empty Chris@82: \def\pdfxrefdest{Top}% no empty targets Chris@82: \else Chris@82: \txiescapepdf\pdfxrefdest % escape PDF special chars Chris@82: \fi Chris@82: % Chris@82: \leavevmode Chris@82: \startlink attr{/Border [0 0 0]}% Chris@82: \ifnum\filenamelength>0 Chris@82: goto file{\the\filename.pdf} name{\pdfxrefdest}% Chris@82: \else Chris@82: goto name{\pdfmkpgn{\pdfxrefdest}}% Chris@82: \fi Chris@82: }% Chris@82: \setcolor{\linkcolor}% Chris@82: \fi Chris@82: % Chris@82: % Float references are printed completely differently: "Figure 1.2" Chris@82: % instead of "[somenode], p.3". We distinguish them by the Chris@82: % LABEL-title being set to a magic string. Chris@82: {% Chris@82: % Have to otherify everything special to allow the \csname to Chris@82: % include an _ in the xref name, etc. Chris@82: \indexnofonts Chris@82: \turnoffactive Chris@82: \expandafter\global\expandafter\let\expandafter\Xthisreftitle Chris@82: \csname XR#1-title\endcsname Chris@82: }% Chris@82: \iffloat\Xthisreftitle Chris@82: % If the user specified the print name (third arg) to the ref, Chris@82: % print it instead of our usual "Figure 1.2". Chris@82: \ifdim\wd\printedrefnamebox = 0pt Chris@82: \refx{#1-snt}{}% Chris@82: \else Chris@82: \printedrefname Chris@82: \fi Chris@82: % Chris@82: % If the user also gave the printed manual name (fifth arg), append Chris@82: % "in MANUALNAME". Chris@82: \ifdim \wd\printedmanualbox > 0pt Chris@82: \space \putwordin{} \cite{\printedmanual}% Chris@82: \fi Chris@82: \else Chris@82: % node/anchor (non-float) references. Chris@82: % Chris@82: % If we use \unhbox to print the node names, TeX does not insert Chris@82: % empty discretionaries after hyphens, which means that it will not Chris@82: % find a line break at a hyphen in a node names. Since some manuals Chris@82: % are best written with fairly long node names, containing hyphens, Chris@82: % this is a loss. Therefore, we give the text of the node name Chris@82: % again, so it is as if TeX is seeing it for the first time. Chris@82: % Chris@82: \ifdim \wd\printedmanualbox > 0pt Chris@82: % Cross-manual reference with a printed manual name. Chris@82: % Chris@82: \crossmanualxref{\cite{\printedmanual\unskip}}% Chris@82: % Chris@82: \else\ifdim \wd\infofilenamebox > 0pt Chris@82: % Cross-manual reference with only an info filename (arg 4), no Chris@82: % printed manual name (arg 5). This is essentially the same as Chris@82: % the case above; we output the filename, since we have nothing else. Chris@82: % Chris@82: \crossmanualxref{\code{\infofilename\unskip}}% Chris@82: % Chris@82: \else Chris@82: % Reference within this manual. Chris@82: % Chris@82: % _ (for example) has to be the character _ for the purposes of the Chris@82: % control sequence corresponding to the node, but it has to expand Chris@82: % into the usual \leavevmode...\vrule stuff for purposes of Chris@82: % printing. So we \turnoffactive for the \refx-snt, back on for the Chris@82: % printing, back off for the \refx-pg. Chris@82: {\turnoffactive Chris@82: % Only output a following space if the -snt ref is nonempty; for Chris@82: % @unnumbered and @anchor, it won't be. Chris@82: \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% Chris@82: \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi Chris@82: }% Chris@82: % output the `[mynode]' via the macro below so it can be overridden. Chris@82: \xrefprintnodename\printedrefname Chris@82: % Chris@82: % But we always want a comma and a space: Chris@82: ,\space Chris@82: % Chris@82: % output the `page 3'. Chris@82: \turnoffactive \putwordpage\tie\refx{#1-pg}{}% Chris@82: \fi\fi Chris@82: \fi Chris@82: \endlink Chris@82: \endgroup} Chris@82: Chris@82: % Output a cross-manual xref to #1. Used just above (twice). Chris@82: % Chris@82: % Only include the text "Section ``foo'' in" if the foo is neither Chris@82: % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply Chris@82: % "see The Foo Manual", the idea being to refer to the whole manual. Chris@82: % Chris@82: % But, this being TeX, we can't easily compare our node name against the Chris@82: % string "Top" while ignoring the possible spaces before and after in Chris@82: % the input. By adding the arbitrary 7sp below, we make it much less Chris@82: % likely that a real node name would have the same width as "Top" (e.g., Chris@82: % in a monospaced font). Hopefully it will never happen in practice. Chris@82: % Chris@82: % For the same basic reason, we retypeset the "Top" at every Chris@82: % reference, since the current font is indeterminate. Chris@82: % Chris@82: \def\crossmanualxref#1{% Chris@82: \setbox\toprefbox = \hbox{Top\kern7sp}% Chris@82: \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% Chris@82: \ifdim \wd2 > 7sp % nonempty? Chris@82: \ifdim \wd2 = \wd\toprefbox \else % same as Top? Chris@82: \putwordSection{} ``\printedrefname'' \putwordin{}\space Chris@82: \fi Chris@82: \fi Chris@82: #1% Chris@82: } Chris@82: Chris@82: % This macro is called from \xrefX for the `[nodename]' part of xref Chris@82: % output. It's a separate macro only so it can be changed more easily, Chris@82: % since square brackets don't work well in some documents. Particularly Chris@82: % one that Bob is working on :). Chris@82: % Chris@82: \def\xrefprintnodename#1{[#1]} Chris@82: Chris@82: % Things referred to by \setref. Chris@82: % Chris@82: \def\Ynothing{} Chris@82: \def\Yomitfromtoc{} Chris@82: \def\Ynumbered{% Chris@82: \ifnum\secno=0 Chris@82: \putwordChapter@tie \the\chapno Chris@82: \else \ifnum\subsecno=0 Chris@82: \putwordSection@tie \the\chapno.\the\secno Chris@82: \else \ifnum\subsubsecno=0 Chris@82: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno Chris@82: \else Chris@82: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno Chris@82: \fi\fi\fi Chris@82: } Chris@82: \def\Yappendix{% Chris@82: \ifnum\secno=0 Chris@82: \putwordAppendix@tie @char\the\appendixno{}% Chris@82: \else \ifnum\subsecno=0 Chris@82: \putwordSection@tie @char\the\appendixno.\the\secno Chris@82: \else \ifnum\subsubsecno=0 Chris@82: \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno Chris@82: \else Chris@82: \putwordSection@tie Chris@82: @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno Chris@82: \fi\fi\fi Chris@82: } Chris@82: Chris@82: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. Chris@82: % If its value is nonempty, SUFFIX is output afterward. Chris@82: % Chris@82: \def\refx#1#2{% Chris@82: {% Chris@82: \indexnofonts Chris@82: \otherbackslash Chris@82: \expandafter\global\expandafter\let\expandafter\thisrefX Chris@82: \csname XR#1\endcsname Chris@82: }% Chris@82: \ifx\thisrefX\relax Chris@82: % If not defined, say something at least. Chris@82: \angleleft un\-de\-fined\angleright Chris@82: \iflinks Chris@82: \ifhavexrefs Chris@82: {\toks0 = {#1}% avoid expansion of possibly-complex value Chris@82: \message{\linenumber Undefined cross reference `\the\toks0'.}}% Chris@82: \else Chris@82: \ifwarnedxrefs\else Chris@82: \global\warnedxrefstrue Chris@82: \message{Cross reference values unknown; you must run TeX again.}% Chris@82: \fi Chris@82: \fi Chris@82: \fi Chris@82: \else Chris@82: % It's defined, so just use it. Chris@82: \thisrefX Chris@82: \fi Chris@82: #2% Output the suffix in any case. Chris@82: } Chris@82: Chris@82: % This is the macro invoked by entries in the aux file. Usually it's Chris@82: % just a \def (we prepend XR to the control sequence name to avoid Chris@82: % collisions). But if this is a float type, we have more work to do. Chris@82: % Chris@82: \def\xrdef#1#2{% Chris@82: {% The node name might contain 8-bit characters, which in our current Chris@82: % implementation are changed to commands like @'e. Don't let these Chris@82: % mess up the control sequence name. Chris@82: \indexnofonts Chris@82: \turnoffactive Chris@82: \xdef\safexrefname{#1}% Chris@82: }% Chris@82: % Chris@82: \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref Chris@82: % Chris@82: % Was that xref control sequence that we just defined for a float? Chris@82: \expandafter\iffloat\csname XR\safexrefname\endcsname Chris@82: % it was a float, and we have the (safe) float type in \iffloattype. Chris@82: \expandafter\let\expandafter\floatlist Chris@82: \csname floatlist\iffloattype\endcsname Chris@82: % Chris@82: % Is this the first time we've seen this float type? Chris@82: \expandafter\ifx\floatlist\relax Chris@82: \toks0 = {\do}% yes, so just \do Chris@82: \else Chris@82: % had it before, so preserve previous elements in list. Chris@82: \toks0 = \expandafter{\floatlist\do}% Chris@82: \fi Chris@82: % Chris@82: % Remember this xref in the control sequence \floatlistFLOATTYPE, Chris@82: % for later use in \listoffloats. Chris@82: \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 Chris@82: {\safexrefname}}% Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Read the last existing aux file, if any. No error if none exists. Chris@82: % Chris@82: \def\tryauxfile{% Chris@82: \openin 1 \jobname.aux Chris@82: \ifeof 1 \else Chris@82: \readdatafile{aux}% Chris@82: \global\havexrefstrue Chris@82: \fi Chris@82: \closein 1 Chris@82: } Chris@82: Chris@82: \def\setupdatafile{% Chris@82: \catcode`\^^@=\other Chris@82: \catcode`\^^A=\other Chris@82: \catcode`\^^B=\other Chris@82: \catcode`\^^C=\other Chris@82: \catcode`\^^D=\other Chris@82: \catcode`\^^E=\other Chris@82: \catcode`\^^F=\other Chris@82: \catcode`\^^G=\other Chris@82: \catcode`\^^H=\other Chris@82: \catcode`\^^K=\other Chris@82: \catcode`\^^L=\other Chris@82: \catcode`\^^N=\other Chris@82: \catcode`\^^P=\other Chris@82: \catcode`\^^Q=\other Chris@82: \catcode`\^^R=\other Chris@82: \catcode`\^^S=\other Chris@82: \catcode`\^^T=\other Chris@82: \catcode`\^^U=\other Chris@82: \catcode`\^^V=\other Chris@82: \catcode`\^^W=\other Chris@82: \catcode`\^^X=\other Chris@82: \catcode`\^^Z=\other Chris@82: \catcode`\^^[=\other Chris@82: \catcode`\^^\=\other Chris@82: \catcode`\^^]=\other Chris@82: \catcode`\^^^=\other Chris@82: \catcode`\^^_=\other Chris@82: % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. Chris@82: % in xref tags, i.e., node names. But since ^^e4 notation isn't Chris@82: % supported in the main text, it doesn't seem desirable. Furthermore, Chris@82: % that is not enough: for node names that actually contain a ^ Chris@82: % character, we would end up writing a line like this: 'xrdef {'hat Chris@82: % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first Chris@82: % argument, and \hat is not an expandable control sequence. It could Chris@82: % all be worked out, but why? Either we support ^^ or we don't. Chris@82: % Chris@82: % The other change necessary for this was to define \auxhat: Chris@82: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter Chris@82: % and then to call \auxhat in \setq. Chris@82: % Chris@82: \catcode`\^=\other Chris@82: % Chris@82: % Special characters. Should be turned off anyway, but... Chris@82: \catcode`\~=\other Chris@82: \catcode`\[=\other Chris@82: \catcode`\]=\other Chris@82: \catcode`\"=\other Chris@82: \catcode`\_=\other Chris@82: \catcode`\|=\other Chris@82: \catcode`\<=\other Chris@82: \catcode`\>=\other Chris@82: \catcode`\$=\other Chris@82: \catcode`\#=\other Chris@82: \catcode`\&=\other Chris@82: \catcode`\%=\other Chris@82: \catcode`+=\other % avoid \+ for paranoia even though we've turned it off Chris@82: % Chris@82: % This is to support \ in node names and titles, since the \ Chris@82: % characters end up in a \csname. It's easier than Chris@82: % leaving it active and making its active definition an actual \ Chris@82: % character. What I don't understand is why it works in the *value* Chris@82: % of the xrdef. Seems like it should be a catcode12 \, and that Chris@82: % should not typeset properly. But it works, so I'm moving on for Chris@82: % now. --karl, 15jan04. Chris@82: \catcode`\\=\other Chris@82: % Chris@82: % Make the characters 128-255 be printing characters. Chris@82: {% Chris@82: \count1=128 Chris@82: \def\loop{% Chris@82: \catcode\count1=\other Chris@82: \advance\count1 by 1 Chris@82: \ifnum \count1<256 \loop \fi Chris@82: }% Chris@82: }% Chris@82: % Chris@82: % @ is our escape character in .aux files, and we need braces. Chris@82: \catcode`\{=1 Chris@82: \catcode`\}=2 Chris@82: \catcode`\@=0 Chris@82: } Chris@82: Chris@82: \def\readdatafile#1{% Chris@82: \begingroup Chris@82: \setupdatafile Chris@82: \input\jobname.#1 Chris@82: \endgroup} Chris@82: Chris@82: Chris@82: \message{insertions,} Chris@82: % including footnotes. Chris@82: Chris@82: \newcount \footnoteno Chris@82: Chris@82: % The trailing space in the following definition for supereject is Chris@82: % vital for proper filling; pages come out unaligned when you do a Chris@82: % pagealignmacro call if that space before the closing brace is Chris@82: % removed. (Generally, numeric constants should always be followed by a Chris@82: % space to prevent strange expansion errors.) Chris@82: \def\supereject{\par\penalty -20000\footnoteno =0 } Chris@82: Chris@82: % @footnotestyle is meaningful for Info output only. Chris@82: \let\footnotestyle=\comment Chris@82: Chris@82: {\catcode `\@=11 Chris@82: % Chris@82: % Auto-number footnotes. Otherwise like plain. Chris@82: \gdef\footnote{% Chris@82: \let\indent=\ptexindent Chris@82: \let\noindent=\ptexnoindent Chris@82: \global\advance\footnoteno by \@ne Chris@82: \edef\thisfootno{$^{\the\footnoteno}$}% Chris@82: % Chris@82: % In case the footnote comes at the end of a sentence, preserve the Chris@82: % extra spacing after we do the footnote number. Chris@82: \let\@sf\empty Chris@82: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi Chris@82: % Chris@82: % Remove inadvertent blank space before typesetting the footnote number. Chris@82: \unskip Chris@82: \thisfootno\@sf Chris@82: \dofootnote Chris@82: }% Chris@82: Chris@82: % Don't bother with the trickery in plain.tex to not require the Chris@82: % footnote text as a parameter. Our footnotes don't need to be so general. Chris@82: % Chris@82: % Oh yes, they do; otherwise, @ifset (and anything else that uses Chris@82: % \parseargline) fails inside footnotes because the tokens are fixed when Chris@82: % the footnote is read. --karl, 16nov96. Chris@82: % Chris@82: \gdef\dofootnote{% Chris@82: \insert\footins\bgroup Chris@82: % We want to typeset this text as a normal paragraph, even if the Chris@82: % footnote reference occurs in (for example) a display environment. Chris@82: % So reset some parameters. Chris@82: \hsize=\pagewidth Chris@82: \interlinepenalty\interfootnotelinepenalty Chris@82: \splittopskip\ht\strutbox % top baseline for broken footnotes Chris@82: \splitmaxdepth\dp\strutbox Chris@82: \floatingpenalty\@MM Chris@82: \leftskip\z@skip Chris@82: \rightskip\z@skip Chris@82: \spaceskip\z@skip Chris@82: \xspaceskip\z@skip Chris@82: \parindent\defaultparindent Chris@82: % Chris@82: \smallfonts \rm Chris@82: % Chris@82: % Because we use hanging indentation in footnotes, a @noindent appears Chris@82: % to exdent this text, so make it be a no-op. makeinfo does not use Chris@82: % hanging indentation so @noindent can still be needed within footnote Chris@82: % text after an @example or the like (not that this is good style). Chris@82: \let\noindent = \relax Chris@82: % Chris@82: % Hang the footnote text off the number. Use \everypar in case the Chris@82: % footnote extends for more than one paragraph. Chris@82: \everypar = {\hang}% Chris@82: \textindent{\thisfootno}% Chris@82: % Chris@82: % Don't crash into the line above the footnote text. Since this Chris@82: % expands into a box, it must come within the paragraph, lest it Chris@82: % provide a place where TeX can split the footnote. Chris@82: \footstrut Chris@82: % Chris@82: % Invoke rest of plain TeX footnote routine. Chris@82: \futurelet\next\fo@t Chris@82: } Chris@82: }%end \catcode `\@=11 Chris@82: Chris@82: % In case a @footnote appears in a vbox, save the footnote text and create Chris@82: % the real \insert just after the vbox finished. Otherwise, the insertion Chris@82: % would be lost. Chris@82: % Similarly, if a @footnote appears inside an alignment, save the footnote Chris@82: % text to a box and make the \insert when a row of the table is finished. Chris@82: % And the same can be done for other insert classes. --kasal, 16nov03. Chris@82: Chris@82: % Replace the \insert primitive by a cheating macro. Chris@82: % Deeper inside, just make sure that the saved insertions are not spilled Chris@82: % out prematurely. Chris@82: % Chris@82: \def\startsavinginserts{% Chris@82: \ifx \insert\ptexinsert Chris@82: \let\insert\saveinsert Chris@82: \else Chris@82: \let\checkinserts\relax Chris@82: \fi Chris@82: } Chris@82: Chris@82: % This \insert replacement works for both \insert\footins{foo} and Chris@82: % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. Chris@82: % Chris@82: \def\saveinsert#1{% Chris@82: \edef\next{\noexpand\savetobox \makeSAVEname#1}% Chris@82: \afterassignment\next Chris@82: % swallow the left brace Chris@82: \let\temp = Chris@82: } Chris@82: \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} Chris@82: \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} Chris@82: Chris@82: \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} Chris@82: Chris@82: \def\placesaveins#1{% Chris@82: \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname Chris@82: {\box#1}% Chris@82: } Chris@82: Chris@82: % eat @SAVE -- beware, all of them have catcode \other: Chris@82: { Chris@82: \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) Chris@82: \gdef\gobblesave @SAVE{} Chris@82: } Chris@82: Chris@82: % initialization: Chris@82: \def\newsaveins #1{% Chris@82: \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% Chris@82: \next Chris@82: } Chris@82: \def\newsaveinsX #1{% Chris@82: \csname newbox\endcsname #1% Chris@82: \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts Chris@82: \checksaveins #1}% Chris@82: } Chris@82: Chris@82: % initialize: Chris@82: \let\checkinserts\empty Chris@82: \newsaveins\footins Chris@82: \newsaveins\margin Chris@82: Chris@82: Chris@82: % @image. We use the macros from epsf.tex to support this. Chris@82: % If epsf.tex is not installed and @image is used, we complain. Chris@82: % Chris@82: % Check for and read epsf.tex up front. If we read it only at @image Chris@82: % time, we might be inside a group, and then its definitions would get Chris@82: % undone and the next image would fail. Chris@82: \openin 1 = epsf.tex Chris@82: \ifeof 1 \else Chris@82: % Do not bother showing banner with epsf.tex v2.7k (available in Chris@82: % doc/epsf.tex and on ctan). Chris@82: \def\epsfannounce{\toks0 = }% Chris@82: \input epsf.tex Chris@82: \fi Chris@82: \closein 1 Chris@82: % Chris@82: % We will only complain once about lack of epsf.tex. Chris@82: \newif\ifwarnednoepsf Chris@82: \newhelp\noepsfhelp{epsf.tex must be installed for images to Chris@82: work. It is also included in the Texinfo distribution, or you can get Chris@82: it from ftp://tug.org/tex/epsf.tex.} Chris@82: % Chris@82: \def\image#1{% Chris@82: \ifx\epsfbox\thisisundefined Chris@82: \ifwarnednoepsf \else Chris@82: \errhelp = \noepsfhelp Chris@82: \errmessage{epsf.tex not found, images will be ignored}% Chris@82: \global\warnednoepsftrue Chris@82: \fi Chris@82: \else Chris@82: \imagexxx #1,,,,,\finish Chris@82: \fi Chris@82: } Chris@82: % Chris@82: % Arguments to @image: Chris@82: % #1 is (mandatory) image filename; we tack on .eps extension. Chris@82: % #2 is (optional) width, #3 is (optional) height. Chris@82: % #4 is (ignored optional) html alt text. Chris@82: % #5 is (ignored optional) extension. Chris@82: % #6 is just the usual extra ignored arg for parsing stuff. Chris@82: \newif\ifimagevmode Chris@82: \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup Chris@82: \catcode`\^^M = 5 % in case we're inside an example Chris@82: \normalturnoffactive % allow _ et al. in names Chris@82: % If the image is by itself, center it. Chris@82: \ifvmode Chris@82: \imagevmodetrue Chris@82: \else \ifx\centersub\centerV Chris@82: % for @center @image, we need a vbox so we can have our vertical space Chris@82: \imagevmodetrue Chris@82: \vbox\bgroup % vbox has better behavior than vtop herev Chris@82: \fi\fi Chris@82: % Chris@82: \ifimagevmode Chris@82: \nobreak\medskip Chris@82: % Usually we'll have text after the image which will insert Chris@82: % \parskip glue, so insert it here too to equalize the space Chris@82: % above and below. Chris@82: \nobreak\vskip\parskip Chris@82: \nobreak Chris@82: \fi Chris@82: % Chris@82: % Leave vertical mode so that indentation from an enclosing Chris@82: % environment such as @quotation is respected. Chris@82: % However, if we're at the top level, we don't want the Chris@82: % normal paragraph indentation. Chris@82: % On the other hand, if we are in the case of @center @image, we don't Chris@82: % want to start a paragraph, which will create a hsize-width box and Chris@82: % eradicate the centering. Chris@82: \ifx\centersub\centerV\else \noindent \fi Chris@82: % Chris@82: % Output the image. Chris@82: \ifpdf Chris@82: \dopdfimage{#1}{#2}{#3}% Chris@82: \else Chris@82: % \epsfbox itself resets \epsf?size at each figure. Chris@82: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi Chris@82: \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi Chris@82: \epsfbox{#1.eps}% Chris@82: \fi Chris@82: % Chris@82: \ifimagevmode Chris@82: \medskip % space after a standalone image Chris@82: \fi Chris@82: \ifx\centersub\centerV \egroup \fi Chris@82: \endgroup} Chris@82: Chris@82: Chris@82: % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, Chris@82: % etc. We don't actually implement floating yet, we always include the Chris@82: % float "here". But it seemed the best name for the future. Chris@82: % Chris@82: \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} Chris@82: Chris@82: % There may be a space before second and/or third parameter; delete it. Chris@82: \def\eatcommaspace#1, {#1,} Chris@82: Chris@82: % #1 is the optional FLOATTYPE, the text label for this float, typically Chris@82: % "Figure", "Table", "Example", etc. Can't contain commas. If omitted, Chris@82: % this float will not be numbered and cannot be referred to. Chris@82: % Chris@82: % #2 is the optional xref label. Also must be present for the float to Chris@82: % be referable. Chris@82: % Chris@82: % #3 is the optional positioning argument; for now, it is ignored. It Chris@82: % will somehow specify the positions allowed to float to (here, top, bottom). Chris@82: % Chris@82: % We keep a separate counter for each FLOATTYPE, which we reset at each Chris@82: % chapter-level command. Chris@82: \let\resetallfloatnos=\empty Chris@82: % Chris@82: \def\dofloat#1,#2,#3,#4\finish{% Chris@82: \let\thiscaption=\empty Chris@82: \let\thisshortcaption=\empty Chris@82: % Chris@82: % don't lose footnotes inside @float. Chris@82: % Chris@82: % BEWARE: when the floats start float, we have to issue warning whenever an Chris@82: % insert appears inside a float which could possibly float. --kasal, 26may04 Chris@82: % Chris@82: \startsavinginserts Chris@82: % Chris@82: % We can't be used inside a paragraph. Chris@82: \par Chris@82: % Chris@82: \vtop\bgroup Chris@82: \def\floattype{#1}% Chris@82: \def\floatlabel{#2}% Chris@82: \def\floatloc{#3}% we do nothing with this yet. Chris@82: % Chris@82: \ifx\floattype\empty Chris@82: \let\safefloattype=\empty Chris@82: \else Chris@82: {% Chris@82: % the floattype might have accents or other special characters, Chris@82: % but we need to use it in a control sequence name. Chris@82: \indexnofonts Chris@82: \turnoffactive Chris@82: \xdef\safefloattype{\floattype}% Chris@82: }% Chris@82: \fi Chris@82: % Chris@82: % If label is given but no type, we handle that as the empty type. Chris@82: \ifx\floatlabel\empty \else Chris@82: % We want each FLOATTYPE to be numbered separately (Figure 1, Chris@82: % Table 1, Figure 2, ...). (And if no label, no number.) Chris@82: % Chris@82: \expandafter\getfloatno\csname\safefloattype floatno\endcsname Chris@82: \global\advance\floatno by 1 Chris@82: % Chris@82: {% Chris@82: % This magic value for \lastsection is output by \setref as the Chris@82: % XREFLABEL-title value. \xrefX uses it to distinguish float Chris@82: % labels (which have a completely different output format) from Chris@82: % node and anchor labels. And \xrdef uses it to construct the Chris@82: % lists of floats. Chris@82: % Chris@82: \edef\lastsection{\floatmagic=\safefloattype}% Chris@82: \setref{\floatlabel}{Yfloat}% Chris@82: }% Chris@82: \fi Chris@82: % Chris@82: % start with \parskip glue, I guess. Chris@82: \vskip\parskip Chris@82: % Chris@82: % Don't suppress indentation if a float happens to start a section. Chris@82: \restorefirstparagraphindent Chris@82: } Chris@82: Chris@82: % we have these possibilities: Chris@82: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap Chris@82: % @float Foo,lbl & no caption: Foo 1.1 Chris@82: % @float Foo & @caption{Cap}: Foo: Cap Chris@82: % @float Foo & no caption: Foo Chris@82: % @float ,lbl & Caption{Cap}: 1.1: Cap Chris@82: % @float ,lbl & no caption: 1.1 Chris@82: % @float & @caption{Cap}: Cap Chris@82: % @float & no caption: Chris@82: % Chris@82: \def\Efloat{% Chris@82: \let\floatident = \empty Chris@82: % Chris@82: % In all cases, if we have a float type, it comes first. Chris@82: \ifx\floattype\empty \else \def\floatident{\floattype}\fi Chris@82: % Chris@82: % If we have an xref label, the number comes next. Chris@82: \ifx\floatlabel\empty \else Chris@82: \ifx\floattype\empty \else % if also had float type, need tie first. Chris@82: \appendtomacro\floatident{\tie}% Chris@82: \fi Chris@82: % the number. Chris@82: \appendtomacro\floatident{\chaplevelprefix\the\floatno}% Chris@82: \fi Chris@82: % Chris@82: % Start the printed caption with what we've constructed in Chris@82: % \floatident, but keep it separate; we need \floatident again. Chris@82: \let\captionline = \floatident Chris@82: % Chris@82: \ifx\thiscaption\empty \else Chris@82: \ifx\floatident\empty \else Chris@82: \appendtomacro\captionline{: }% had ident, so need a colon between Chris@82: \fi Chris@82: % Chris@82: % caption text. Chris@82: \appendtomacro\captionline{\scanexp\thiscaption}% Chris@82: \fi Chris@82: % Chris@82: % If we have anything to print, print it, with space before. Chris@82: % Eventually this needs to become an \insert. Chris@82: \ifx\captionline\empty \else Chris@82: \vskip.5\parskip Chris@82: \captionline Chris@82: % Chris@82: % Space below caption. Chris@82: \vskip\parskip Chris@82: \fi Chris@82: % Chris@82: % If have an xref label, write the list of floats info. Do this Chris@82: % after the caption, to avoid chance of it being a breakpoint. Chris@82: \ifx\floatlabel\empty \else Chris@82: % Write the text that goes in the lof to the aux file as Chris@82: % \floatlabel-lof. Besides \floatident, we include the short Chris@82: % caption if specified, else the full caption if specified, else nothing. Chris@82: {% Chris@82: \atdummies Chris@82: % Chris@82: % since we read the caption text in the macro world, where ^^M Chris@82: % is turned into a normal character, we have to scan it back, so Chris@82: % we don't write the literal three characters "^^M" into the aux file. Chris@82: \scanexp{% Chris@82: \xdef\noexpand\gtemp{% Chris@82: \ifx\thisshortcaption\empty Chris@82: \thiscaption Chris@82: \else Chris@82: \thisshortcaption Chris@82: \fi Chris@82: }% Chris@82: }% Chris@82: \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident Chris@82: \ifx\gtemp\empty \else : \gtemp \fi}}% Chris@82: }% Chris@82: \fi Chris@82: \egroup % end of \vtop Chris@82: % Chris@82: % place the captured inserts Chris@82: % Chris@82: % BEWARE: when the floats start floating, we have to issue warning Chris@82: % whenever an insert appears inside a float which could possibly Chris@82: % float. --kasal, 26may04 Chris@82: % Chris@82: \checkinserts Chris@82: } Chris@82: Chris@82: % Append the tokens #2 to the definition of macro #1, not expanding either. Chris@82: % Chris@82: \def\appendtomacro#1#2{% Chris@82: \expandafter\def\expandafter#1\expandafter{#1#2}% Chris@82: } Chris@82: Chris@82: % @caption, @shortcaption Chris@82: % Chris@82: \def\caption{\docaption\thiscaption} Chris@82: \def\shortcaption{\docaption\thisshortcaption} Chris@82: \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} Chris@82: \def\defcaption#1#2{\egroup \def#1{#2}} Chris@82: Chris@82: % The parameter is the control sequence identifying the counter we are Chris@82: % going to use. Create it if it doesn't exist and assign it to \floatno. Chris@82: \def\getfloatno#1{% Chris@82: \ifx#1\relax Chris@82: % Haven't seen this figure type before. Chris@82: \csname newcount\endcsname #1% Chris@82: % Chris@82: % Remember to reset this floatno at the next chap. Chris@82: \expandafter\gdef\expandafter\resetallfloatnos Chris@82: \expandafter{\resetallfloatnos #1=0 }% Chris@82: \fi Chris@82: \let\floatno#1% Chris@82: } Chris@82: Chris@82: % \setref calls this to get the XREFLABEL-snt value. We want an @xref Chris@82: % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we Chris@82: % first read the @float command. Chris@82: % Chris@82: \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% Chris@82: Chris@82: % Magic string used for the XREFLABEL-title value, so \xrefX can Chris@82: % distinguish floats from other xref types. Chris@82: \def\floatmagic{!!float!!} Chris@82: Chris@82: % #1 is the control sequence we are passed; we expand into a conditional Chris@82: % which is true if #1 represents a float ref. That is, the magic Chris@82: % \lastsection value which we \setref above. Chris@82: % Chris@82: \def\iffloat#1{\expandafter\doiffloat#1==\finish} Chris@82: % Chris@82: % #1 is (maybe) the \floatmagic string. If so, #2 will be the Chris@82: % (safe) float type for this float. We set \iffloattype to #2. Chris@82: % Chris@82: \def\doiffloat#1=#2=#3\finish{% Chris@82: \def\temp{#1}% Chris@82: \def\iffloattype{#2}% Chris@82: \ifx\temp\floatmagic Chris@82: } Chris@82: Chris@82: % @listoffloats FLOATTYPE - print a list of floats like a table of contents. Chris@82: % Chris@82: \parseargdef\listoffloats{% Chris@82: \def\floattype{#1}% floattype Chris@82: {% Chris@82: % the floattype might have accents or other special characters, Chris@82: % but we need to use it in a control sequence name. Chris@82: \indexnofonts Chris@82: \turnoffactive Chris@82: \xdef\safefloattype{\floattype}% Chris@82: }% Chris@82: % Chris@82: % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. Chris@82: \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax Chris@82: \ifhavexrefs Chris@82: % if the user said @listoffloats foo but never @float foo. Chris@82: \message{\linenumber No `\safefloattype' floats to list.}% Chris@82: \fi Chris@82: \else Chris@82: \begingroup Chris@82: \leftskip=\tocindent % indent these entries like a toc Chris@82: \let\do=\listoffloatsdo Chris@82: \csname floatlist\safefloattype\endcsname Chris@82: \endgroup Chris@82: \fi Chris@82: } Chris@82: Chris@82: % This is called on each entry in a list of floats. We're passed the Chris@82: % xref label, in the form LABEL-title, which is how we save it in the Chris@82: % aux file. We strip off the -title and look up \XRLABEL-lof, which Chris@82: % has the text we're supposed to typeset here. Chris@82: % Chris@82: % Figures without xref labels will not be included in the list (since Chris@82: % they won't appear in the aux file). Chris@82: % Chris@82: \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} Chris@82: \def\listoffloatsdoentry#1-title\finish{{% Chris@82: % Can't fully expand XR#1-lof because it can contain anything. Just Chris@82: % pass the control sequence. On the other hand, XR#1-pg is just the Chris@82: % page number, and we want to fully expand that so we can get a link Chris@82: % in pdf output. Chris@82: \toksA = \expandafter{\csname XR#1-lof\endcsname}% Chris@82: % Chris@82: % use the same \entry macro we use to generate the TOC and index. Chris@82: \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% Chris@82: \writeentry Chris@82: }} Chris@82: Chris@82: Chris@82: \message{localization,} Chris@82: Chris@82: % For single-language documents, @documentlanguage is usually given very Chris@82: % early, just after @documentencoding. Single argument is the language Chris@82: % (de) or locale (de_DE) abbreviation. Chris@82: % Chris@82: { Chris@82: \catcode`\_ = \active Chris@82: \globaldefs=1 Chris@82: \parseargdef\documentlanguage{\begingroup Chris@82: \let_=\normalunderscore % normal _ character for filenames Chris@82: \tex % read txi-??.tex file in plain TeX. Chris@82: % Read the file by the name they passed if it exists. Chris@82: \openin 1 txi-#1.tex Chris@82: \ifeof 1 Chris@82: \documentlanguagetrywithoutunderscore{#1_\finish}% Chris@82: \else Chris@82: \globaldefs = 1 % everything in the txi-LL files needs to persist Chris@82: \input txi-#1.tex Chris@82: \fi Chris@82: \closein 1 Chris@82: \endgroup % end raw TeX Chris@82: \endgroup} Chris@82: % Chris@82: % If they passed de_DE, and txi-de_DE.tex doesn't exist, Chris@82: % try txi-de.tex. Chris@82: % Chris@82: \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% Chris@82: \openin 1 txi-#1.tex Chris@82: \ifeof 1 Chris@82: \errhelp = \nolanghelp Chris@82: \errmessage{Cannot read language file txi-#1.tex}% Chris@82: \else Chris@82: \globaldefs = 1 % everything in the txi-LL files needs to persist Chris@82: \input txi-#1.tex Chris@82: \fi Chris@82: \closein 1 Chris@82: } Chris@82: }% end of special _ catcode Chris@82: % Chris@82: \newhelp\nolanghelp{The given language definition file cannot be found or Chris@82: is empty. Maybe you need to install it? Putting it in the current Chris@82: directory should work if nowhere else does.} Chris@82: Chris@82: % This macro is called from txi-??.tex files; the first argument is the Chris@82: % \language name to set (without the "\lang@" prefix), the second and Chris@82: % third args are \{left,right}hyphenmin. Chris@82: % Chris@82: % The language names to pass are determined when the format is built. Chris@82: % See the etex.log file created at that time, e.g., Chris@82: % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. Chris@82: % Chris@82: % With TeX Live 2008, etex now includes hyphenation patterns for all Chris@82: % available languages. This means we can support hyphenation in Chris@82: % Texinfo, at least to some extent. (This still doesn't solve the Chris@82: % accented characters problem.) Chris@82: % Chris@82: \catcode`@=11 Chris@82: \def\txisetlanguage#1#2#3{% Chris@82: % do not set the language if the name is undefined in the current TeX. Chris@82: \expandafter\ifx\csname lang@#1\endcsname \relax Chris@82: \message{no patterns for #1}% Chris@82: \else Chris@82: \global\language = \csname lang@#1\endcsname Chris@82: \fi Chris@82: % but there is no harm in adjusting the hyphenmin values regardless. Chris@82: \global\lefthyphenmin = #2\relax Chris@82: \global\righthyphenmin = #3\relax Chris@82: } Chris@82: Chris@82: % Helpers for encodings. Chris@82: % Set the catcode of characters 128 through 255 to the specified number. Chris@82: % Chris@82: \def\setnonasciicharscatcode#1{% Chris@82: \count255=128 Chris@82: \loop\ifnum\count255<256 Chris@82: \global\catcode\count255=#1\relax Chris@82: \advance\count255 by 1 Chris@82: \repeat Chris@82: } Chris@82: Chris@82: \def\setnonasciicharscatcodenonglobal#1{% Chris@82: \count255=128 Chris@82: \loop\ifnum\count255<256 Chris@82: \catcode\count255=#1\relax Chris@82: \advance\count255 by 1 Chris@82: \repeat Chris@82: } Chris@82: Chris@82: % @documentencoding sets the definition of non-ASCII characters Chris@82: % according to the specified encoding. Chris@82: % Chris@82: \parseargdef\documentencoding{% Chris@82: % Encoding being declared for the document. Chris@82: \def\declaredencoding{\csname #1.enc\endcsname}% Chris@82: % Chris@82: % Supported encodings: names converted to tokens in order to be able Chris@82: % to compare them with \ifx. Chris@82: \def\ascii{\csname US-ASCII.enc\endcsname}% Chris@82: \def\latnine{\csname ISO-8859-15.enc\endcsname}% Chris@82: \def\latone{\csname ISO-8859-1.enc\endcsname}% Chris@82: \def\lattwo{\csname ISO-8859-2.enc\endcsname}% Chris@82: \def\utfeight{\csname UTF-8.enc\endcsname}% Chris@82: % Chris@82: \ifx \declaredencoding \ascii Chris@82: \asciichardefs Chris@82: % Chris@82: \else \ifx \declaredencoding \lattwo Chris@82: \setnonasciicharscatcode\active Chris@82: \lattwochardefs Chris@82: % Chris@82: \else \ifx \declaredencoding \latone Chris@82: \setnonasciicharscatcode\active Chris@82: \latonechardefs Chris@82: % Chris@82: \else \ifx \declaredencoding \latnine Chris@82: \setnonasciicharscatcode\active Chris@82: \latninechardefs Chris@82: % Chris@82: \else \ifx \declaredencoding \utfeight Chris@82: \setnonasciicharscatcode\active Chris@82: \utfeightchardefs Chris@82: % Chris@82: \else Chris@82: \message{Unknown document encoding #1, ignoring.}% Chris@82: % Chris@82: \fi % utfeight Chris@82: \fi % latnine Chris@82: \fi % latone Chris@82: \fi % lattwo Chris@82: \fi % ascii Chris@82: } Chris@82: Chris@82: % A message to be logged when using a character that isn't available Chris@82: % the default font encoding (OT1). Chris@82: % Chris@82: \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} Chris@82: Chris@82: % Take account of \c (plain) vs. \, (Texinfo) difference. Chris@82: \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} Chris@82: Chris@82: % First, make active non-ASCII characters in order for them to be Chris@82: % correctly categorized when TeX reads the replacement text of Chris@82: % macros containing the character definitions. Chris@82: \setnonasciicharscatcode\active Chris@82: % Chris@82: % Latin1 (ISO-8859-1) character definitions. Chris@82: \def\latonechardefs{% Chris@82: \gdef^^a0{\tie} Chris@82: \gdef^^a1{\exclamdown} Chris@82: \gdef^^a2{\missingcharmsg{CENT SIGN}} Chris@82: \gdef^^a3{{\pounds}} Chris@82: \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} Chris@82: \gdef^^a5{\missingcharmsg{YEN SIGN}} Chris@82: \gdef^^a6{\missingcharmsg{BROKEN BAR}} Chris@82: \gdef^^a7{\S} Chris@82: \gdef^^a8{\"{}} Chris@82: \gdef^^a9{\copyright} Chris@82: \gdef^^aa{\ordf} Chris@82: \gdef^^ab{\guillemetleft} Chris@82: \gdef^^ac{$\lnot$} Chris@82: \gdef^^ad{\-} Chris@82: \gdef^^ae{\registeredsymbol} Chris@82: \gdef^^af{\={}} Chris@82: % Chris@82: \gdef^^b0{\textdegree} Chris@82: \gdef^^b1{$\pm$} Chris@82: \gdef^^b2{$^2$} Chris@82: \gdef^^b3{$^3$} Chris@82: \gdef^^b4{\'{}} Chris@82: \gdef^^b5{$\mu$} Chris@82: \gdef^^b6{\P} Chris@82: % Chris@82: \gdef^^b7{$^.$} Chris@82: \gdef^^b8{\cedilla\ } Chris@82: \gdef^^b9{$^1$} Chris@82: \gdef^^ba{\ordm} Chris@82: % Chris@82: \gdef^^bb{\guillemetright} Chris@82: \gdef^^bc{$1\over4$} Chris@82: \gdef^^bd{$1\over2$} Chris@82: \gdef^^be{$3\over4$} Chris@82: \gdef^^bf{\questiondown} Chris@82: % Chris@82: \gdef^^c0{\`A} Chris@82: \gdef^^c1{\'A} Chris@82: \gdef^^c2{\^A} Chris@82: \gdef^^c3{\~A} Chris@82: \gdef^^c4{\"A} Chris@82: \gdef^^c5{\ringaccent A} Chris@82: \gdef^^c6{\AE} Chris@82: \gdef^^c7{\cedilla C} Chris@82: \gdef^^c8{\`E} Chris@82: \gdef^^c9{\'E} Chris@82: \gdef^^ca{\^E} Chris@82: \gdef^^cb{\"E} Chris@82: \gdef^^cc{\`I} Chris@82: \gdef^^cd{\'I} Chris@82: \gdef^^ce{\^I} Chris@82: \gdef^^cf{\"I} Chris@82: % Chris@82: \gdef^^d0{\DH} Chris@82: \gdef^^d1{\~N} Chris@82: \gdef^^d2{\`O} Chris@82: \gdef^^d3{\'O} Chris@82: \gdef^^d4{\^O} Chris@82: \gdef^^d5{\~O} Chris@82: \gdef^^d6{\"O} Chris@82: \gdef^^d7{$\times$} Chris@82: \gdef^^d8{\O} Chris@82: \gdef^^d9{\`U} Chris@82: \gdef^^da{\'U} Chris@82: \gdef^^db{\^U} Chris@82: \gdef^^dc{\"U} Chris@82: \gdef^^dd{\'Y} Chris@82: \gdef^^de{\TH} Chris@82: \gdef^^df{\ss} Chris@82: % Chris@82: \gdef^^e0{\`a} Chris@82: \gdef^^e1{\'a} Chris@82: \gdef^^e2{\^a} Chris@82: \gdef^^e3{\~a} Chris@82: \gdef^^e4{\"a} Chris@82: \gdef^^e5{\ringaccent a} Chris@82: \gdef^^e6{\ae} Chris@82: \gdef^^e7{\cedilla c} Chris@82: \gdef^^e8{\`e} Chris@82: \gdef^^e9{\'e} Chris@82: \gdef^^ea{\^e} Chris@82: \gdef^^eb{\"e} Chris@82: \gdef^^ec{\`{\dotless i}} Chris@82: \gdef^^ed{\'{\dotless i}} Chris@82: \gdef^^ee{\^{\dotless i}} Chris@82: \gdef^^ef{\"{\dotless i}} Chris@82: % Chris@82: \gdef^^f0{\dh} Chris@82: \gdef^^f1{\~n} Chris@82: \gdef^^f2{\`o} Chris@82: \gdef^^f3{\'o} Chris@82: \gdef^^f4{\^o} Chris@82: \gdef^^f5{\~o} Chris@82: \gdef^^f6{\"o} Chris@82: \gdef^^f7{$\div$} Chris@82: \gdef^^f8{\o} Chris@82: \gdef^^f9{\`u} Chris@82: \gdef^^fa{\'u} Chris@82: \gdef^^fb{\^u} Chris@82: \gdef^^fc{\"u} Chris@82: \gdef^^fd{\'y} Chris@82: \gdef^^fe{\th} Chris@82: \gdef^^ff{\"y} Chris@82: } Chris@82: Chris@82: % Latin9 (ISO-8859-15) encoding character definitions. Chris@82: \def\latninechardefs{% Chris@82: % Encoding is almost identical to Latin1. Chris@82: \latonechardefs Chris@82: % Chris@82: \gdef^^a4{\euro} Chris@82: \gdef^^a6{\v S} Chris@82: \gdef^^a8{\v s} Chris@82: \gdef^^b4{\v Z} Chris@82: \gdef^^b8{\v z} Chris@82: \gdef^^bc{\OE} Chris@82: \gdef^^bd{\oe} Chris@82: \gdef^^be{\"Y} Chris@82: } Chris@82: Chris@82: % Latin2 (ISO-8859-2) character definitions. Chris@82: \def\lattwochardefs{% Chris@82: \gdef^^a0{\tie} Chris@82: \gdef^^a1{\ogonek{A}} Chris@82: \gdef^^a2{\u{}} Chris@82: \gdef^^a3{\L} Chris@82: \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} Chris@82: \gdef^^a5{\v L} Chris@82: \gdef^^a6{\'S} Chris@82: \gdef^^a7{\S} Chris@82: \gdef^^a8{\"{}} Chris@82: \gdef^^a9{\v S} Chris@82: \gdef^^aa{\cedilla S} Chris@82: \gdef^^ab{\v T} Chris@82: \gdef^^ac{\'Z} Chris@82: \gdef^^ad{\-} Chris@82: \gdef^^ae{\v Z} Chris@82: \gdef^^af{\dotaccent Z} Chris@82: % Chris@82: \gdef^^b0{\textdegree} Chris@82: \gdef^^b1{\ogonek{a}} Chris@82: \gdef^^b2{\ogonek{ }} Chris@82: \gdef^^b3{\l} Chris@82: \gdef^^b4{\'{}} Chris@82: \gdef^^b5{\v l} Chris@82: \gdef^^b6{\'s} Chris@82: \gdef^^b7{\v{}} Chris@82: \gdef^^b8{\cedilla\ } Chris@82: \gdef^^b9{\v s} Chris@82: \gdef^^ba{\cedilla s} Chris@82: \gdef^^bb{\v t} Chris@82: \gdef^^bc{\'z} Chris@82: \gdef^^bd{\H{}} Chris@82: \gdef^^be{\v z} Chris@82: \gdef^^bf{\dotaccent z} Chris@82: % Chris@82: \gdef^^c0{\'R} Chris@82: \gdef^^c1{\'A} Chris@82: \gdef^^c2{\^A} Chris@82: \gdef^^c3{\u A} Chris@82: \gdef^^c4{\"A} Chris@82: \gdef^^c5{\'L} Chris@82: \gdef^^c6{\'C} Chris@82: \gdef^^c7{\cedilla C} Chris@82: \gdef^^c8{\v C} Chris@82: \gdef^^c9{\'E} Chris@82: \gdef^^ca{\ogonek{E}} Chris@82: \gdef^^cb{\"E} Chris@82: \gdef^^cc{\v E} Chris@82: \gdef^^cd{\'I} Chris@82: \gdef^^ce{\^I} Chris@82: \gdef^^cf{\v D} Chris@82: % Chris@82: \gdef^^d0{\DH} Chris@82: \gdef^^d1{\'N} Chris@82: \gdef^^d2{\v N} Chris@82: \gdef^^d3{\'O} Chris@82: \gdef^^d4{\^O} Chris@82: \gdef^^d5{\H O} Chris@82: \gdef^^d6{\"O} Chris@82: \gdef^^d7{$\times$} Chris@82: \gdef^^d8{\v R} Chris@82: \gdef^^d9{\ringaccent U} Chris@82: \gdef^^da{\'U} Chris@82: \gdef^^db{\H U} Chris@82: \gdef^^dc{\"U} Chris@82: \gdef^^dd{\'Y} Chris@82: \gdef^^de{\cedilla T} Chris@82: \gdef^^df{\ss} Chris@82: % Chris@82: \gdef^^e0{\'r} Chris@82: \gdef^^e1{\'a} Chris@82: \gdef^^e2{\^a} Chris@82: \gdef^^e3{\u a} Chris@82: \gdef^^e4{\"a} Chris@82: \gdef^^e5{\'l} Chris@82: \gdef^^e6{\'c} Chris@82: \gdef^^e7{\cedilla c} Chris@82: \gdef^^e8{\v c} Chris@82: \gdef^^e9{\'e} Chris@82: \gdef^^ea{\ogonek{e}} Chris@82: \gdef^^eb{\"e} Chris@82: \gdef^^ec{\v e} Chris@82: \gdef^^ed{\'{\dotless{i}}} Chris@82: \gdef^^ee{\^{\dotless{i}}} Chris@82: \gdef^^ef{\v d} Chris@82: % Chris@82: \gdef^^f0{\dh} Chris@82: \gdef^^f1{\'n} Chris@82: \gdef^^f2{\v n} Chris@82: \gdef^^f3{\'o} Chris@82: \gdef^^f4{\^o} Chris@82: \gdef^^f5{\H o} Chris@82: \gdef^^f6{\"o} Chris@82: \gdef^^f7{$\div$} Chris@82: \gdef^^f8{\v r} Chris@82: \gdef^^f9{\ringaccent u} Chris@82: \gdef^^fa{\'u} Chris@82: \gdef^^fb{\H u} Chris@82: \gdef^^fc{\"u} Chris@82: \gdef^^fd{\'y} Chris@82: \gdef^^fe{\cedilla t} Chris@82: \gdef^^ff{\dotaccent{}} Chris@82: } Chris@82: Chris@82: % UTF-8 character definitions. Chris@82: % Chris@82: % This code to support UTF-8 is based on LaTeX's utf8.def, with some Chris@82: % changes for Texinfo conventions. It is included here under the GPL by Chris@82: % permission from Frank Mittelbach and the LaTeX team. Chris@82: % Chris@82: \newcount\countUTFx Chris@82: \newcount\countUTFy Chris@82: \newcount\countUTFz Chris@82: Chris@82: \gdef\UTFviiiTwoOctets#1#2{\expandafter Chris@82: \UTFviiiDefined\csname u8:#1\string #2\endcsname} Chris@82: % Chris@82: \gdef\UTFviiiThreeOctets#1#2#3{\expandafter Chris@82: \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} Chris@82: % Chris@82: \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter Chris@82: \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} Chris@82: Chris@82: \gdef\UTFviiiDefined#1{% Chris@82: \ifx #1\relax Chris@82: \message{\linenumber Unicode char \string #1 not defined for Texinfo}% Chris@82: \else Chris@82: \expandafter #1% Chris@82: \fi Chris@82: } Chris@82: Chris@82: \begingroup Chris@82: \catcode`\~13 Chris@82: \catcode`\"12 Chris@82: Chris@82: \def\UTFviiiLoop{% Chris@82: \global\catcode\countUTFx\active Chris@82: \uccode`\~\countUTFx Chris@82: \uppercase\expandafter{\UTFviiiTmp}% Chris@82: \advance\countUTFx by 1 Chris@82: \ifnum\countUTFx < \countUTFy Chris@82: \expandafter\UTFviiiLoop Chris@82: \fi} Chris@82: Chris@82: \countUTFx = "C2 Chris@82: \countUTFy = "E0 Chris@82: \def\UTFviiiTmp{% Chris@82: \xdef~{\noexpand\UTFviiiTwoOctets\string~}} Chris@82: \UTFviiiLoop Chris@82: Chris@82: \countUTFx = "E0 Chris@82: \countUTFy = "F0 Chris@82: \def\UTFviiiTmp{% Chris@82: \xdef~{\noexpand\UTFviiiThreeOctets\string~}} Chris@82: \UTFviiiLoop Chris@82: Chris@82: \countUTFx = "F0 Chris@82: \countUTFy = "F4 Chris@82: \def\UTFviiiTmp{% Chris@82: \xdef~{\noexpand\UTFviiiFourOctets\string~}} Chris@82: \UTFviiiLoop Chris@82: \endgroup Chris@82: Chris@82: \begingroup Chris@82: \catcode`\"=12 Chris@82: \catcode`\<=12 Chris@82: \catcode`\.=12 Chris@82: \catcode`\,=12 Chris@82: \catcode`\;=12 Chris@82: \catcode`\!=12 Chris@82: \catcode`\~=13 Chris@82: Chris@82: \gdef\DeclareUnicodeCharacter#1#2{% Chris@82: \countUTFz = "#1\relax Chris@82: %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% Chris@82: \begingroup Chris@82: \parseXMLCharref Chris@82: \def\UTFviiiTwoOctets##1##2{% Chris@82: \csname u8:##1\string ##2\endcsname}% Chris@82: \def\UTFviiiThreeOctets##1##2##3{% Chris@82: \csname u8:##1\string ##2\string ##3\endcsname}% Chris@82: \def\UTFviiiFourOctets##1##2##3##4{% Chris@82: \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% Chris@82: \expandafter\expandafter\expandafter\expandafter Chris@82: \expandafter\expandafter\expandafter Chris@82: \gdef\UTFviiiTmp{#2}% Chris@82: \endgroup} Chris@82: Chris@82: \gdef\parseXMLCharref{% Chris@82: \ifnum\countUTFz < "A0\relax Chris@82: \errhelp = \EMsimple Chris@82: \errmessage{Cannot define Unicode char value < 00A0}% Chris@82: \else\ifnum\countUTFz < "800\relax Chris@82: \parseUTFviiiA,% Chris@82: \parseUTFviiiB C\UTFviiiTwoOctets.,% Chris@82: \else\ifnum\countUTFz < "10000\relax Chris@82: \parseUTFviiiA;% Chris@82: \parseUTFviiiA,% Chris@82: \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% Chris@82: \else Chris@82: \parseUTFviiiA;% Chris@82: \parseUTFviiiA,% Chris@82: \parseUTFviiiA!% Chris@82: \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% Chris@82: \fi\fi\fi Chris@82: } Chris@82: Chris@82: \gdef\parseUTFviiiA#1{% Chris@82: \countUTFx = \countUTFz Chris@82: \divide\countUTFz by 64 Chris@82: \countUTFy = \countUTFz Chris@82: \multiply\countUTFz by 64 Chris@82: \advance\countUTFx by -\countUTFz Chris@82: \advance\countUTFx by 128 Chris@82: \uccode `#1\countUTFx Chris@82: \countUTFz = \countUTFy} Chris@82: Chris@82: \gdef\parseUTFviiiB#1#2#3#4{% Chris@82: \advance\countUTFz by "#10\relax Chris@82: \uccode `#3\countUTFz Chris@82: \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} Chris@82: \endgroup Chris@82: Chris@82: \def\utfeightchardefs{% Chris@82: \DeclareUnicodeCharacter{00A0}{\tie} Chris@82: \DeclareUnicodeCharacter{00A1}{\exclamdown} Chris@82: \DeclareUnicodeCharacter{00A3}{\pounds} Chris@82: \DeclareUnicodeCharacter{00A8}{\"{ }} Chris@82: \DeclareUnicodeCharacter{00A9}{\copyright} Chris@82: \DeclareUnicodeCharacter{00AA}{\ordf} Chris@82: \DeclareUnicodeCharacter{00AB}{\guillemetleft} Chris@82: \DeclareUnicodeCharacter{00AD}{\-} Chris@82: \DeclareUnicodeCharacter{00AE}{\registeredsymbol} Chris@82: \DeclareUnicodeCharacter{00AF}{\={ }} Chris@82: Chris@82: \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} Chris@82: \DeclareUnicodeCharacter{00B4}{\'{ }} Chris@82: \DeclareUnicodeCharacter{00B8}{\cedilla{ }} Chris@82: \DeclareUnicodeCharacter{00BA}{\ordm} Chris@82: \DeclareUnicodeCharacter{00BB}{\guillemetright} Chris@82: \DeclareUnicodeCharacter{00BF}{\questiondown} Chris@82: Chris@82: \DeclareUnicodeCharacter{00C0}{\`A} Chris@82: \DeclareUnicodeCharacter{00C1}{\'A} Chris@82: \DeclareUnicodeCharacter{00C2}{\^A} Chris@82: \DeclareUnicodeCharacter{00C3}{\~A} Chris@82: \DeclareUnicodeCharacter{00C4}{\"A} Chris@82: \DeclareUnicodeCharacter{00C5}{\AA} Chris@82: \DeclareUnicodeCharacter{00C6}{\AE} Chris@82: \DeclareUnicodeCharacter{00C7}{\cedilla{C}} Chris@82: \DeclareUnicodeCharacter{00C8}{\`E} Chris@82: \DeclareUnicodeCharacter{00C9}{\'E} Chris@82: \DeclareUnicodeCharacter{00CA}{\^E} Chris@82: \DeclareUnicodeCharacter{00CB}{\"E} Chris@82: \DeclareUnicodeCharacter{00CC}{\`I} Chris@82: \DeclareUnicodeCharacter{00CD}{\'I} Chris@82: \DeclareUnicodeCharacter{00CE}{\^I} Chris@82: \DeclareUnicodeCharacter{00CF}{\"I} Chris@82: Chris@82: \DeclareUnicodeCharacter{00D0}{\DH} Chris@82: \DeclareUnicodeCharacter{00D1}{\~N} Chris@82: \DeclareUnicodeCharacter{00D2}{\`O} Chris@82: \DeclareUnicodeCharacter{00D3}{\'O} Chris@82: \DeclareUnicodeCharacter{00D4}{\^O} Chris@82: \DeclareUnicodeCharacter{00D5}{\~O} Chris@82: \DeclareUnicodeCharacter{00D6}{\"O} Chris@82: \DeclareUnicodeCharacter{00D8}{\O} Chris@82: \DeclareUnicodeCharacter{00D9}{\`U} Chris@82: \DeclareUnicodeCharacter{00DA}{\'U} Chris@82: \DeclareUnicodeCharacter{00DB}{\^U} Chris@82: \DeclareUnicodeCharacter{00DC}{\"U} Chris@82: \DeclareUnicodeCharacter{00DD}{\'Y} Chris@82: \DeclareUnicodeCharacter{00DE}{\TH} Chris@82: \DeclareUnicodeCharacter{00DF}{\ss} Chris@82: Chris@82: \DeclareUnicodeCharacter{00E0}{\`a} Chris@82: \DeclareUnicodeCharacter{00E1}{\'a} Chris@82: \DeclareUnicodeCharacter{00E2}{\^a} Chris@82: \DeclareUnicodeCharacter{00E3}{\~a} Chris@82: \DeclareUnicodeCharacter{00E4}{\"a} Chris@82: \DeclareUnicodeCharacter{00E5}{\aa} Chris@82: \DeclareUnicodeCharacter{00E6}{\ae} Chris@82: \DeclareUnicodeCharacter{00E7}{\cedilla{c}} Chris@82: \DeclareUnicodeCharacter{00E8}{\`e} Chris@82: \DeclareUnicodeCharacter{00E9}{\'e} Chris@82: \DeclareUnicodeCharacter{00EA}{\^e} Chris@82: \DeclareUnicodeCharacter{00EB}{\"e} Chris@82: \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} Chris@82: Chris@82: \DeclareUnicodeCharacter{00F0}{\dh} Chris@82: \DeclareUnicodeCharacter{00F1}{\~n} Chris@82: \DeclareUnicodeCharacter{00F2}{\`o} Chris@82: \DeclareUnicodeCharacter{00F3}{\'o} Chris@82: \DeclareUnicodeCharacter{00F4}{\^o} Chris@82: \DeclareUnicodeCharacter{00F5}{\~o} Chris@82: \DeclareUnicodeCharacter{00F6}{\"o} Chris@82: \DeclareUnicodeCharacter{00F8}{\o} Chris@82: \DeclareUnicodeCharacter{00F9}{\`u} Chris@82: \DeclareUnicodeCharacter{00FA}{\'u} Chris@82: \DeclareUnicodeCharacter{00FB}{\^u} Chris@82: \DeclareUnicodeCharacter{00FC}{\"u} Chris@82: \DeclareUnicodeCharacter{00FD}{\'y} Chris@82: \DeclareUnicodeCharacter{00FE}{\th} Chris@82: \DeclareUnicodeCharacter{00FF}{\"y} Chris@82: Chris@82: \DeclareUnicodeCharacter{0100}{\=A} Chris@82: \DeclareUnicodeCharacter{0101}{\=a} Chris@82: \DeclareUnicodeCharacter{0102}{\u{A}} Chris@82: \DeclareUnicodeCharacter{0103}{\u{a}} Chris@82: \DeclareUnicodeCharacter{0104}{\ogonek{A}} Chris@82: \DeclareUnicodeCharacter{0105}{\ogonek{a}} Chris@82: \DeclareUnicodeCharacter{0106}{\'C} Chris@82: \DeclareUnicodeCharacter{0107}{\'c} Chris@82: \DeclareUnicodeCharacter{0108}{\^C} Chris@82: \DeclareUnicodeCharacter{0109}{\^c} Chris@82: \DeclareUnicodeCharacter{0118}{\ogonek{E}} Chris@82: \DeclareUnicodeCharacter{0119}{\ogonek{e}} Chris@82: \DeclareUnicodeCharacter{010A}{\dotaccent{C}} Chris@82: \DeclareUnicodeCharacter{010B}{\dotaccent{c}} Chris@82: \DeclareUnicodeCharacter{010C}{\v{C}} Chris@82: \DeclareUnicodeCharacter{010D}{\v{c}} Chris@82: \DeclareUnicodeCharacter{010E}{\v{D}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0112}{\=E} Chris@82: \DeclareUnicodeCharacter{0113}{\=e} Chris@82: \DeclareUnicodeCharacter{0114}{\u{E}} Chris@82: \DeclareUnicodeCharacter{0115}{\u{e}} Chris@82: \DeclareUnicodeCharacter{0116}{\dotaccent{E}} Chris@82: \DeclareUnicodeCharacter{0117}{\dotaccent{e}} Chris@82: \DeclareUnicodeCharacter{011A}{\v{E}} Chris@82: \DeclareUnicodeCharacter{011B}{\v{e}} Chris@82: \DeclareUnicodeCharacter{011C}{\^G} Chris@82: \DeclareUnicodeCharacter{011D}{\^g} Chris@82: \DeclareUnicodeCharacter{011E}{\u{G}} Chris@82: \DeclareUnicodeCharacter{011F}{\u{g}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0120}{\dotaccent{G}} Chris@82: \DeclareUnicodeCharacter{0121}{\dotaccent{g}} Chris@82: \DeclareUnicodeCharacter{0124}{\^H} Chris@82: \DeclareUnicodeCharacter{0125}{\^h} Chris@82: \DeclareUnicodeCharacter{0128}{\~I} Chris@82: \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{012A}{\=I} Chris@82: \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{012C}{\u{I}} Chris@82: \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0130}{\dotaccent{I}} Chris@82: \DeclareUnicodeCharacter{0131}{\dotless{i}} Chris@82: \DeclareUnicodeCharacter{0132}{IJ} Chris@82: \DeclareUnicodeCharacter{0133}{ij} Chris@82: \DeclareUnicodeCharacter{0134}{\^J} Chris@82: \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} Chris@82: \DeclareUnicodeCharacter{0139}{\'L} Chris@82: \DeclareUnicodeCharacter{013A}{\'l} Chris@82: Chris@82: \DeclareUnicodeCharacter{0141}{\L} Chris@82: \DeclareUnicodeCharacter{0142}{\l} Chris@82: \DeclareUnicodeCharacter{0143}{\'N} Chris@82: \DeclareUnicodeCharacter{0144}{\'n} Chris@82: \DeclareUnicodeCharacter{0147}{\v{N}} Chris@82: \DeclareUnicodeCharacter{0148}{\v{n}} Chris@82: \DeclareUnicodeCharacter{014C}{\=O} Chris@82: \DeclareUnicodeCharacter{014D}{\=o} Chris@82: \DeclareUnicodeCharacter{014E}{\u{O}} Chris@82: \DeclareUnicodeCharacter{014F}{\u{o}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0150}{\H{O}} Chris@82: \DeclareUnicodeCharacter{0151}{\H{o}} Chris@82: \DeclareUnicodeCharacter{0152}{\OE} Chris@82: \DeclareUnicodeCharacter{0153}{\oe} Chris@82: \DeclareUnicodeCharacter{0154}{\'R} Chris@82: \DeclareUnicodeCharacter{0155}{\'r} Chris@82: \DeclareUnicodeCharacter{0158}{\v{R}} Chris@82: \DeclareUnicodeCharacter{0159}{\v{r}} Chris@82: \DeclareUnicodeCharacter{015A}{\'S} Chris@82: \DeclareUnicodeCharacter{015B}{\'s} Chris@82: \DeclareUnicodeCharacter{015C}{\^S} Chris@82: \DeclareUnicodeCharacter{015D}{\^s} Chris@82: \DeclareUnicodeCharacter{015E}{\cedilla{S}} Chris@82: \DeclareUnicodeCharacter{015F}{\cedilla{s}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0160}{\v{S}} Chris@82: \DeclareUnicodeCharacter{0161}{\v{s}} Chris@82: \DeclareUnicodeCharacter{0162}{\cedilla{t}} Chris@82: \DeclareUnicodeCharacter{0163}{\cedilla{T}} Chris@82: \DeclareUnicodeCharacter{0164}{\v{T}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0168}{\~U} Chris@82: \DeclareUnicodeCharacter{0169}{\~u} Chris@82: \DeclareUnicodeCharacter{016A}{\=U} Chris@82: \DeclareUnicodeCharacter{016B}{\=u} Chris@82: \DeclareUnicodeCharacter{016C}{\u{U}} Chris@82: \DeclareUnicodeCharacter{016D}{\u{u}} Chris@82: \DeclareUnicodeCharacter{016E}{\ringaccent{U}} Chris@82: \DeclareUnicodeCharacter{016F}{\ringaccent{u}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0170}{\H{U}} Chris@82: \DeclareUnicodeCharacter{0171}{\H{u}} Chris@82: \DeclareUnicodeCharacter{0174}{\^W} Chris@82: \DeclareUnicodeCharacter{0175}{\^w} Chris@82: \DeclareUnicodeCharacter{0176}{\^Y} Chris@82: \DeclareUnicodeCharacter{0177}{\^y} Chris@82: \DeclareUnicodeCharacter{0178}{\"Y} Chris@82: \DeclareUnicodeCharacter{0179}{\'Z} Chris@82: \DeclareUnicodeCharacter{017A}{\'z} Chris@82: \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} Chris@82: \DeclareUnicodeCharacter{017C}{\dotaccent{z}} Chris@82: \DeclareUnicodeCharacter{017D}{\v{Z}} Chris@82: \DeclareUnicodeCharacter{017E}{\v{z}} Chris@82: Chris@82: \DeclareUnicodeCharacter{01C4}{D\v{Z}} Chris@82: \DeclareUnicodeCharacter{01C5}{D\v{z}} Chris@82: \DeclareUnicodeCharacter{01C6}{d\v{z}} Chris@82: \DeclareUnicodeCharacter{01C7}{LJ} Chris@82: \DeclareUnicodeCharacter{01C8}{Lj} Chris@82: \DeclareUnicodeCharacter{01C9}{lj} Chris@82: \DeclareUnicodeCharacter{01CA}{NJ} Chris@82: \DeclareUnicodeCharacter{01CB}{Nj} Chris@82: \DeclareUnicodeCharacter{01CC}{nj} Chris@82: \DeclareUnicodeCharacter{01CD}{\v{A}} Chris@82: \DeclareUnicodeCharacter{01CE}{\v{a}} Chris@82: \DeclareUnicodeCharacter{01CF}{\v{I}} Chris@82: Chris@82: \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} Chris@82: \DeclareUnicodeCharacter{01D1}{\v{O}} Chris@82: \DeclareUnicodeCharacter{01D2}{\v{o}} Chris@82: \DeclareUnicodeCharacter{01D3}{\v{U}} Chris@82: \DeclareUnicodeCharacter{01D4}{\v{u}} Chris@82: Chris@82: \DeclareUnicodeCharacter{01E2}{\={\AE}} Chris@82: \DeclareUnicodeCharacter{01E3}{\={\ae}} Chris@82: \DeclareUnicodeCharacter{01E6}{\v{G}} Chris@82: \DeclareUnicodeCharacter{01E7}{\v{g}} Chris@82: \DeclareUnicodeCharacter{01E8}{\v{K}} Chris@82: \DeclareUnicodeCharacter{01E9}{\v{k}} Chris@82: Chris@82: \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} Chris@82: \DeclareUnicodeCharacter{01F1}{DZ} Chris@82: \DeclareUnicodeCharacter{01F2}{Dz} Chris@82: \DeclareUnicodeCharacter{01F3}{dz} Chris@82: \DeclareUnicodeCharacter{01F4}{\'G} Chris@82: \DeclareUnicodeCharacter{01F5}{\'g} Chris@82: \DeclareUnicodeCharacter{01F8}{\`N} Chris@82: \DeclareUnicodeCharacter{01F9}{\`n} Chris@82: \DeclareUnicodeCharacter{01FC}{\'{\AE}} Chris@82: \DeclareUnicodeCharacter{01FD}{\'{\ae}} Chris@82: \DeclareUnicodeCharacter{01FE}{\'{\O}} Chris@82: \DeclareUnicodeCharacter{01FF}{\'{\o}} Chris@82: Chris@82: \DeclareUnicodeCharacter{021E}{\v{H}} Chris@82: \DeclareUnicodeCharacter{021F}{\v{h}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0226}{\dotaccent{A}} Chris@82: \DeclareUnicodeCharacter{0227}{\dotaccent{a}} Chris@82: \DeclareUnicodeCharacter{0228}{\cedilla{E}} Chris@82: \DeclareUnicodeCharacter{0229}{\cedilla{e}} Chris@82: \DeclareUnicodeCharacter{022E}{\dotaccent{O}} Chris@82: \DeclareUnicodeCharacter{022F}{\dotaccent{o}} Chris@82: Chris@82: \DeclareUnicodeCharacter{0232}{\=Y} Chris@82: \DeclareUnicodeCharacter{0233}{\=y} Chris@82: \DeclareUnicodeCharacter{0237}{\dotless{j}} Chris@82: Chris@82: \DeclareUnicodeCharacter{02DB}{\ogonek{ }} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} Chris@82: \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} Chris@82: \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} Chris@82: \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} Chris@82: \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} Chris@82: \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} Chris@82: \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} Chris@82: \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} Chris@82: \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} Chris@82: \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} Chris@82: \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} Chris@82: \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} Chris@82: \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E20}{\=G} Chris@82: \DeclareUnicodeCharacter{1E21}{\=g} Chris@82: \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} Chris@82: \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} Chris@82: \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} Chris@82: \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} Chris@82: \DeclareUnicodeCharacter{1E26}{\"H} Chris@82: \DeclareUnicodeCharacter{1E27}{\"h} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E30}{\'K} Chris@82: \DeclareUnicodeCharacter{1E31}{\'k} Chris@82: \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} Chris@82: \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} Chris@82: \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} Chris@82: \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} Chris@82: \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} Chris@82: \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} Chris@82: \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} Chris@82: \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} Chris@82: \DeclareUnicodeCharacter{1E3E}{\'M} Chris@82: \DeclareUnicodeCharacter{1E3F}{\'m} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} Chris@82: \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} Chris@82: \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} Chris@82: \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} Chris@82: \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} Chris@82: \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} Chris@82: \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} Chris@82: \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} Chris@82: \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} Chris@82: \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E54}{\'P} Chris@82: \DeclareUnicodeCharacter{1E55}{\'p} Chris@82: \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} Chris@82: \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} Chris@82: \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} Chris@82: \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} Chris@82: \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} Chris@82: \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} Chris@82: \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} Chris@82: \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} Chris@82: \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} Chris@82: \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} Chris@82: \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} Chris@82: \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} Chris@82: \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} Chris@82: \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} Chris@82: \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} Chris@82: \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} Chris@82: \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E7C}{\~V} Chris@82: \DeclareUnicodeCharacter{1E7D}{\~v} Chris@82: \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} Chris@82: \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E80}{\`W} Chris@82: \DeclareUnicodeCharacter{1E81}{\`w} Chris@82: \DeclareUnicodeCharacter{1E82}{\'W} Chris@82: \DeclareUnicodeCharacter{1E83}{\'w} Chris@82: \DeclareUnicodeCharacter{1E84}{\"W} Chris@82: \DeclareUnicodeCharacter{1E85}{\"w} Chris@82: \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} Chris@82: \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} Chris@82: \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} Chris@82: \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} Chris@82: \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} Chris@82: \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} Chris@82: \DeclareUnicodeCharacter{1E8C}{\"X} Chris@82: \DeclareUnicodeCharacter{1E8D}{\"x} Chris@82: \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} Chris@82: \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1E90}{\^Z} Chris@82: \DeclareUnicodeCharacter{1E91}{\^z} Chris@82: \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} Chris@82: \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} Chris@82: \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} Chris@82: \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} Chris@82: \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} Chris@82: \DeclareUnicodeCharacter{1E97}{\"t} Chris@82: \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} Chris@82: \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} Chris@82: \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} Chris@82: \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} Chris@82: \DeclareUnicodeCharacter{1EBC}{\~E} Chris@82: \DeclareUnicodeCharacter{1EBD}{\~e} Chris@82: Chris@82: \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} Chris@82: \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} Chris@82: \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} Chris@82: \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} Chris@82: \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1EF2}{\`Y} Chris@82: \DeclareUnicodeCharacter{1EF3}{\`y} Chris@82: \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} Chris@82: Chris@82: \DeclareUnicodeCharacter{1EF8}{\~Y} Chris@82: \DeclareUnicodeCharacter{1EF9}{\~y} Chris@82: Chris@82: \DeclareUnicodeCharacter{2013}{--} Chris@82: \DeclareUnicodeCharacter{2014}{---} Chris@82: \DeclareUnicodeCharacter{2018}{\quoteleft} Chris@82: \DeclareUnicodeCharacter{2019}{\quoteright} Chris@82: \DeclareUnicodeCharacter{201A}{\quotesinglbase} Chris@82: \DeclareUnicodeCharacter{201C}{\quotedblleft} Chris@82: \DeclareUnicodeCharacter{201D}{\quotedblright} Chris@82: \DeclareUnicodeCharacter{201E}{\quotedblbase} Chris@82: \DeclareUnicodeCharacter{2022}{\bullet} Chris@82: \DeclareUnicodeCharacter{2026}{\dots} Chris@82: \DeclareUnicodeCharacter{2039}{\guilsinglleft} Chris@82: \DeclareUnicodeCharacter{203A}{\guilsinglright} Chris@82: \DeclareUnicodeCharacter{20AC}{\euro} Chris@82: Chris@82: \DeclareUnicodeCharacter{2192}{\expansion} Chris@82: \DeclareUnicodeCharacter{21D2}{\result} Chris@82: Chris@82: \DeclareUnicodeCharacter{2212}{\minus} Chris@82: \DeclareUnicodeCharacter{2217}{\point} Chris@82: \DeclareUnicodeCharacter{2261}{\equiv} Chris@82: }% end of \utfeightchardefs Chris@82: Chris@82: Chris@82: % US-ASCII character definitions. Chris@82: \def\asciichardefs{% nothing need be done Chris@82: \relax Chris@82: } Chris@82: Chris@82: % Make non-ASCII characters printable again for compatibility with Chris@82: % existing Texinfo documents that may use them, even without declaring a Chris@82: % document encoding. Chris@82: % Chris@82: \setnonasciicharscatcode \other Chris@82: Chris@82: Chris@82: \message{formatting,} Chris@82: Chris@82: \newdimen\defaultparindent \defaultparindent = 15pt Chris@82: Chris@82: \chapheadingskip = 15pt plus 4pt minus 2pt Chris@82: \secheadingskip = 12pt plus 3pt minus 2pt Chris@82: \subsecheadingskip = 9pt plus 2pt minus 2pt Chris@82: Chris@82: % Prevent underfull vbox error messages. Chris@82: \vbadness = 10000 Chris@82: Chris@82: % Don't be very finicky about underfull hboxes, either. Chris@82: \hbadness = 6666 Chris@82: Chris@82: % Following George Bush, get rid of widows and orphans. Chris@82: \widowpenalty=10000 Chris@82: \clubpenalty=10000 Chris@82: Chris@82: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're Chris@82: % using an old version of TeX, don't do anything. We want the amount of Chris@82: % stretch added to depend on the line length, hence the dependence on Chris@82: % \hsize. We call this whenever the paper size is set. Chris@82: % Chris@82: \def\setemergencystretch{% Chris@82: \ifx\emergencystretch\thisisundefined Chris@82: % Allow us to assign to \emergencystretch anyway. Chris@82: \def\emergencystretch{\dimen0}% Chris@82: \else Chris@82: \emergencystretch = .15\hsize Chris@82: \fi Chris@82: } Chris@82: Chris@82: % Parameters in order: 1) textheight; 2) textwidth; Chris@82: % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; Chris@82: % 7) physical page height; 8) physical page width. Chris@82: % Chris@82: % We also call \setleading{\textleading}, so the caller should define Chris@82: % \textleading. The caller should also set \parskip. Chris@82: % Chris@82: \def\internalpagesizes#1#2#3#4#5#6#7#8{% Chris@82: \voffset = #3\relax Chris@82: \topskip = #6\relax Chris@82: \splittopskip = \topskip Chris@82: % Chris@82: \vsize = #1\relax Chris@82: \advance\vsize by \topskip Chris@82: \outervsize = \vsize Chris@82: \advance\outervsize by 2\topandbottommargin Chris@82: \pageheight = \vsize Chris@82: % Chris@82: \hsize = #2\relax Chris@82: \outerhsize = \hsize Chris@82: \advance\outerhsize by 0.5in Chris@82: \pagewidth = \hsize Chris@82: % Chris@82: \normaloffset = #4\relax Chris@82: \bindingoffset = #5\relax Chris@82: % Chris@82: \ifpdf Chris@82: \pdfpageheight #7\relax Chris@82: \pdfpagewidth #8\relax Chris@82: % if we don't reset these, they will remain at "1 true in" of Chris@82: % whatever layout pdftex was dumped with. Chris@82: \pdfhorigin = 1 true in Chris@82: \pdfvorigin = 1 true in Chris@82: \fi Chris@82: % Chris@82: \setleading{\textleading} Chris@82: % Chris@82: \parindent = \defaultparindent Chris@82: \setemergencystretch Chris@82: } Chris@82: Chris@82: % @letterpaper (the default). Chris@82: \def\letterpaper{{\globaldefs = 1 Chris@82: \parskip = 3pt plus 2pt minus 1pt Chris@82: \textleading = 13.2pt Chris@82: % Chris@82: % If page is nothing but text, make it come out even. Chris@82: \internalpagesizes{607.2pt}{6in}% that's 46 lines Chris@82: {\voffset}{.25in}% Chris@82: {\bindingoffset}{36pt}% Chris@82: {11in}{8.5in}% Chris@82: }} Chris@82: Chris@82: % Use @smallbook to reset parameters for 7x9.25 trim size. Chris@82: \def\smallbook{{\globaldefs = 1 Chris@82: \parskip = 2pt plus 1pt Chris@82: \textleading = 12pt Chris@82: % Chris@82: \internalpagesizes{7.5in}{5in}% Chris@82: {-.2in}{0in}% Chris@82: {\bindingoffset}{16pt}% Chris@82: {9.25in}{7in}% Chris@82: % Chris@82: \lispnarrowing = 0.3in Chris@82: \tolerance = 700 Chris@82: \hfuzz = 1pt Chris@82: \contentsrightmargin = 0pt Chris@82: \defbodyindent = .5cm Chris@82: }} Chris@82: Chris@82: % Use @smallerbook to reset parameters for 6x9 trim size. Chris@82: % (Just testing, parameters still in flux.) Chris@82: \def\smallerbook{{\globaldefs = 1 Chris@82: \parskip = 1.5pt plus 1pt Chris@82: \textleading = 12pt Chris@82: % Chris@82: \internalpagesizes{7.4in}{4.8in}% Chris@82: {-.2in}{-.4in}% Chris@82: {0pt}{14pt}% Chris@82: {9in}{6in}% Chris@82: % Chris@82: \lispnarrowing = 0.25in Chris@82: \tolerance = 700 Chris@82: \hfuzz = 1pt Chris@82: \contentsrightmargin = 0pt Chris@82: \defbodyindent = .4cm Chris@82: }} Chris@82: Chris@82: % Use @afourpaper to print on European A4 paper. Chris@82: \def\afourpaper{{\globaldefs = 1 Chris@82: \parskip = 3pt plus 2pt minus 1pt Chris@82: \textleading = 13.2pt Chris@82: % Chris@82: % Double-side printing via postscript on Laserjet 4050 Chris@82: % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. Chris@82: % To change the settings for a different printer or situation, adjust Chris@82: % \normaloffset until the front-side and back-side texts align. Then Chris@82: % do the same for \bindingoffset. You can set these for testing in Chris@82: % your texinfo source file like this: Chris@82: % @tex Chris@82: % \global\normaloffset = -6mm Chris@82: % \global\bindingoffset = 10mm Chris@82: % @end tex Chris@82: \internalpagesizes{673.2pt}{160mm}% that's 51 lines Chris@82: {\voffset}{\hoffset}% Chris@82: {\bindingoffset}{44pt}% Chris@82: {297mm}{210mm}% Chris@82: % Chris@82: \tolerance = 700 Chris@82: \hfuzz = 1pt Chris@82: \contentsrightmargin = 0pt Chris@82: \defbodyindent = 5mm Chris@82: }} Chris@82: Chris@82: % Use @afivepaper to print on European A5 paper. Chris@82: % From romildo@urano.iceb.ufop.br, 2 July 2000. Chris@82: % He also recommends making @example and @lisp be small. Chris@82: \def\afivepaper{{\globaldefs = 1 Chris@82: \parskip = 2pt plus 1pt minus 0.1pt Chris@82: \textleading = 12.5pt Chris@82: % Chris@82: \internalpagesizes{160mm}{120mm}% Chris@82: {\voffset}{\hoffset}% Chris@82: {\bindingoffset}{8pt}% Chris@82: {210mm}{148mm}% Chris@82: % Chris@82: \lispnarrowing = 0.2in Chris@82: \tolerance = 800 Chris@82: \hfuzz = 1.2pt Chris@82: \contentsrightmargin = 0pt Chris@82: \defbodyindent = 2mm Chris@82: \tableindent = 12mm Chris@82: }} Chris@82: Chris@82: % A specific text layout, 24x15cm overall, intended for A4 paper. Chris@82: \def\afourlatex{{\globaldefs = 1 Chris@82: \afourpaper Chris@82: \internalpagesizes{237mm}{150mm}% Chris@82: {\voffset}{4.6mm}% Chris@82: {\bindingoffset}{7mm}% Chris@82: {297mm}{210mm}% Chris@82: % Chris@82: % Must explicitly reset to 0 because we call \afourpaper. Chris@82: \globaldefs = 0 Chris@82: }} Chris@82: Chris@82: % Use @afourwide to print on A4 paper in landscape format. Chris@82: \def\afourwide{{\globaldefs = 1 Chris@82: \afourpaper Chris@82: \internalpagesizes{241mm}{165mm}% Chris@82: {\voffset}{-2.95mm}% Chris@82: {\bindingoffset}{7mm}% Chris@82: {297mm}{210mm}% Chris@82: \globaldefs = 0 Chris@82: }} Chris@82: Chris@82: % @pagesizes TEXTHEIGHT[,TEXTWIDTH] Chris@82: % Perhaps we should allow setting the margins, \topskip, \parskip, Chris@82: % and/or leading, also. Or perhaps we should compute them somehow. Chris@82: % Chris@82: \parseargdef\pagesizes{\pagesizesyyy #1,,\finish} Chris@82: \def\pagesizesyyy#1,#2,#3\finish{{% Chris@82: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi Chris@82: \globaldefs = 1 Chris@82: % Chris@82: \parskip = 3pt plus 2pt minus 1pt Chris@82: \setleading{\textleading}% Chris@82: % Chris@82: \dimen0 = #1\relax Chris@82: \advance\dimen0 by \voffset Chris@82: % Chris@82: \dimen2 = \hsize Chris@82: \advance\dimen2 by \normaloffset Chris@82: % Chris@82: \internalpagesizes{#1}{\hsize}% Chris@82: {\voffset}{\normaloffset}% Chris@82: {\bindingoffset}{44pt}% Chris@82: {\dimen0}{\dimen2}% Chris@82: }} Chris@82: Chris@82: % Set default to letter. Chris@82: % Chris@82: \letterpaper Chris@82: Chris@82: Chris@82: \message{and turning on texinfo input format.} Chris@82: Chris@82: \def^^L{\par} % remove \outer, so ^L can appear in an @comment Chris@82: Chris@82: % DEL is a comment character, in case @c does not suffice. Chris@82: \catcode`\^^? = 14 Chris@82: Chris@82: % Define macros to output various characters with catcode for normal text. Chris@82: \catcode`\"=\other \def\normaldoublequote{"} Chris@82: \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix Chris@82: \catcode`\+=\other \def\normalplus{+} Chris@82: \catcode`\<=\other \def\normalless{<} Chris@82: \catcode`\>=\other \def\normalgreater{>} Chris@82: \catcode`\^=\other \def\normalcaret{^} Chris@82: \catcode`\_=\other \def\normalunderscore{_} Chris@82: \catcode`\|=\other \def\normalverticalbar{|} Chris@82: \catcode`\~=\other \def\normaltilde{~} Chris@82: Chris@82: % This macro is used to make a character print one way in \tt Chris@82: % (where it can probably be output as-is), and another way in other fonts, Chris@82: % where something hairier probably needs to be done. Chris@82: % Chris@82: % #1 is what to print if we are indeed using \tt; #2 is what to print Chris@82: % otherwise. Since all the Computer Modern typewriter fonts have zero Chris@82: % interword stretch (and shrink), and it is reasonable to expect all Chris@82: % typewriter fonts to have this, we can check that font parameter. Chris@82: % Chris@82: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} Chris@82: Chris@82: % Same as above, but check for italic font. Actually this also catches Chris@82: % non-italic slanted fonts since it is impossible to distinguish them from Chris@82: % italic fonts. But since this is only used by $ and it uses \sl anyway Chris@82: % this is not a problem. Chris@82: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} Chris@82: Chris@82: % Turn off all special characters except @ Chris@82: % (and those which the user can use as if they were ordinary). Chris@82: % Most of these we simply print from the \tt font, but for some, we can Chris@82: % use math or other variants that look better in normal text. Chris@82: Chris@82: \catcode`\"=\active Chris@82: \def\activedoublequote{{\tt\char34}} Chris@82: \let"=\activedoublequote Chris@82: \catcode`\~=\active Chris@82: \def~{{\tt\char126}} Chris@82: \chardef\hat=`\^ Chris@82: \catcode`\^=\active Chris@82: \def^{{\tt \hat}} Chris@82: Chris@82: \catcode`\_=\active Chris@82: \def_{\ifusingtt\normalunderscore\_} Chris@82: \let\realunder=_ Chris@82: % Subroutine for the previous macro. Chris@82: \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } Chris@82: Chris@82: \catcode`\|=\active Chris@82: \def|{{\tt\char124}} Chris@82: \chardef \less=`\< Chris@82: \catcode`\<=\active Chris@82: \def<{{\tt \less}} Chris@82: \chardef \gtr=`\> Chris@82: \catcode`\>=\active Chris@82: \def>{{\tt \gtr}} Chris@82: \catcode`\+=\active Chris@82: \def+{{\tt \char 43}} Chris@82: \catcode`\$=\active Chris@82: \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix Chris@82: Chris@82: % If a .fmt file is being used, characters that might appear in a file Chris@82: % name cannot be active until we have parsed the command line. Chris@82: % So turn them off again, and have \everyjob (or @setfilename) turn them on. Chris@82: % \otherifyactive is called near the end of this file. Chris@82: \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} Chris@82: Chris@82: % Used sometimes to turn off (effectively) the active characters even after Chris@82: % parsing them. Chris@82: \def\turnoffactive{% Chris@82: \normalturnoffactive Chris@82: \otherbackslash Chris@82: } Chris@82: Chris@82: \catcode`\@=0 Chris@82: Chris@82: % \backslashcurfont outputs one backslash character in current font, Chris@82: % as in \char`\\. Chris@82: \global\chardef\backslashcurfont=`\\ Chris@82: \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work Chris@82: Chris@82: % \realbackslash is an actual character `\' with catcode other, and Chris@82: % \doublebackslash is two of them (for the pdf outlines). Chris@82: {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} Chris@82: Chris@82: % In texinfo, backslash is an active character; it prints the backslash Chris@82: % in fixed width font. Chris@82: \catcode`\\=\active % @ for escape char from now on. Chris@82: Chris@82: % The story here is that in math mode, the \char of \backslashcurfont Chris@82: % ends up printing the roman \ from the math symbol font (because \char Chris@82: % in math mode uses the \mathcode, and plain.tex sets Chris@82: % \mathcode`\\="026E). It seems better for @backslashchar{} to always Chris@82: % print a typewriter backslash, hence we use an explicit \mathchar, Chris@82: % which is the decimal equivalent of "715c (class 7, e.g., use \fam; Chris@82: % ignored family value; char position "5C). We can't use " for the Chris@82: % usual hex value because it has already been made active. Chris@82: @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} Chris@82: @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. Chris@82: Chris@82: % On startup, @fixbackslash assigns: Chris@82: % @let \ = @normalbackslash Chris@82: % \rawbackslash defines an active \ to do \backslashcurfont. Chris@82: % \otherbackslash defines an active \ to be a literal `\' character with Chris@82: % catcode other. We switch back and forth between these. Chris@82: @gdef@rawbackslash{@let\=@backslashcurfont} Chris@82: @gdef@otherbackslash{@let\=@realbackslash} Chris@82: Chris@82: % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of Chris@82: % the literal character `\'. Also revert - to its normal character, in Chris@82: % case the active - from code has slipped in. Chris@82: % Chris@82: {@catcode`- = @active Chris@82: @gdef@normalturnoffactive{% Chris@82: @let-=@normaldash Chris@82: @let"=@normaldoublequote Chris@82: @let$=@normaldollar %$ font-lock fix Chris@82: @let+=@normalplus Chris@82: @let<=@normalless Chris@82: @let>=@normalgreater Chris@82: @let\=@normalbackslash Chris@82: @let^=@normalcaret Chris@82: @let_=@normalunderscore Chris@82: @let|=@normalverticalbar Chris@82: @let~=@normaltilde Chris@82: @markupsetuplqdefault Chris@82: @markupsetuprqdefault Chris@82: @unsepspaces Chris@82: } Chris@82: } Chris@82: Chris@82: % Make _ and + \other characters, temporarily. Chris@82: % This is canceled by @fixbackslash. Chris@82: @otherifyactive Chris@82: Chris@82: % If a .fmt file is being used, we don't want the `\input texinfo' to show up. Chris@82: % That is what \eatinput is for; after that, the `\' should revert to printing Chris@82: % a backslash. Chris@82: % Chris@82: @gdef@eatinput input texinfo{@fixbackslash} Chris@82: @global@let\ = @eatinput Chris@82: Chris@82: % On the other hand, perhaps the file did not have a `\input texinfo'. Then Chris@82: % the first `\' in the file would cause an error. This macro tries to fix Chris@82: % that, assuming it is called before the first `\' could plausibly occur. Chris@82: % Also turn back on active characters that might appear in the input Chris@82: % file name, in case not using a pre-dumped format. Chris@82: % Chris@82: @gdef@fixbackslash{% Chris@82: @ifx\@eatinput @let\ = @normalbackslash @fi Chris@82: @catcode`+=@active Chris@82: @catcode`@_=@active Chris@82: } Chris@82: Chris@82: % Say @foo, not \foo, in error messages. Chris@82: @escapechar = `@@ Chris@82: Chris@82: % These (along with & and #) are made active for url-breaking, so need Chris@82: % active definitions as the normal characters. Chris@82: @def@normaldot{.} Chris@82: @def@normalquest{?} Chris@82: @def@normalslash{/} Chris@82: Chris@82: % These look ok in all fonts, so just make them not special. Chris@82: % @hashchar{} gets its own user-level command, because of #line. Chris@82: @catcode`@& = @other @def@normalamp{&} Chris@82: @catcode`@# = @other @def@normalhash{#} Chris@82: @catcode`@% = @other @def@normalpercent{%} Chris@82: Chris@82: @let @hashchar = @normalhash Chris@82: Chris@82: @c Finally, make ` and ' active, so that txicodequoteundirected and Chris@82: @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we Chris@82: @c don't make ` and ' active, @code will not get them as active chars. Chris@82: @c Do this last of all since we use ` in the previous @catcode assignments. Chris@82: @catcode`@'=@active Chris@82: @catcode`@`=@active Chris@82: @markupsetuplqdefault Chris@82: @markupsetuprqdefault Chris@82: Chris@82: @c Local variables: Chris@82: @c eval: (add-hook 'write-file-hooks 'time-stamp) Chris@82: @c page-delimiter: "^\\\\message" Chris@82: @c time-stamp-start: "def\\\\texinfoversion{" Chris@82: @c time-stamp-format: "%:y-%02m-%02d.%02H" Chris@82: @c time-stamp-end: "}" Chris@82: @c End: Chris@82: Chris@82: @c vim:sw=2: Chris@82: Chris@82: @ignore Chris@82: arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 Chris@82: @end ignore