texinfo.tex 179 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484
  1. % texinfo.tex -- TeX macros to handle Texinfo files.
  2. %
  3. % Load plain if necessary, i.e., if running under initex.
  4. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
  5. %
  6. \def\texinfoversion{1999-01-05}%
  7. %
  8. % Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98
  9. % Free Software Foundation, Inc.
  10. %
  11. % This texinfo.tex file is free software; you can redistribute it and/or
  12. % modify it under the terms of the GNU General Public License as
  13. % published by the Free Software Foundation; either version 2, or (at
  14. % your option) any later version.
  15. %
  16. % This texinfo.tex file is distributed in the hope that it will be
  17. % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  18. % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. % General Public License for more details.
  20. %
  21. % You should have received a copy of the GNU General Public License
  22. % along with this texinfo.tex file; see the file COPYING. If not, write
  23. % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. % Boston, MA 02111-1307, USA.
  25. %
  26. % In other words, you are welcome to use, share and improve this program.
  27. % You are forbidden to forbid anyone else to use, share and improve
  28. % what you give them. Help stamp out software-hoarding!
  29. %
  30. % Please try the latest version of texinfo.tex before submitting bug
  31. % reports; you can get the latest version from:
  32. % ftp://ftp.gnu.org/pub/gnu/texinfo.tex
  33. % /home/gd/gnu/doc/texinfo.tex on the GNU machines.
  34. % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
  35. % ftp://tug.org/tex/texinfo.tex
  36. % ftp://ctan.org/macros/texinfo/texinfo.tex
  37. % (and all CTAN mirrors, finger ctan@ctan.org for a list).
  38. % The texinfo.tex in the texinfo distribution itself could well be out
  39. % of date, so if that's what you're using, please check.
  40. %
  41. % Send bug reports to bug-texinfo@gnu.org.
  42. % Please include a precise test case in each bug report,
  43. % including a complete document with which we can reproduce the problem.
  44. %
  45. % To process a Texinfo manual with TeX, it's most reliable to use the
  46. % texi2dvi shell script that comes with the distribution. For simple
  47. % manuals, however, you can get away with:
  48. % tex foo.texi
  49. % texindex foo.??
  50. % tex foo.texi
  51. % tex foo.texi
  52. % dvips foo.dvi -o # or whatever, to process the dvi file.
  53. % The extra runs of TeX get the cross-reference information correct.
  54. % Sometimes one run after texindex suffices, and sometimes you need more
  55. % than two; texi2dvi does it as many times as necessary.
  56. \message{Loading texinfo [version \texinfoversion]:}
  57. % If in a .fmt file, print the version number
  58. % and turn on active characters that we couldn't do earlier because
  59. % they might have appeared in the input file name.
  60. \everyjob{\message{[Texinfo version \texinfoversion]}%
  61. \catcode`+=\active \catcode`\_=\active}
  62. % Save some parts of plain tex whose names we will redefine.
  63. \let\ptexb=\b
  64. \let\ptexbullet=\bullet
  65. \let\ptexc=\c
  66. \let\ptexcomma=\,
  67. \let\ptexdot=\.
  68. \let\ptexdots=\dots
  69. \let\ptexend=\end
  70. \let\ptexequiv=\equiv
  71. \let\ptexexclam=\!
  72. \let\ptexi=\i
  73. \let\ptexlbrace=\{
  74. \let\ptexrbrace=\}
  75. \let\ptexstar=\*
  76. \let\ptext=\t
  77. % We never want plain's outer \+ definition in Texinfo.
  78. % For @tex, we can use \tabalign.
  79. \let\+ = \relax
  80. \message{Basics,}
  81. \chardef\other=12
  82. % If this character appears in an error message or help string, it
  83. % starts a new line in the output.
  84. \newlinechar = `^^J
  85. % Set up fixed words for English if not already set.
  86. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
  87. \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
  88. \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
  89. \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
  90. \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
  91. \ifx\putwordon\undefined \gdef\putwordon{on}\fi
  92. \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
  93. \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
  94. \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
  95. \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
  96. \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
  97. \ifx\putwordShortContents\undefined \gdef\putwordShortContents{Short Contents}\fi
  98. \ifx\putwordTableofContents\undefined\gdef\putwordTableofContents{Table of Contents}\fi
  99. % Ignore a token.
  100. %
  101. \def\gobble#1{}
  102. \hyphenation{ap-pen-dix}
  103. \hyphenation{mini-buf-fer mini-buf-fers}
  104. \hyphenation{eshell}
  105. \hyphenation{white-space}
  106. % Margin to add to right of even pages, to left of odd pages.
  107. \newdimen \bindingoffset
  108. \newdimen \normaloffset
  109. \newdimen\pagewidth \newdimen\pageheight
  110. % Sometimes it is convenient to have everything in the transcript file
  111. % and nothing on the terminal. We don't just call \tracingall here,
  112. % since that produces some useless output on the terminal.
  113. %
  114. \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
  115. \ifx\eTeXversion\undefined
  116. \def\loggingall{\tracingcommands2 \tracingstats2
  117. \tracingpages1 \tracingoutput1 \tracinglostchars1
  118. \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  119. \showboxbreadth\maxdimen\showboxdepth\maxdimen
  120. }%
  121. \else
  122. \def\loggingall{\tracingcommands3 \tracingstats2
  123. \tracingpages1 \tracingoutput1 \tracinglostchars1
  124. \tracingmacros2 \tracingparagraphs1 \tracingrestores1
  125. \tracingscantokens1 \tracingassigns1 \tracingifs1
  126. \tracinggroups1 \tracingnesting2
  127. \showboxbreadth\maxdimen\showboxdepth\maxdimen
  128. }%
  129. \fi
  130. % For @cropmarks command.
  131. % Do @cropmarks to get crop marks.
  132. %
  133. \newif\ifcropmarks
  134. \let\cropmarks = \cropmarkstrue
  135. %
  136. % Dimensions to add cropmarks at corners.
  137. % Added by P. A. MacKay, 12 Nov. 1986
  138. %
  139. \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
  140. \newdimen\cornerlong \cornerlong=1pc
  141. \newdimen\cornerthick \cornerthick=.3pt
  142. \newdimen\topandbottommargin \topandbottommargin=.75in
  143. % Main output routine.
  144. \chardef\PAGE = 255
  145. \output = {\onepageout{\pagecontents\PAGE}}
  146. \newbox\headlinebox
  147. \newbox\footlinebox
  148. % \onepageout takes a vbox as an argument. Note that \pagecontents
  149. % does insertions, but you have to call it yourself.
  150. \def\onepageout#1{%
  151. \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
  152. %
  153. \ifodd\pageno \advance\hoffset by \bindingoffset
  154. \else \advance\hoffset by -\bindingoffset\fi
  155. %
  156. % Do this outside of the \shipout so @code etc. will be expanded in
  157. % the headline as they should be, not taken literally (outputting ''code).
  158. \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
  159. \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
  160. %
  161. {%
  162. % Have to do this stuff outside the \shipout because we want it to
  163. % take effect in \write's, yet the group defined by the \vbox ends
  164. % before the \shipout runs.
  165. %
  166. \escapechar = `\\ % use backslash in output files.
  167. \indexdummies % don't expand commands in the output.
  168. \normalturnoffactive % \ in index entries must not stay \, e.g., if
  169. % the page break happens to be in the middle of an example.
  170. \shipout\vbox{%
  171. \ifcropmarks \vbox to \outervsize\bgroup
  172. \hsize = \outerhsize
  173. \vskip-\topandbottommargin
  174. \vtop to0pt{%
  175. \line{\ewtop\hfil\ewtop}%
  176. \nointerlineskip
  177. \line{%
  178. \vbox{\moveleft\cornerthick\nstop}%
  179. \hfill
  180. \vbox{\moveright\cornerthick\nstop}%
  181. }%
  182. \vss}%
  183. \vskip\topandbottommargin
  184. \line\bgroup
  185. \hfil % center the page within the outer (page) hsize.
  186. \ifodd\pageno\hskip\bindingoffset\fi
  187. \vbox\bgroup
  188. \fi
  189. %
  190. \unvbox\headlinebox
  191. \pagebody{#1}%
  192. \ifdim\ht\footlinebox > 0pt
  193. % Only leave this space if the footline is nonempty.
  194. % (We lessened \vsize for it in \oddfootingxxx.)
  195. % The \baselineskip=24pt in plain's \makefootline has no effect.
  196. \vskip 2\baselineskip
  197. \unvbox\footlinebox
  198. \fi
  199. %
  200. \ifcropmarks
  201. \egroup % end of \vbox\bgroup
  202. \hfil\egroup % end of (centering) \line\bgroup
  203. \vskip\topandbottommargin plus1fill minus1fill
  204. \boxmaxdepth = \cornerthick
  205. \vbox to0pt{\vss
  206. \line{%
  207. \vbox{\moveleft\cornerthick\nsbot}%
  208. \hfill
  209. \vbox{\moveright\cornerthick\nsbot}%
  210. }%
  211. \nointerlineskip
  212. \line{\ewbot\hfil\ewbot}%
  213. }%
  214. \egroup % \vbox from first cropmarks clause
  215. \fi
  216. }% end of \shipout\vbox
  217. }% end of group with \turnoffactive
  218. \advancepageno
  219. \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  220. }
  221. \newinsert\margin \dimen\margin=\maxdimen
  222. \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  223. {\catcode`\@ =11
  224. \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  225. % marginal hacks, juha@viisa.uucp (Juha Takala)
  226. \ifvoid\margin\else % marginal info is present
  227. \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
  228. \dimen@=\dp#1 \unvbox#1
  229. \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
  230. \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  231. }
  232. % Here are the rules for the cropmarks. Note that they are
  233. % offset so that the space between them is truly \outerhsize or \outervsize
  234. % (P. A. MacKay, 12 November, 1986)
  235. %
  236. \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
  237. \def\nstop{\vbox
  238. {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
  239. \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
  240. \def\nsbot{\vbox
  241. {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  242. % Parse an argument, then pass it to #1. The argument is the rest of
  243. % the input line (except we remove a trailing comment). #1 should be a
  244. % macro which expects an ordinary undelimited TeX argument.
  245. %
  246. \def\parsearg#1{%
  247. \let\next = #1%
  248. \begingroup
  249. \obeylines
  250. \futurelet\temp\parseargx
  251. }
  252. % If the next token is an obeyed space (from an @example environment or
  253. % the like), remove it and recurse. Otherwise, we're done.
  254. \def\parseargx{%
  255. % \obeyedspace is defined far below, after the definition of \sepspaces.
  256. \ifx\obeyedspace\temp
  257. \expandafter\parseargdiscardspace
  258. \else
  259. \expandafter\parseargline
  260. \fi
  261. }
  262. % Remove a single space (as the delimiter token to the macro call).
  263. {\obeyspaces %
  264. \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
  265. {\obeylines %
  266. \gdef\parseargline#1^^M{%
  267. \endgroup % End of the group started in \parsearg.
  268. %
  269. % First remove any @c comment, then any @comment.
  270. % Result of each macro is put in \toks0.
  271. \argremovec #1\c\relax %
  272. \expandafter\argremovecomment \the\toks0 \comment\relax %
  273. %
  274. % Call the caller's macro, saved as \next in \parsearg.
  275. \expandafter\next\expandafter{\the\toks0}%
  276. }%
  277. }
  278. % Since all \c{,omment} does is throw away the argument, we can let TeX
  279. % do that for us. The \relax here is matched by the \relax in the call
  280. % in \parseargline; it could be more or less anything, its purpose is
  281. % just to delimit the argument to the \c.
  282. \def\argremovec#1\c#2\relax{\toks0 = {#1}}
  283. \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
  284. % \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
  285. % @end itemize @c foo
  286. % will have two active spaces as part of the argument with the
  287. % `itemize'. Here we remove all active spaces from #1, and assign the
  288. % result to \toks0.
  289. %
  290. % This loses if there are any *other* active characters besides spaces
  291. % in the argument -- _ ^ +, for example -- since they get expanded.
  292. % Fortunately, Texinfo does not define any such commands. (If it ever
  293. % does, the catcode of the characters in questionwill have to be changed
  294. % here.) But this means we cannot call \removeactivespaces as part of
  295. % \argremovec{,omment}, since @c uses \parsearg, and thus the argument
  296. % that \parsearg gets might well have any character at all in it.
  297. %
  298. \def\removeactivespaces#1{%
  299. \begingroup
  300. \ignoreactivespaces
  301. \edef\temp{#1}%
  302. \global\toks0 = \expandafter{\temp}%
  303. \endgroup
  304. }
  305. % Change the active space to expand to nothing.
  306. %
  307. \begingroup
  308. \obeyspaces
  309. \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
  310. \endgroup
  311. \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
  312. %% These are used to keep @begin/@end levels from running away
  313. %% Call \inENV within environments (after a \begingroup)
  314. \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
  315. \def\ENVcheck{%
  316. \ifENV\errmessage{Still within an environment; press RETURN to continue}
  317. \endgroup\fi} % This is not perfect, but it should reduce lossage
  318. % @begin foo is the same as @foo, for now.
  319. \newhelp\EMsimple{Press RETURN to continue.}
  320. \outer\def\begin{\parsearg\beginxxx}
  321. \def\beginxxx #1{%
  322. \expandafter\ifx\csname #1\endcsname\relax
  323. {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
  324. \csname #1\endcsname\fi}
  325. % @end foo executes the definition of \Efoo.
  326. %
  327. \def\end{\parsearg\endxxx}
  328. \def\endxxx #1{%
  329. \removeactivespaces{#1}%
  330. \edef\endthing{\the\toks0}%
  331. %
  332. \expandafter\ifx\csname E\endthing\endcsname\relax
  333. \expandafter\ifx\csname \endthing\endcsname\relax
  334. % There's no \foo, i.e., no ``environment'' foo.
  335. \errhelp = \EMsimple
  336. \errmessage{Undefined command `@end \endthing'}%
  337. \else
  338. \unmatchedenderror\endthing
  339. \fi
  340. \else
  341. % Everything's ok; the right environment has been started.
  342. \csname E\endthing\endcsname
  343. \fi
  344. }
  345. % There is an environment #1, but it hasn't been started. Give an error.
  346. %
  347. \def\unmatchedenderror#1{%
  348. \errhelp = \EMsimple
  349. \errmessage{This `@end #1' doesn't have a matching `@#1'}%
  350. }
  351. % Define the control sequence \E#1 to give an unmatched @end error.
  352. %
  353. \def\defineunmatchedend#1{%
  354. \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
  355. }
  356. % Single-spacing is done by various environments (specifically, in
  357. % \nonfillstart and \quotations).
  358. \newskip\singlespaceskip \singlespaceskip = 12.5pt
  359. \def\singlespace{%
  360. % Why was this kern here? It messes up equalizing space above and below
  361. % environments. --karl, 6may93
  362. %{\advance \baselineskip by -\singlespaceskip
  363. %\kern \baselineskip}%
  364. \setleading \singlespaceskip
  365. }
  366. %% Simple single-character @ commands
  367. % @@ prints an @
  368. % Kludge this until the fonts are right (grr).
  369. \def\@{{\tt\char64}}
  370. % This is turned off because it was never documented
  371. % and you can use @w{...} around a quote to suppress ligatures.
  372. %% Define @` and @' to be the same as ` and '
  373. %% but suppressing ligatures.
  374. %\def\`{{`}}
  375. %\def\'{{'}}
  376. % Used to generate quoted braces.
  377. \def\mylbrace {{\tt\char123}}
  378. \def\myrbrace {{\tt\char125}}
  379. \let\{=\mylbrace
  380. \let\}=\myrbrace
  381. \begingroup
  382. % Definitions to produce actual \{ & \} command in an index.
  383. \catcode`\{ = 12 \catcode`\} = 12
  384. \catcode`\[ = 1 \catcode`\] = 2
  385. \catcode`\@ = 0 \catcode`\\ = 12
  386. @gdef@lbracecmd[\{]%
  387. @gdef@rbracecmd[\}]%
  388. @endgroup
  389. % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
  390. % Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
  391. \let\, = \c
  392. \let\dotaccent = \.
  393. \def\ringaccent#1{{\accent23 #1}}
  394. \let\tieaccent = \t
  395. \let\ubaraccent = \b
  396. \let\udotaccent = \d
  397. % Other special characters: @questiondown @exclamdown
  398. % Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
  399. \def\questiondown{?`}
  400. \def\exclamdown{!`}
  401. % Dotless i and dotless j, used for accents.
  402. \def\imacro{i}
  403. \def\jmacro{j}
  404. \def\dotless#1{%
  405. \def\temp{#1}%
  406. \ifx\temp\imacro \ptexi
  407. \else\ifx\temp\jmacro \j
  408. \else \errmessage{@dotless can be used only with i or j}%
  409. \fi\fi
  410. }
  411. % Be sure we're in horizontal mode when doing a tie, since we make space
  412. % equivalent to this in @example-like environments. Otherwise, a space
  413. % at the beginning of a line will start with \penalty -- and
  414. % since \penalty is valid in vertical mode, we'd end up putting the
  415. % penalty on the vertical list instead of in the new paragraph.
  416. {\catcode`@ = 11
  417. % Avoid using \@M directly, because that causes trouble
  418. % if the definition is written into an index file.
  419. \global\let\tiepenalty = \@M
  420. \gdef\tie{\leavevmode\penalty\tiepenalty\ }
  421. }
  422. % @: forces normal size whitespace following.
  423. \def\:{\spacefactor=1000 }
  424. % @* forces a line break.
  425. \def\*{\hfil\break\hbox{}\ignorespaces}
  426. % @. is an end-of-sentence period.
  427. \def\.{.\spacefactor=3000 }
  428. % @! is an end-of-sentence bang.
  429. \def\!{!\spacefactor=3000 }
  430. % @? is an end-of-sentence query.
  431. \def\?{?\spacefactor=3000 }
  432. % @w prevents a word break. Without the \leavevmode, @w at the
  433. % beginning of a paragraph, when TeX is still in vertical mode, would
  434. % produce a whole line of output instead of starting the paragraph.
  435. \def\w#1{\leavevmode\hbox{#1}}
  436. % @group ... @end group forces ... to be all on one page, by enclosing
  437. % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
  438. % to keep its height that of a normal line. According to the rules for
  439. % \topskip (p.114 of the TeXbook), the glue inserted is
  440. % max (\topskip - \ht (first item), 0). If that height is large,
  441. % therefore, no glue is inserted, and the space between the headline and
  442. % the text is small, which looks bad.
  443. %
  444. \def\group{\begingroup
  445. \ifnum\catcode13=\active \else
  446. \errhelp = \groupinvalidhelp
  447. \errmessage{@group invalid in context where filling is enabled}%
  448. \fi
  449. %
  450. % The \vtop we start below produces a box with normal height and large
  451. % depth; thus, TeX puts \baselineskip glue before it, and (when the
  452. % next line of text is done) \lineskip glue after it. (See p.82 of
  453. % the TeXbook.) Thus, space below is not quite equal to space
  454. % above. But it's pretty close.
  455. \def\Egroup{%
  456. \egroup % End the \vtop.
  457. \endgroup % End the \group.
  458. }%
  459. %
  460. \vtop\bgroup
  461. % We have to put a strut on the last line in case the @group is in
  462. % the midst of an example, rather than completely enclosing it.
  463. % Otherwise, the interline space between the last line of the group
  464. % and the first line afterwards is too small. But we can't put the
  465. % strut in \Egroup, since there it would be on a line by itself.
  466. % Hence this just inserts a strut at the beginning of each line.
  467. \everypar = {\strut}%
  468. %
  469. % Since we have a strut on every line, we don't need any of TeX's
  470. % normal interline spacing.
  471. \offinterlineskip
  472. %
  473. % OK, but now we have to do something about blank
  474. % lines in the input in @example-like environments, which normally
  475. % just turn into \lisppar, which will insert no space now that we've
  476. % turned off the interline space. Simplest is to make them be an
  477. % empty paragraph.
  478. \ifx\par\lisppar
  479. \edef\par{\leavevmode \par}%
  480. %
  481. % Reset ^^M's definition to new definition of \par.
  482. \obeylines
  483. \fi
  484. %
  485. % Do @comment since we are called inside an environment such as
  486. % @example, where each end-of-line in the input causes an
  487. % end-of-line in the output. We don't want the end-of-line after
  488. % the `@group' to put extra space in the output. Since @group
  489. % should appear on a line by itself (according to the Texinfo
  490. % manual), we don't worry about eating any user text.
  491. \comment
  492. }
  493. %
  494. % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  495. % message, so this ends up printing `@group can only ...'.
  496. %
  497. \newhelp\groupinvalidhelp{%
  498. group can only be used in environments such as @example,^^J%
  499. where each line of input produces a line of output.}
  500. % @need space-in-mils
  501. % forces a page break if there is not space-in-mils remaining.
  502. \newdimen\mil \mil=0.001in
  503. \def\need{\parsearg\needx}
  504. % Old definition--didn't work.
  505. %\def\needx #1{\par %
  506. %% This method tries to make TeX break the page naturally
  507. %% if the depth of the box does not fit.
  508. %{\baselineskip=0pt%
  509. %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
  510. %\prevdepth=-1000pt
  511. %}}
  512. \def\needx#1{%
  513. % Go into vertical mode, so we don't make a big box in the middle of a
  514. % paragraph.
  515. \par
  516. %
  517. % Don't add any leading before our big empty box, but allow a page
  518. % break, since the best break might be right here.
  519. \allowbreak
  520. \nointerlineskip
  521. \vtop to #1\mil{\vfil}%
  522. %
  523. % TeX does not even consider page breaks if a penalty added to the
  524. % main vertical list is 10000 or more. But in order to see if the
  525. % empty box we just added fits on the page, we must make it consider
  526. % page breaks. On the other hand, we don't want to actually break the
  527. % page after the empty box. So we use a penalty of 9999.
  528. %
  529. % There is an extremely small chance that TeX will actually break the
  530. % page at this \penalty, if there are no other feasible breakpoints in
  531. % sight. (If the user is using lots of big @group commands, which
  532. % almost-but-not-quite fill up a page, TeX will have a hard time doing
  533. % good page breaking, for example.) However, I could not construct an
  534. % example where a page broke at this \penalty; if it happens in a real
  535. % document, then we can reconsider our strategy.
  536. \penalty9999
  537. %
  538. % Back up by the size of the box, whether we did a page break or not.
  539. \kern -#1\mil
  540. %
  541. % Do not allow a page break right after this kern.
  542. \nobreak
  543. }
  544. % @br forces paragraph break
  545. \let\br = \par
  546. % @dots{} output an ellipsis using the current font.
  547. % We do .5em per period so that it has the same spacing in a typewriter
  548. % font as three actual period characters.
  549. %
  550. \def\dots{%
  551. \leavevmode
  552. \hbox to 1.5em{%
  553. \hskip 0pt plus 0.25fil minus 0.25fil
  554. .\hss.\hss.%
  555. \hskip 0pt plus 0.5fil minus 0.5fil
  556. }%
  557. }
  558. % @enddots{} is an end-of-sentence ellipsis.
  559. %
  560. \def\enddots{%
  561. \leavevmode
  562. \hbox to 2em{%
  563. \hskip 0pt plus 0.25fil minus 0.25fil
  564. .\hss.\hss.\hss.%
  565. \hskip 0pt plus 0.5fil minus 0.5fil
  566. }%
  567. \spacefactor=3000
  568. }
  569. % @page forces the start of a new page
  570. %
  571. \def\page{\par\vfill\supereject}
  572. % @exdent text....
  573. % outputs text on separate line in roman font, starting at standard page margin
  574. % This records the amount of indent in the innermost environment.
  575. % That's how much \exdent should take out.
  576. \newskip\exdentamount
  577. % This defn is used inside fill environments such as @defun.
  578. \def\exdent{\parsearg\exdentyyy}
  579. \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
  580. % This defn is used inside nofill environments such as @example.
  581. \def\nofillexdent{\parsearg\nofillexdentyyy}
  582. \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
  583. \leftline{\hskip\leftskip{\rm#1}}}}
  584. % @inmargin{TEXT} puts TEXT in the margin next to the current paragraph.
  585. \def\inmargin#1{%
  586. \strut\vadjust{\nobreak\kern-\strutdepth
  587. \vtop to \strutdepth{\baselineskip\strutdepth\vss
  588. \llap{\rightskip=\inmarginspacing \vbox{\noindent #1}}\null}}}
  589. \newskip\inmarginspacing \inmarginspacing=1cm
  590. \def\strutdepth{\dp\strutbox}
  591. %\hbox{{\rm#1}}\hfil\break}}
  592. % @include file insert text of that file as input.
  593. % Allow normal characters that we make active in the argument (a file name).
  594. \def\include{\begingroup
  595. \catcode`\\=12
  596. \catcode`~=12
  597. \catcode`^=12
  598. \catcode`_=12
  599. \catcode`|=12
  600. \catcode`<=12
  601. \catcode`>=12
  602. \catcode`+=12
  603. \parsearg\includezzz}
  604. % Restore active chars for included file.
  605. \def\includezzz#1{\endgroup\begingroup
  606. % Read the included file in a group so nested @include's work.
  607. \def\thisfile{#1}%
  608. \input\thisfile
  609. \endgroup}
  610. \def\thisfile{}
  611. % @center line outputs that line, centered
  612. \def\center{\parsearg\centerzzz}
  613. \def\centerzzz #1{{\advance\hsize by -\leftskip
  614. \advance\hsize by -\rightskip
  615. \centerline{#1}}}
  616. % @sp n outputs n lines of vertical space
  617. \def\sp{\parsearg\spxxx}
  618. \def\spxxx #1{\vskip #1\baselineskip}
  619. % @comment ...line which is ignored...
  620. % @c is the same as @comment
  621. % @ignore ... @end ignore is another way to write a comment
  622. \def\comment{\begingroup \catcode`\^^M=\other%
  623. \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
  624. \commentxxx}
  625. {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
  626. \let\c=\comment
  627. % @paragraphindent is defined for the Info formatting commands only.
  628. \let\paragraphindent=\comment
  629. % Prevent errors for section commands.
  630. % Used in @ignore and in failing conditionals.
  631. \def\ignoresections{%
  632. \let\chapter=\relax
  633. \let\unnumbered=\relax
  634. \let\top=\relax
  635. \let\unnumberedsec=\relax
  636. \let\unnumberedsection=\relax
  637. \let\unnumberedsubsec=\relax
  638. \let\unnumberedsubsection=\relax
  639. \let\unnumberedsubsubsec=\relax
  640. \let\unnumberedsubsubsection=\relax
  641. \let\section=\relax
  642. \let\subsec=\relax
  643. \let\subsubsec=\relax
  644. \let\subsection=\relax
  645. \let\subsubsection=\relax
  646. \let\appendix=\relax
  647. \let\appendixsec=\relax
  648. \let\appendixsection=\relax
  649. \let\appendixsubsec=\relax
  650. \let\appendixsubsection=\relax
  651. \let\appendixsubsubsec=\relax
  652. \let\appendixsubsubsection=\relax
  653. \let\contents=\relax
  654. \let\smallbook=\relax
  655. \let\titlepage=\relax
  656. }
  657. % Used in nested conditionals, where we have to parse the Texinfo source
  658. % and so want to turn off most commands, in case they are used
  659. % incorrectly.
  660. %
  661. \def\ignoremorecommands{%
  662. \let\defcodeindex = \relax
  663. \let\defcv = \relax
  664. \let\deffn = \relax
  665. \let\deffnx = \relax
  666. \let\defindex = \relax
  667. \let\defivar = \relax
  668. \let\defmac = \relax
  669. \let\defmethod = \relax
  670. \let\defop = \relax
  671. \let\defopt = \relax
  672. \let\defspec = \relax
  673. \let\deftp = \relax
  674. \let\deftypefn = \relax
  675. \let\deftypefun = \relax
  676. \let\deftypevar = \relax
  677. \let\deftypevr = \relax
  678. \let\defun = \relax
  679. \let\defvar = \relax
  680. \let\defvr = \relax
  681. \let\ref = \relax
  682. \let\xref = \relax
  683. \let\printindex = \relax
  684. \let\pxref = \relax
  685. \let\settitle = \relax
  686. \let\setchapternewpage = \relax
  687. \let\setchapterstyle = \relax
  688. \let\everyheading = \relax
  689. \let\evenheading = \relax
  690. \let\oddheading = \relax
  691. \let\everyfooting = \relax
  692. \let\evenfooting = \relax
  693. \let\oddfooting = \relax
  694. \let\headings = \relax
  695. \let\include = \relax
  696. \let\lowersections = \relax
  697. \let\down = \relax
  698. \let\raisesections = \relax
  699. \let\up = \relax
  700. \let\set = \relax
  701. \let\clear = \relax
  702. \let\item = \relax
  703. }
  704. % Ignore @ignore ... @end ignore.
  705. %
  706. \def\ignore{\doignore{ignore}}
  707. % Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
  708. %
  709. \def\ifinfo{\doignore{ifinfo}}
  710. \def\ifhtml{\doignore{ifhtml}}
  711. \def\ifnottex{\doignore{ifnottex}}
  712. \def\html{\doignore{html}}
  713. \def\menu{\doignore{menu}}
  714. \def\direntry{\doignore{direntry}}
  715. % @dircategory CATEGORY -- specify a category of the dir file
  716. % which this file should belong to. Ignore this in TeX.
  717. \let\dircategory = \comment
  718. % Ignore text until a line `@end #1'.
  719. %
  720. \def\doignore#1{\begingroup
  721. % Don't complain about control sequences we have declared \outer.
  722. \ignoresections
  723. %
  724. % Define a command to swallow text until we reach `@end #1'.
  725. % This @ is a catcode 12 token (that is the normal catcode of @ in
  726. % this texinfo.tex file). We change the catcode of @ below to match.
  727. \long\def\doignoretext##1@end #1{\enddoignore}%
  728. %
  729. % Make sure that spaces turn into tokens that match what \doignoretext wants.
  730. \catcode32 = 10
  731. %
  732. % Ignore braces, too, so mismatched braces don't cause trouble.
  733. \catcode`\{ = 9
  734. \catcode`\} = 9
  735. %
  736. % We must not have @c interpreted as a control sequence.
  737. \catcode`\@ = 12
  738. %
  739. % Make the letter c a comment character so that the rest of the line
  740. % will be ignored. This way, the document can have (for example)
  741. % @c @end ifinfo
  742. % and the @end ifinfo will be properly ignored.
  743. % (We've just changed @ to catcode 12.)
  744. \catcode`\c = 14
  745. %
  746. % And now expand that command.
  747. \doignoretext
  748. }
  749. % What we do to finish off ignored text.
  750. %
  751. \def\enddoignore{\endgroup\ignorespaces}%
  752. \newif\ifwarnedobs\warnedobsfalse
  753. \def\obstexwarn{%
  754. \ifwarnedobs\relax\else
  755. % We need to warn folks that they may have trouble with TeX 3.0.
  756. % This uses \immediate\write16 rather than \message to get newlines.
  757. \immediate\write16{}
  758. \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
  759. \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
  760. \immediate\write16{If you are running another version of TeX, relax.}
  761. \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
  762. \immediate\write16{ Then upgrade your TeX installation if you can.}
  763. \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
  764. \immediate\write16{If you are stuck with version 3.0, run the}
  765. \immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
  766. \immediate\write16{ to use a workaround.}
  767. \immediate\write16{}
  768. \global\warnedobstrue
  769. \fi
  770. }
  771. % **In TeX 3.0, setting text in \nullfont hangs tex. For a
  772. % workaround (which requires the file ``dummy.tfm'' to be installed),
  773. % uncomment the following line:
  774. %%%%%\font\nullfont=dummy\let\obstexwarn=\relax
  775. % Ignore text, except that we keep track of conditional commands for
  776. % purposes of nesting, up to an `@end #1' command.
  777. %
  778. \def\nestedignore#1{%
  779. \obstexwarn
  780. % We must actually expand the ignored text to look for the @end
  781. % command, so that nested ignore constructs work. Thus, we put the
  782. % text into a \vbox and then do nothing with the result. To minimize
  783. % the change of memory overflow, we follow the approach outlined on
  784. % page 401 of the TeXbook: make the current font be a dummy font.
  785. %
  786. \setbox0 = \vbox\bgroup
  787. % Don't complain about control sequences we have declared \outer.
  788. \ignoresections
  789. %
  790. % Define `@end #1' to end the box, which will in turn undefine the
  791. % @end command again.
  792. \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
  793. %
  794. % We are going to be parsing Texinfo commands. Most cause no
  795. % trouble when they are used incorrectly, but some commands do
  796. % complicated argument parsing or otherwise get confused, so we
  797. % undefine them.
  798. %
  799. % We can't do anything about stray @-signs, unfortunately;
  800. % they'll produce `undefined control sequence' errors.
  801. \ignoremorecommands
  802. %
  803. % Set the current font to be \nullfont, a TeX primitive, and define
  804. % all the font commands to also use \nullfont. We don't use
  805. % dummy.tfm, as suggested in the TeXbook, because not all sites
  806. % might have that installed. Therefore, math mode will still
  807. % produce output, but that should be an extremely small amount of
  808. % stuff compared to the main input.
  809. %
  810. \nullfont
  811. \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont
  812. \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont
  813. \let\tensf = \nullfont
  814. % Similarly for index fonts (mostly for their use in
  815. % smallexample)
  816. \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont
  817. \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont
  818. \let\indsf = \nullfont
  819. %
  820. % Don't complain when characters are missing from the fonts.
  821. \tracinglostchars = 0
  822. %
  823. % Don't bother to do space factor calculations.
  824. \frenchspacing
  825. %
  826. % Don't report underfull hboxes.
  827. \hbadness = 10000
  828. %
  829. % Do minimal line-breaking.
  830. \pretolerance = 10000
  831. %
  832. % Do not execute instructions in @tex
  833. \def\tex{\doignore{tex}}%
  834. % Do not execute macro definitions.
  835. % `c' is a comment character, so the word `macro' will get cut off.
  836. \def\macro{\doignore{ma}}%
  837. }
  838. % @set VAR sets the variable VAR to an empty value.
  839. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
  840. %
  841. % Since we want to separate VAR from REST-OF-LINE (which might be
  842. % empty), we can't just use \parsearg; we have to insert a space of our
  843. % own to delimit the rest of the line, and then take it out again if we
  844. % didn't need it. Make sure the catcode of space is correct to avoid
  845. % losing inside @example, for instance.
  846. %
  847. \def\set{\begingroup\catcode` =10
  848. \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
  849. \parsearg\setxxx}
  850. \def\setxxx#1{\setyyy#1 \endsetyyy}
  851. \def\setyyy#1 #2\endsetyyy{%
  852. \def\temp{#2}%
  853. \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
  854. \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
  855. \fi
  856. \endgroup
  857. }
  858. % Can't use \xdef to pre-expand #2 and save some time, since \temp or
  859. % \next or other control sequences that we've defined might get us into
  860. % an infinite loop. Consider `@set foo @cite{bar}'.
  861. \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
  862. % @clear VAR clears (i.e., unsets) the variable VAR.
  863. %
  864. \def\clear{\parsearg\clearxxx}
  865. \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
  866. % @value{foo} gets the text saved in variable foo.
  867. %
  868. {
  869. \catcode`\_ = \active
  870. %
  871. % We might end up with active _ or - characters in the argument if
  872. % we're called from @code, as @code{@value{foo-bar_}}. So \let any
  873. % such active characters to their normal equivalents.
  874. \gdef\value{\begingroup
  875. \catcode`\-=12 \catcode`\_=12
  876. \indexbreaks \let_\normalunderscore
  877. \valuexxx}
  878. }
  879. \def\valuexxx#1{\expandablevalue{#1}\endgroup}
  880. % We have this subroutine so that we can handle at least some @value's
  881. % properly in indexes (we \let\value to this in \indexdummies). Ones
  882. % whose names contain - or _ still won't work, but we can't do anything
  883. % about that. The command has to be fully expandable, since the result
  884. % winds up in the index file. This means that if the variable's value
  885. % contains other Texinfo commands, it's almost certain it will fail
  886. % (although perhaps we could fix that with sufficient work to do a
  887. % one-level expansion on the result, instead of complete).
  888. %
  889. \def\expandablevalue#1{%
  890. \expandafter\ifx\csname SET#1\endcsname\relax
  891. {[No value for ``#1'']}%
  892. \else
  893. \csname SET#1\endcsname
  894. \fi
  895. }
  896. % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  897. % with @set.
  898. %
  899. \def\ifset{\parsearg\ifsetxxx}
  900. \def\ifsetxxx #1{%
  901. \expandafter\ifx\csname SET#1\endcsname\relax
  902. \expandafter\ifsetfail
  903. \else
  904. \expandafter\ifsetsucceed
  905. \fi
  906. }
  907. \def\ifsetsucceed{\conditionalsucceed{ifset}}
  908. \def\ifsetfail{\nestedignore{ifset}}
  909. \defineunmatchedend{ifset}
  910. % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  911. % defined with @set, or has been undefined with @clear.
  912. %
  913. \def\ifclear{\parsearg\ifclearxxx}
  914. \def\ifclearxxx #1{%
  915. \expandafter\ifx\csname SET#1\endcsname\relax
  916. \expandafter\ifclearsucceed
  917. \else
  918. \expandafter\ifclearfail
  919. \fi
  920. }
  921. \def\ifclearsucceed{\conditionalsucceed{ifclear}}
  922. \def\ifclearfail{\nestedignore{ifclear}}
  923. \defineunmatchedend{ifclear}
  924. % @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
  925. % following, through the first @end iftex (etc.). Make `@end iftex'
  926. % (etc.) valid only after an @iftex.
  927. %
  928. \def\iftex{\conditionalsucceed{iftex}}
  929. \def\ifnothtml{\conditionalsucceed{ifnothtml}}
  930. \def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
  931. \defineunmatchedend{iftex}
  932. \defineunmatchedend{ifnothtml}
  933. \defineunmatchedend{ifnotinfo}
  934. % We can't just want to start a group at @iftex (for example) and end it
  935. % at @end iftex, since then @set commands inside the conditional have no
  936. % effect (they'd get reverted at the end of the group). So we must
  937. % define \Eiftex to redefine itself to be its previous value. (We can't
  938. % just define it to fail again with an ``unmatched end'' error, since
  939. % the @ifset might be nested.)
  940. %
  941. \def\conditionalsucceed#1{%
  942. \edef\temp{%
  943. % Remember the current value of \E#1.
  944. \let\nece{prevE#1} = \nece{E#1}%
  945. %
  946. % At the `@end #1', redefine \E#1 to be its previous value.
  947. \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
  948. }%
  949. \temp
  950. }
  951. % We need to expand lots of \csname's, but we don't want to expand the
  952. % control sequences after we've constructed them.
  953. %
  954. \def\nece#1{\expandafter\noexpand\csname#1\endcsname}
  955. % @asis just yields its argument. Used with @table, for example.
  956. %
  957. \def\asis#1{#1}
  958. % @math means output in math mode.
  959. % We don't use $'s directly in the definition of \math because control
  960. % sequences like \math are expanded when the toc file is written. Then,
  961. % we read the toc file back, the $'s will be normal characters (as they
  962. % should be, according to the definition of Texinfo). So we must use a
  963. % control sequence to switch into and out of math mode.
  964. %
  965. % This isn't quite enough for @math to work properly in indices, but it
  966. % seems unlikely it will ever be needed there.
  967. %
  968. \let\implicitmath = $
  969. \def\math#1{\implicitmath #1\implicitmath}
  970. % @bullet and @minus need the same treatment as @math, just above.
  971. \def\bullet{\implicitmath\ptexbullet\implicitmath}
  972. \def\minus{\implicitmath-\implicitmath}
  973. % @refill is a no-op.
  974. \let\refill=\relax
  975. % If working on a large document in chapters, it is convenient to
  976. % be able to disable indexing, cross-referencing, and contents, for test runs.
  977. % This is done with @novalidate (before @setfilename).
  978. %
  979. \newif\iflinks \linkstrue % by default we want the aux files.
  980. \let\novalidate = \linksfalse
  981. % @setfilename is done at the beginning of every texinfo file.
  982. % So open here the files we need to have open while reading the input.
  983. % This makes it possible to make a .fmt file for texinfo.
  984. \def\setfilename{%
  985. \iflinks
  986. \readauxfile
  987. \fi % \openindices needs to do some work in any case.
  988. \openindices
  989. \fixbackslash % Turn off hack to swallow `\input texinfo'.
  990. \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
  991. %
  992. % If texinfo.cnf is present on the system, read it.
  993. % Useful for site-wide @afourpaper, etc.
  994. % Just to be on the safe side, close the input stream before the \input.
  995. \openin 1 texinfo.cnf
  996. \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
  997. \closein1
  998. \temp
  999. %
  1000. \comment % Ignore the actual filename.
  1001. }
  1002. % Called from \setfilename.
  1003. %
  1004. \def\openindices{%
  1005. \newindex{cp}%
  1006. \newcodeindex{fn}%
  1007. \newcodeindex{vr}%
  1008. \newcodeindex{tp}%
  1009. \newcodeindex{ky}%
  1010. \newcodeindex{pg}%
  1011. }
  1012. % @bye.
  1013. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
  1014. \message{fonts,}
  1015. % Font-change commands.
  1016. % Texinfo sort of supports the sans serif font style, which plain TeX does not.
  1017. % So we set up a \sf analogous to plain's \rm, etc.
  1018. \newfam\sffam
  1019. \def\sf{\fam=\sffam \tensf}
  1020. \let\li = \sf % Sometimes we call it \li, not \sf.
  1021. % We don't need math for this one.
  1022. \def\ttsl{\tenttsl}
  1023. % Use Computer Modern fonts at \magstephalf (11pt).
  1024. \newcount\mainmagstep
  1025. \mainmagstep=\magstephalf
  1026. % Set the font macro #1 to the font named #2, adding on the
  1027. % specified font prefix (normally `cm').
  1028. % #3 is the font's design size, #4 is a scale factor
  1029. \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
  1030. % Use cm as the default font prefix.
  1031. % To specify the font prefix, you must define \fontprefix
  1032. % before you read in texinfo.tex.
  1033. \ifx\fontprefix\undefined
  1034. \def\fontprefix{cm}
  1035. \fi
  1036. % Support font families that don't use the same naming scheme as CM.
  1037. \def\rmshape{r}
  1038. \def\rmbshape{bx} %where the normal face is bold
  1039. \def\bfshape{b}
  1040. \def\bxshape{bx}
  1041. \def\ttshape{tt}
  1042. \def\ttbshape{tt}
  1043. \def\ttslshape{sltt}
  1044. \def\itshape{ti}
  1045. \def\itbshape{bxti}
  1046. \def\slshape{sl}
  1047. \def\slbshape{bxsl}
  1048. \def\sfshape{ss}
  1049. \def\sfbshape{ss}
  1050. \def\scshape{csc}
  1051. \def\scbshape{csc}
  1052. \ifx\bigger\relax
  1053. \let\mainmagstep=\magstep1
  1054. \setfont\textrm\rmshape{12}{1000}
  1055. \setfont\texttt\ttshape{12}{1000}
  1056. \else
  1057. \setfont\textrm\rmshape{10}{\mainmagstep}
  1058. \setfont\texttt\ttshape{10}{\mainmagstep}
  1059. \fi
  1060. % Instead of cmb10, you many want to use cmbx10.
  1061. % cmbx10 is a prettier font on its own, but cmb10
  1062. % looks better when embedded in a line with cmr10.
  1063. \setfont\textbf\bfshape{10}{\mainmagstep}
  1064. \setfont\textit\itshape{10}{\mainmagstep}
  1065. \setfont\textsl\slshape{10}{\mainmagstep}
  1066. \setfont\textsf\sfshape{10}{\mainmagstep}
  1067. \setfont\textsc\scshape{10}{\mainmagstep}
  1068. \setfont\textttsl\ttslshape{10}{\mainmagstep}
  1069. \font\texti=cmmi10 scaled \mainmagstep
  1070. \font\textsy=cmsy10 scaled \mainmagstep
  1071. % A few fonts for @defun, etc.
  1072. \setfont\defbf\bxshape{10}{\magstep1} %was 1314
  1073. \setfont\deftt\ttshape{10}{\magstep1}
  1074. \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
  1075. % Fonts for indices and small examples (9pt).
  1076. % We actually use the slanted font rather than the italic,
  1077. % because texinfo normally uses the slanted fonts for that.
  1078. % Do not make many font distinctions in general in the index, since they
  1079. % aren't very useful.
  1080. \setfont\ninett\ttshape{9}{1000}
  1081. \setfont\ninettsl\ttslshape{10}{900}
  1082. \setfont\indrm\rmshape{9}{1000}
  1083. \setfont\indit\itshape{9}{1000}
  1084. \setfont\indsl\slshape{9}{1000}
  1085. \let\indtt=\ninett
  1086. \let\indttsl=\ninettsl
  1087. \let\indsf=\indrm
  1088. \let\indbf=\indrm
  1089. \setfont\indsc\scshape{10}{900}
  1090. \font\indi=cmmi9
  1091. \font\indsy=cmsy9
  1092. % Fonts for title page:
  1093. \setfont\titlerm\rmbshape{12}{\magstep3}
  1094. \setfont\titleit\itbshape{10}{\magstep4}
  1095. \setfont\titlesl\slbshape{10}{\magstep4}
  1096. \setfont\titlett\ttbshape{12}{\magstep3}
  1097. \setfont\titlettsl\ttslshape{10}{\magstep4}
  1098. \setfont\titlesf\sfbshape{17}{\magstep1}
  1099. \let\titlebf=\titlerm
  1100. \setfont\titlesc\scbshape{10}{\magstep4}
  1101. \font\titlei=cmmi12 scaled \magstep3
  1102. \font\titlesy=cmsy10 scaled \magstep4
  1103. \def\authorrm{\secrm}
  1104. % Chapter (and unnumbered) fonts (17.28pt).
  1105. \setfont\chaprm\rmbshape{12}{\magstep2}
  1106. \setfont\chapit\itbshape{10}{\magstep3}
  1107. \setfont\chapsl\slbshape{10}{\magstep3}
  1108. \setfont\chaptt\ttbshape{12}{\magstep2}
  1109. \setfont\chapttsl\ttslshape{10}{\magstep3}
  1110. \setfont\chapsf\sfbshape{17}{1000}
  1111. \let\chapbf=\chaprm
  1112. \setfont\chapsc\scbshape{10}{\magstep3}
  1113. \font\chapi=cmmi12 scaled \magstep2
  1114. \font\chapsy=cmsy10 scaled \magstep3
  1115. % Section fonts (14.4pt).
  1116. \setfont\secrm\rmbshape{12}{\magstep1}
  1117. \setfont\secit\itbshape{10}{\magstep2}
  1118. \setfont\secsl\slbshape{10}{\magstep2}
  1119. \setfont\sectt\ttbshape{12}{\magstep1}
  1120. \setfont\secttsl\ttslshape{10}{\magstep2}
  1121. \setfont\secsf\sfbshape{12}{\magstep1}
  1122. \let\secbf\secrm
  1123. \setfont\secsc\scbshape{10}{\magstep2}
  1124. \font\seci=cmmi12 scaled \magstep1
  1125. \font\secsy=cmsy10 scaled \magstep2
  1126. % \setfont\ssecrm\bxshape{10}{\magstep1} % This size an font looked bad.
  1127. % \setfont\ssecit\itshape{10}{\magstep1} % The letters were too crowded.
  1128. % \setfont\ssecsl\slshape{10}{\magstep1}
  1129. % \setfont\ssectt\ttshape{10}{\magstep1}
  1130. % \setfont\ssecsf\sfshape{10}{\magstep1}
  1131. %\setfont\ssecrm\bfshape{10}{1315} % Note the use of cmb rather than cmbx.
  1132. %\setfont\ssecit\itshape{10}{1315} % Also, the size is a little larger than
  1133. %\setfont\ssecsl\slshape{10}{1315} % being scaled magstep1.
  1134. %\setfont\ssectt\ttshape{10}{1315}
  1135. %\setfont\ssecsf\sfshape{10}{1315}
  1136. %\let\ssecbf=\ssecrm
  1137. % Subsection fonts (13.15pt).
  1138. \setfont\ssecrm\rmbshape{12}{\magstephalf}
  1139. \setfont\ssecit\itbshape{10}{1315}
  1140. \setfont\ssecsl\slbshape{10}{1315}
  1141. \setfont\ssectt\ttbshape{12}{\magstephalf}
  1142. \setfont\ssecttsl\ttslshape{10}{1315}
  1143. \setfont\ssecsf\sfbshape{12}{\magstephalf}
  1144. \let\ssecbf\ssecrm
  1145. \setfont\ssecsc\scbshape{10}{\magstep1}
  1146. \font\sseci=cmmi12 scaled \magstephalf
  1147. \font\ssecsy=cmsy10 scaled 1315
  1148. % The smallcaps and symbol fonts should actually be scaled \magstep1.5,
  1149. % but that is not a standard magnification.
  1150. % In order for the font changes to affect most math symbols and letters,
  1151. % we have to define the \textfont of the standard families. Since
  1152. % texinfo doesn't allow for producing subscripts and superscripts, we
  1153. % don't bother to reset \scriptfont and \scriptscriptfont (which would
  1154. % also require loading a lot more fonts).
  1155. %
  1156. \def\resetmathfonts{%
  1157. \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
  1158. \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
  1159. \textfont\ttfam = \tentt \textfont\sffam = \tensf
  1160. }
  1161. % The font-changing commands redefine the meanings of \tenSTYLE, instead
  1162. % of just \STYLE. We do this so that font changes will continue to work
  1163. % in math mode, where it is the current \fam that is relevant in most
  1164. % cases, not the current font. Plain TeX does \def\bf{\fam=\bffam
  1165. % \tenbf}, for example. By redefining \tenbf, we obviate the need to
  1166. % redefine \bf itself.
  1167. \def\textfonts{%
  1168. \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
  1169. \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
  1170. \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
  1171. \resetmathfonts}
  1172. \def\titlefonts{%
  1173. \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
  1174. \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
  1175. \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
  1176. \let\tenttsl=\titlettsl
  1177. \resetmathfonts \setleading{25pt}}
  1178. \def\titlefont#1{{\titlefonts\rm #1}}
  1179. \def\chapfonts{%
  1180. \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
  1181. \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
  1182. \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
  1183. \resetmathfonts \setleading{19pt}}
  1184. \def\secfonts{%
  1185. \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
  1186. \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
  1187. \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
  1188. \resetmathfonts \setleading{16pt}}
  1189. \def\subsecfonts{%
  1190. \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
  1191. \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
  1192. \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
  1193. \resetmathfonts \setleading{15pt}}
  1194. \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
  1195. \def\indexfonts{%
  1196. \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
  1197. \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
  1198. \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \let\tenttsl=\indttsl
  1199. \resetmathfonts \setleading{12pt}}
  1200. % Set up the default fonts, so we can use them for creating boxes.
  1201. %
  1202. \textfonts
  1203. % Define these so they can be easily changed for other fonts.
  1204. \def\angleleft{$\langle$}
  1205. \def\angleright{$\rangle$}
  1206. % Count depth in font-changes, for error checks
  1207. \newcount\fontdepth \fontdepth=0
  1208. % Fonts for short table of contents.
  1209. \setfont\shortcontrm\rmshape{12}{1000}
  1210. \setfont\shortcontbf\bxshape{12}{1000}
  1211. \setfont\shortcontsl\slshape{12}{1000}
  1212. %% Add scribe-like font environments, plus @l for inline lisp (usually sans
  1213. %% serif) and @ii for TeX italic
  1214. % \smartitalic{ARG} outputs arg in italics, followed by an italic correction
  1215. % unless the following character is such as not to need one.
  1216. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
  1217. \def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
  1218. \def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
  1219. \let\i=\smartitalic
  1220. \let\var=\smartslanted
  1221. \let\dfn=\smartslanted
  1222. \let\emph=\smartitalic
  1223. \let\cite=\smartslanted
  1224. \def\b#1{{\bf #1}}
  1225. \let\strong=\b
  1226. % We can't just use \exhyphenpenalty, because that only has effect at
  1227. % the end of a paragraph. Restore normal hyphenation at the end of the
  1228. % group within which \nohyphenation is presumably called.
  1229. %
  1230. \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
  1231. \def\restorehyphenation{\hyphenchar\font = `- }
  1232. \def\t#1{%
  1233. {\tt \rawbackslash \frenchspacing #1}%
  1234. \null
  1235. }
  1236. \let\ttfont=\t
  1237. \def\samp#1{`\tclose{#1}'\null}
  1238. \setfont\smallrm\rmshape{8}{1000}
  1239. \font\smallsy=cmsy9
  1240. \def\key#1{{\smallrm\textfont2=\smallsy \leavevmode\hbox{%
  1241. \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
  1242. \vbox{\hrule\kern-0.4pt
  1243. \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
  1244. \kern-0.4pt\hrule}%
  1245. \kern-.06em\raise0.4pt\hbox{\angleright}}}}
  1246. % The old definition, with no lozenge:
  1247. %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
  1248. \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  1249. % @file, @option are the same as @samp.
  1250. \let\file=\samp
  1251. \let\option=\samp
  1252. % @code is a modification of @t,
  1253. % which makes spaces the same size as normal in the surrounding text.
  1254. \def\tclose#1{%
  1255. {%
  1256. % Change normal interword space to be same as for the current font.
  1257. \spaceskip = \fontdimen2\font
  1258. %
  1259. % Switch to typewriter.
  1260. \tt
  1261. %
  1262. % But `\ ' produces the large typewriter interword space.
  1263. \def\ {{\spaceskip = 0pt{} }}%
  1264. %
  1265. % Turn off hyphenation.
  1266. \nohyphenation
  1267. %
  1268. \rawbackslash
  1269. \frenchspacing
  1270. #1%
  1271. }%
  1272. \null
  1273. }
  1274. % We *must* turn on hyphenation at `-' and `_' in \code.
  1275. % Otherwise, it is too hard to avoid overfull hboxes
  1276. % in the Emacs manual, the Library manual, etc.
  1277. % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  1278. % both hyphenation at - and hyphenation within words.
  1279. % We must therefore turn them both off (\tclose does that)
  1280. % and arrange explicitly to hyphenate at a dash.
  1281. % -- rms.
  1282. {
  1283. \catcode`\-=\active
  1284. \catcode`\_=\active
  1285. %
  1286. \global\def\code{\begingroup
  1287. \catcode`\-=\active \let-\codedash
  1288. \catcode`\_=\active \let_\codeunder
  1289. \codex
  1290. }
  1291. %
  1292. % If we end up with any active - characters when handling the index,
  1293. % just treat them as a normal -.
  1294. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
  1295. }
  1296. \def\realdash{-}
  1297. \def\codedash{-\discretionary{}{}{}}
  1298. \def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
  1299. \def\codex #1{\tclose{#1}\endgroup}
  1300. %\let\exp=\tclose %Was temporary
  1301. % @kbd is like @code, except that if the argument is just one @key command,
  1302. % then @kbd has no effect.
  1303. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
  1304. % `example' (@kbd uses ttsl only inside of @example and friends),
  1305. % or `code' (@kbd uses normal tty font always).
  1306. \def\kbdinputstyle{\parsearg\kbdinputstylexxx}
  1307. \def\kbdinputstylexxx#1{%
  1308. \def\arg{#1}%
  1309. \ifx\arg\worddistinct
  1310. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
  1311. \else\ifx\arg\wordexample
  1312. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
  1313. \else\ifx\arg\wordcode
  1314. \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
  1315. \fi\fi\fi
  1316. }
  1317. \def\worddistinct{distinct}
  1318. \def\wordexample{example}
  1319. \def\wordcode{code}
  1320. % Default is kbdinputdistinct. (Too much of a hassle to call the macro,
  1321. % the catcodes are wrong for parsearg to work.)
  1322. \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
  1323. \def\xkey{\key}
  1324. \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
  1325. \ifx\one\xkey\ifx\threex\three \key{#2}%
  1326. \else{\tclose{\kbdfont\look}}\fi
  1327. \else{\tclose{\kbdfont\look}}\fi}
  1328. % For @url, @env, @command quotes seem unnecessary, so use \code.
  1329. \let\url=\code
  1330. \let\env=\code
  1331. \let\command=\code
  1332. % @uref (abbreviation for `urlref') takes an optional second argument
  1333. % specifying the text to display. First (mandatory) arg is the url.
  1334. % Perhaps eventually put in a hypertex \special here.
  1335. %
  1336. \def\uref#1{\urefxxx #1,,\finish}
  1337. \def\urefxxx#1,#2,#3\finish{%
  1338. \setbox0 = \hbox{\ignorespaces #2}%
  1339. \ifdim\wd0 > 0pt
  1340. \unhbox0\ (\code{#1})%
  1341. \else
  1342. \code{#1}%
  1343. \fi
  1344. }
  1345. % rms does not like the angle brackets --karl, 17may97.
  1346. % So now @email is just like @uref.
  1347. %\def\email#1{\angleleft{\tt #1}\angleright}
  1348. \let\email=\uref
  1349. % Check if we are currently using a typewriter font. Since all the
  1350. % Computer Modern typewriter fonts have zero interword stretch (and
  1351. % shrink), and it is reasonable to expect all typewriter fonts to have
  1352. % this property, we can check that font parameter.
  1353. %
  1354. \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
  1355. % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
  1356. % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
  1357. %
  1358. \def\dmn#1{\thinspace #1}
  1359. \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
  1360. % @l was never documented to mean ``switch to the Lisp font'',
  1361. % and it is not used as such in any manual I can find. We need it for
  1362. % Polish suppressed-l. --karl, 22sep96.
  1363. %\def\l#1{{\li #1}\null}
  1364. % Explicit font changes: @r, @sc, undocumented @ii.
  1365. \def\r#1{{\rm #1}} % roman font
  1366. \def\sc#1{{\smallcaps#1}} % smallcaps font
  1367. \def\ii#1{{\it #1}} % italic font
  1368. % @acronym downcases the argument and prints in smallcaps.
  1369. \def\acronym#1{{\smallcaps \lowercase{#1}}}
  1370. % @pounds{} is a sterling sign.
  1371. \def\pounds{{\it\$}}
  1372. \message{page headings,}
  1373. \newskip\titlepagetopglue \titlepagetopglue = 1.5in
  1374. \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
  1375. % First the title page. Must do @settitle before @titlepage.
  1376. \newif\ifseenauthor
  1377. \newif\iffinishedtitlepage
  1378. % Do an implicit @contents or @shortcontents after @end titlepage if the
  1379. % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
  1380. %
  1381. \newif\ifsetcontentsaftertitlepage
  1382. \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
  1383. \newif\ifsetshortcontentsaftertitlepage
  1384. \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
  1385. \def\shorttitlepage{\parsearg\shorttitlepagezzz}
  1386. \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
  1387. \endgroup\page\hbox{}\page}
  1388. \def\titlepage{\begingroup \parindent=0pt \textfonts
  1389. \let\subtitlerm=\tenrm
  1390. \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
  1391. %
  1392. \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
  1393. %
  1394. % Leave some space at the very top of the page.
  1395. \vglue\titlepagetopglue
  1396. %
  1397. % Now you can print the title using @title.
  1398. \def\title{\parsearg\titlezzz}%
  1399. \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
  1400. % print a rule at the page bottom also.
  1401. \finishedtitlepagefalse
  1402. \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
  1403. % No rule at page bottom unless we print one at the top with @title.
  1404. \finishedtitlepagetrue
  1405. %
  1406. % Now you can put text using @subtitle.
  1407. \def\subtitle{\parsearg\subtitlezzz}%
  1408. \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
  1409. %
  1410. % @author should come last, but may come many times.
  1411. \def\author{\parsearg\authorzzz}%
  1412. \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
  1413. {\authorfont \leftline{##1}}}%
  1414. %
  1415. % Most title ``pages'' are actually two pages long, with space
  1416. % at the top of the second. We don't want the ragged left on the second.
  1417. \let\oldpage = \page
  1418. \def\page{%
  1419. \iffinishedtitlepage\else
  1420. \finishtitlepage
  1421. \fi
  1422. \oldpage
  1423. \let\page = \oldpage
  1424. \hbox{}}%
  1425. % \def\page{\oldpage \hbox{}}
  1426. }
  1427. \def\Etitlepage{%
  1428. \iffinishedtitlepage\else
  1429. \finishtitlepage
  1430. \fi
  1431. % It is important to do the page break before ending the group,
  1432. % because the headline and footline are only empty inside the group.
  1433. % If we use the new definition of \page, we always get a blank page
  1434. % after the title page, which we certainly don't want.
  1435. \oldpage
  1436. \endgroup
  1437. %
  1438. % If they want short, they certainly want long too.
  1439. \ifsetshortcontentsaftertitlepage
  1440. \shortcontents
  1441. \contents
  1442. \global\let\shortcontents = \relax
  1443. \global\let\contents = \relax
  1444. \fi
  1445. %
  1446. \ifsetcontentsaftertitlepage
  1447. \contents
  1448. \global\let\contents = \relax
  1449. \global\let\shortcontents = \relax
  1450. \fi
  1451. %
  1452. \HEADINGSon
  1453. }
  1454. \def\finishtitlepage{%
  1455. \vskip4pt \hrule height 2pt width \hsize
  1456. \vskip\titlepagebottomglue
  1457. \finishedtitlepagetrue
  1458. }
  1459. %%% Set up page headings and footings.
  1460. \let\thispage=\folio
  1461. \newtoks\evenheadline % headline on even pages
  1462. \newtoks\oddheadline % headline on odd pages
  1463. \newtoks\evenfootline % footline on even pages
  1464. \newtoks\oddfootline % footline on odd pages
  1465. % Now make Tex use those variables
  1466. \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
  1467. \else \the\evenheadline \fi}}
  1468. \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
  1469. \else \the\evenfootline \fi}\HEADINGShook}
  1470. \let\HEADINGShook=\relax
  1471. % Commands to set those variables.
  1472. % For example, this is what @headings on does
  1473. % @evenheading @thistitle|@thispage|@thischapter
  1474. % @oddheading @thischapter|@thispage|@thistitle
  1475. % @evenfooting @thisfile||
  1476. % @oddfooting ||@thisfile
  1477. \def\evenheading{\parsearg\evenheadingxxx}
  1478. \def\oddheading{\parsearg\oddheadingxxx}
  1479. \def\everyheading{\parsearg\everyheadingxxx}
  1480. \def\evenfooting{\parsearg\evenfootingxxx}
  1481. \def\oddfooting{\parsearg\oddfootingxxx}
  1482. \def\everyfooting{\parsearg\everyfootingxxx}
  1483. {\catcode`\@=0 %
  1484. \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
  1485. \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
  1486. \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1487. \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
  1488. \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
  1489. \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1490. \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
  1491. \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
  1492. \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
  1493. \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  1494. \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
  1495. \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
  1496. \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
  1497. %
  1498. % Leave some space for the footline. Hopefully ok to assume
  1499. % @evenfooting will not be used by itself.
  1500. \global\advance\pageheight by -\baselineskip
  1501. \global\advance\vsize by -\baselineskip
  1502. }
  1503. \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
  1504. %
  1505. }% unbind the catcode of @.
  1506. % @headings double turns headings on for double-sided printing.
  1507. % @headings single turns headings on for single-sided printing.
  1508. % @headings off turns them off.
  1509. % @headings on same as @headings double, retained for compatibility.
  1510. % @headings after turns on double-sided headings after this page.
  1511. % @headings doubleafter turns on double-sided headings after this page.
  1512. % @headings singleafter turns on single-sided headings after this page.
  1513. % By default, they are off at the start of a document,
  1514. % and turned `on' after @end titlepage.
  1515. \def\headings #1 {\csname HEADINGS#1\endcsname}
  1516. \def\HEADINGSoff{
  1517. \global\evenheadline={\hfil} \global\evenfootline={\hfil}
  1518. \global\oddheadline={\hfil} \global\oddfootline={\hfil}}
  1519. \HEADINGSoff
  1520. % When we turn headings on, set the page number to 1.
  1521. % For double-sided printing, put current file name in lower left corner,
  1522. % chapter name on inside top of right hand pages, document
  1523. % title on inside top of left hand pages, and page numbers on outside top
  1524. % edge of all pages.
  1525. \def\HEADINGSdouble{
  1526. \global\pageno=1
  1527. \global\evenfootline={\hfil}
  1528. \global\oddfootline={\hfil}
  1529. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1530. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1531. \global\let\contentsalignmacro = \chapoddpage
  1532. }
  1533. \let\contentsalignmacro = \chappager
  1534. % For single-sided printing, chapter title goes across top left of page,
  1535. % page number on top right.
  1536. \def\HEADINGSsingle{
  1537. \global\pageno=1
  1538. \global\evenfootline={\hfil}
  1539. \global\oddfootline={\hfil}
  1540. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1541. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1542. \global\let\contentsalignmacro = \chappager
  1543. }
  1544. \def\HEADINGSon{\HEADINGSdouble}
  1545. \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
  1546. \let\HEADINGSdoubleafter=\HEADINGSafter
  1547. \def\HEADINGSdoublex{%
  1548. \global\evenfootline={\hfil}
  1549. \global\oddfootline={\hfil}
  1550. \global\evenheadline={\line{\folio\hfil\thistitle}}
  1551. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1552. \global\let\contentsalignmacro = \chapoddpage
  1553. }
  1554. \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
  1555. \def\HEADINGSsinglex{%
  1556. \global\evenfootline={\hfil}
  1557. \global\oddfootline={\hfil}
  1558. \global\evenheadline={\line{\thischapter\hfil\folio}}
  1559. \global\oddheadline={\line{\thischapter\hfil\folio}}
  1560. \global\let\contentsalignmacro = \chappager
  1561. }
  1562. % Subroutines used in generating headings
  1563. % Produces Day Month Year style of output.
  1564. \def\today{\number\day\space
  1565. \ifcase\month\or
  1566. January\or February\or March\or April\or May\or June\or
  1567. July\or August\or September\or October\or November\or December\fi
  1568. \space\number\year}
  1569. % Use this if you want the Month Day, Year style of output.
  1570. %\def\today{\ifcase\month\or
  1571. %January\or February\or March\or April\or May\or June\or
  1572. %July\or August\or September\or October\or November\or December\fi
  1573. %\space\number\day, \number\year}
  1574. % @settitle line... specifies the title of the document, for headings
  1575. % It generates no output of its own
  1576. \def\thistitle{No Title}
  1577. \def\settitle{\parsearg\settitlezzz}
  1578. \def\settitlezzz #1{\gdef\thistitle{#1}}
  1579. \message{tables,}
  1580. % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
  1581. % default indentation of table text
  1582. \newdimen\tableindent \tableindent=.8in
  1583. % default indentation of @itemize and @enumerate text
  1584. \newdimen\itemindent \itemindent=.3in
  1585. % margin between end of table item and start of table text.
  1586. \newdimen\itemmargin \itemmargin=.1in
  1587. % used internally for \itemindent minus \itemmargin
  1588. \newdimen\itemmax
  1589. % Note @table, @vtable, and @vtable define @item, @itemx, etc., with
  1590. % these defs.
  1591. % They also define \itemindex
  1592. % to index the item name in whatever manner is desired (perhaps none).
  1593. \newif\ifitemxneedsnegativevskip
  1594. \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
  1595. \def\internalBitem{\smallbreak \parsearg\itemzzz}
  1596. \def\internalBitemx{\itemxpar \parsearg\itemzzz}
  1597. \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
  1598. \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
  1599. \def\internalBkitem{\smallbreak \parsearg\kitemzzz}
  1600. \def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
  1601. \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
  1602. \itemzzz {#1}}
  1603. \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
  1604. \itemzzz {#1}}
  1605. \def\itemzzz #1{\begingroup %
  1606. \advance\hsize by -\rightskip
  1607. \advance\hsize by -\tableindent
  1608. \setbox0=\hbox{\itemfont{#1}}%
  1609. \itemindex{#1}%
  1610. \nobreak % This prevents a break before @itemx.
  1611. %
  1612. % If the item text does not fit in the space we have, put it on a line
  1613. % by itself, and do not allow a page break either before or after that
  1614. % line. We do not start a paragraph here because then if the next
  1615. % command is, e.g., @kindex, the whatsit would get put into the
  1616. % horizontal list on a line by itself, resulting in extra blank space.
  1617. \ifdim \wd0>\itemmax
  1618. %
  1619. % Make this a paragraph so we get the \parskip glue and wrapping,
  1620. % but leave it ragged-right.
  1621. \begingroup
  1622. \advance\leftskip by-\tableindent
  1623. \advance\hsize by\tableindent
  1624. \advance\rightskip by0pt plus1fil
  1625. \leavevmode\unhbox0\par
  1626. \endgroup
  1627. %
  1628. % We're going to be starting a paragraph, but we don't want the
  1629. % \parskip glue -- logically it's part of the @item we just started.
  1630. \nobreak \vskip-\parskip
  1631. %
  1632. % Stop a page break at the \parskip glue coming up. Unfortunately
  1633. % we can't prevent a possible page break at the following
  1634. % \baselineskip glue.
  1635. \nobreak
  1636. \endgroup
  1637. \itemxneedsnegativevskipfalse
  1638. \else
  1639. % The item text fits into the space. Start a paragraph, so that the
  1640. % following text (if any) will end up on the same line.
  1641. \noindent
  1642. % Do this with kerns and \unhbox so that if there is a footnote in
  1643. % the item text, it can migrate to the main vertical list and
  1644. % eventually be printed.
  1645. \nobreak\kern-\tableindent
  1646. \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
  1647. \unhbox0
  1648. \nobreak\kern\dimen0
  1649. \endgroup
  1650. \itemxneedsnegativevskiptrue
  1651. \fi
  1652. }
  1653. \def\item{\errmessage{@item while not in a table}}
  1654. \def\itemx{\errmessage{@itemx while not in a table}}
  1655. \def\kitem{\errmessage{@kitem while not in a table}}
  1656. \def\kitemx{\errmessage{@kitemx while not in a table}}
  1657. \def\xitem{\errmessage{@xitem while not in a table}}
  1658. \def\xitemx{\errmessage{@xitemx while not in a table}}
  1659. % Contains a kludge to get @end[description] to work.
  1660. \def\description{\tablez{\dontindex}{1}{}{}{}{}}
  1661. % @table, @ftable, @vtable.
  1662. \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
  1663. {\obeylines\obeyspaces%
  1664. \gdef\tablex #1^^M{%
  1665. \tabley\dontindex#1 \endtabley}}
  1666. \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
  1667. {\obeylines\obeyspaces%
  1668. \gdef\ftablex #1^^M{%
  1669. \tabley\fnitemindex#1 \endtabley
  1670. \def\Eftable{\endgraf\afterenvbreak\endgroup}%
  1671. \let\Etable=\relax}}
  1672. \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
  1673. {\obeylines\obeyspaces%
  1674. \gdef\vtablex #1^^M{%
  1675. \tabley\vritemindex#1 \endtabley
  1676. \def\Evtable{\endgraf\afterenvbreak\endgroup}%
  1677. \let\Etable=\relax}}
  1678. \def\dontindex #1{}
  1679. \def\fnitemindex #1{\doind {fn}{\code{#1}}}%
  1680. \def\vritemindex #1{\doind {vr}{\code{#1}}}%
  1681. {\obeyspaces %
  1682. \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
  1683. \tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
  1684. \def\tablez #1#2#3#4#5#6{%
  1685. \aboveenvbreak %
  1686. \begingroup %
  1687. \def\Edescription{\Etable}% Necessary kludge.
  1688. \let\itemindex=#1%
  1689. \ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
  1690. \ifnum 0#4>0 \tableindent=#4\mil \fi %
  1691. \ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
  1692. \def\itemfont{#2}%
  1693. \itemmax=\tableindent %
  1694. \advance \itemmax by -\itemmargin %
  1695. \advance \leftskip by \tableindent %
  1696. \exdentamount=\tableindent
  1697. \parindent = 0pt
  1698. \parskip = \smallskipamount
  1699. \ifdim \parskip=0pt \parskip=2pt \fi%
  1700. \def\Etable{\endgraf\afterenvbreak\endgroup}%
  1701. \let\item = \internalBitem %
  1702. \let\itemx = \internalBitemx %
  1703. \let\kitem = \internalBkitem %
  1704. \let\kitemx = \internalBkitemx %
  1705. \let\xitem = \internalBxitem %
  1706. \let\xitemx = \internalBxitemx %
  1707. }
  1708. % This is the counter used by @enumerate, which is really @itemize
  1709. \newcount \itemno
  1710. \def\itemize{\parsearg\itemizezzz}
  1711. \def\itemizezzz #1{%
  1712. \begingroup % ended by the @end itemize
  1713. \itemizey {#1}{\Eitemize}
  1714. }
  1715. \def\itemizey #1#2{%
  1716. \aboveenvbreak %
  1717. \itemmax=\itemindent %
  1718. \advance \itemmax by -\itemmargin %
  1719. \advance \leftskip by \itemindent %
  1720. \exdentamount=\itemindent
  1721. \parindent = 0pt %
  1722. \parskip = \smallskipamount %
  1723. \ifdim \parskip=0pt \parskip=2pt \fi%
  1724. \def#2{\endgraf\afterenvbreak\endgroup}%
  1725. \def\itemcontents{#1}%
  1726. \let\item=\itemizeitem}
  1727. % Set sfcode to normal for the chars that usually have another value.
  1728. % These are `.?!:;,'
  1729. \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
  1730. \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
  1731. % \splitoff TOKENS\endmark defines \first to be the first token in
  1732. % TOKENS, and \rest to be the remainder.
  1733. %
  1734. \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
  1735. % Allow an optional argument of an uppercase letter, lowercase letter,
  1736. % or number, to specify the first label in the enumerated list. No
  1737. % argument is the same as `1'.
  1738. %
  1739. \def\enumerate{\parsearg\enumeratezzz}
  1740. \def\enumeratezzz #1{\enumeratey #1 \endenumeratey}
  1741. \def\enumeratey #1 #2\endenumeratey{%
  1742. \begingroup % ended by the @end enumerate
  1743. %
  1744. % If we were given no argument, pretend we were given `1'.
  1745. \def\thearg{#1}%
  1746. \ifx\thearg\empty \def\thearg{1}\fi
  1747. %
  1748. % Detect if the argument is a single token. If so, it might be a
  1749. % letter. Otherwise, the only valid thing it can be is a number.
  1750. % (We will always have one token, because of the test we just made.
  1751. % This is a good thing, since \splitoff doesn't work given nothing at
  1752. % all -- the first parameter is undelimited.)
  1753. \expandafter\splitoff\thearg\endmark
  1754. \ifx\rest\empty
  1755. % Only one token in the argument. It could still be anything.
  1756. % A ``lowercase letter'' is one whose \lccode is nonzero.
  1757. % An ``uppercase letter'' is one whose \lccode is both nonzero, and
  1758. % not equal to itself.
  1759. % Otherwise, we assume it's a number.
  1760. %
  1761. % We need the \relax at the end of the \ifnum lines to stop TeX from
  1762. % continuing to look for a <number>.
  1763. %
  1764. \ifnum\lccode\expandafter`\thearg=0\relax
  1765. \numericenumerate % a number (we hope)
  1766. \else
  1767. % It's a letter.
  1768. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
  1769. \lowercaseenumerate % lowercase letter
  1770. \else
  1771. \uppercaseenumerate % uppercase letter
  1772. \fi
  1773. \fi
  1774. \else
  1775. % Multiple tokens in the argument. We hope it's a number.
  1776. \numericenumerate
  1777. \fi
  1778. }
  1779. % An @enumerate whose labels are integers. The starting integer is
  1780. % given in \thearg.
  1781. %
  1782. \def\numericenumerate{%
  1783. \itemno = \thearg
  1784. \startenumeration{\the\itemno}%
  1785. }
  1786. % The starting (lowercase) letter is in \thearg.
  1787. \def\lowercaseenumerate{%
  1788. \itemno = \expandafter`\thearg
  1789. \startenumeration{%
  1790. % Be sure we're not beyond the end of the alphabet.
  1791. \ifnum\itemno=0
  1792. \errmessage{No more lowercase letters in @enumerate; get a bigger
  1793. alphabet}%
  1794. \fi
  1795. \char\lccode\itemno
  1796. }%
  1797. }
  1798. % The starting (uppercase) letter is in \thearg.
  1799. \def\uppercaseenumerate{%
  1800. \itemno = \expandafter`\thearg
  1801. \startenumeration{%
  1802. % Be sure we're not beyond the end of the alphabet.
  1803. \ifnum\itemno=0
  1804. \errmessage{No more uppercase letters in @enumerate; get a bigger
  1805. alphabet}
  1806. \fi
  1807. \char\uccode\itemno
  1808. }%
  1809. }
  1810. % Call itemizey, adding a period to the first argument and supplying the
  1811. % common last two arguments. Also subtract one from the initial value in
  1812. % \itemno, since @item increments \itemno.
  1813. %
  1814. \def\startenumeration#1{%
  1815. \advance\itemno by -1
  1816. \itemizey{#1.}\Eenumerate\flushcr
  1817. }
  1818. % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
  1819. % to @enumerate.
  1820. %
  1821. \def\alphaenumerate{\enumerate{a}}
  1822. \def\capsenumerate{\enumerate{A}}
  1823. \def\Ealphaenumerate{\Eenumerate}
  1824. \def\Ecapsenumerate{\Eenumerate}
  1825. % Definition of @item while inside @itemize.
  1826. \def\itemizeitem{%
  1827. \advance\itemno by 1
  1828. {\let\par=\endgraf \smallbreak}%
  1829. \ifhmode \errmessage{In hmode at itemizeitem}\fi
  1830. {\parskip=0in \hskip 0pt
  1831. \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
  1832. \vadjust{\penalty 1200}}%
  1833. \flushcr}
  1834. % @multitable macros
  1835. % Amy Hendrickson, 8/18/94, 3/6/96
  1836. %
  1837. % @multitable ... @end multitable will make as many columns as desired.
  1838. % Contents of each column will wrap at width given in preamble. Width
  1839. % can be specified either with sample text given in a template line,
  1840. % or in percent of \hsize, the current width of text on page.
  1841. % Table can continue over pages but will only break between lines.
  1842. % To make preamble:
  1843. %
  1844. % Either define widths of columns in terms of percent of \hsize:
  1845. % @multitable @columnfractions .25 .3 .45
  1846. % @item ...
  1847. %
  1848. % Numbers following @columnfractions are the percent of the total
  1849. % current hsize to be used for each column. You may use as many
  1850. % columns as desired.
  1851. % Or use a template:
  1852. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1853. % @item ...
  1854. % using the widest term desired in each column.
  1855. %
  1856. % For those who want to use more than one line's worth of words in
  1857. % the preamble, break the line within one argument and it
  1858. % will parse correctly, i.e.,
  1859. %
  1860. % @multitable {Column 1 template} {Column 2 template} {Column 3
  1861. % template}
  1862. % Not:
  1863. % @multitable {Column 1 template} {Column 2 template}
  1864. % {Column 3 template}
  1865. % Each new table line starts with @item, each subsequent new column
  1866. % starts with @tab. Empty columns may be produced by supplying @tab's
  1867. % with nothing between them for as many times as empty columns are needed,
  1868. % ie, @tab@tab@tab will produce two empty columns.
  1869. % @item, @tab, @multitable or @end multitable do not need to be on their
  1870. % own lines, but it will not hurt if they are.
  1871. % Sample multitable:
  1872. % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
  1873. % @item first col stuff @tab second col stuff @tab third col
  1874. % @item
  1875. % first col stuff
  1876. % @tab
  1877. % second col stuff
  1878. % @tab
  1879. % third col
  1880. % @item first col stuff @tab second col stuff
  1881. % @tab Many paragraphs of text may be used in any column.
  1882. %
  1883. % They will wrap at the width determined by the template.
  1884. % @item@tab@tab This will be in third column.
  1885. % @end multitable
  1886. % Default dimensions may be reset by user.
  1887. % @multitableparskip is vertical space between paragraphs in table.
  1888. % @multitableparindent is paragraph indent in table.
  1889. % @multitablecolmargin is horizontal space to be left between columns.
  1890. % @multitablelinespace is space to leave between table items, baseline
  1891. % to baseline.
  1892. % 0pt means it depends on current normal line spacing.
  1893. %
  1894. \newskip\multitableparskip
  1895. \newskip\multitableparindent
  1896. \newdimen\multitablecolspace
  1897. \newskip\multitablelinespace
  1898. \multitableparskip=0pt
  1899. \multitableparindent=6pt
  1900. \multitablecolspace=12pt
  1901. \multitablelinespace=0pt
  1902. % Macros used to set up halign preamble:
  1903. %
  1904. \let\endsetuptable\relax
  1905. \def\xendsetuptable{\endsetuptable}
  1906. \let\columnfractions\relax
  1907. \def\xcolumnfractions{\columnfractions}
  1908. \newif\ifsetpercent
  1909. % #1 is the part of the @columnfraction before the decimal point, which
  1910. % is presumably either 0 or the empty string (but we don't check, we
  1911. % just throw it away). #2 is the decimal part, which we use as the
  1912. % percent of \hsize for this column.
  1913. \def\pickupwholefraction#1.#2 {%
  1914. \global\advance\colcount by 1
  1915. \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
  1916. \setuptable
  1917. }
  1918. \newcount\colcount
  1919. \def\setuptable#1{%
  1920. \def\firstarg{#1}%
  1921. \ifx\firstarg\xendsetuptable
  1922. \let\go = \relax
  1923. \else
  1924. \ifx\firstarg\xcolumnfractions
  1925. \global\setpercenttrue
  1926. \else
  1927. \ifsetpercent
  1928. \let\go\pickupwholefraction
  1929. \else
  1930. \global\advance\colcount by 1
  1931. \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
  1932. % typically that is always in the input, anyway.
  1933. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
  1934. \fi
  1935. \fi
  1936. \ifx\go\pickupwholefraction
  1937. % Put the argument back for the \pickupwholefraction call, so
  1938. % we'll always have a period there to be parsed.
  1939. \def\go{\pickupwholefraction#1}%
  1940. \else
  1941. \let\go = \setuptable
  1942. \fi%
  1943. \fi
  1944. \go
  1945. }
  1946. % multitable syntax
  1947. \def\tab{&\hskip1sp\relax} % 2/2/96
  1948. % tiny skip here makes sure this column space is
  1949. % maintained, even if it is never used.
  1950. % @multitable ... @end multitable definitions:
  1951. %
  1952. \def\multitable{\parsearg\dotable}
  1953. \def\dotable#1{\bgroup
  1954. \vskip\parskip
  1955. \let\item\crcr
  1956. \tolerance=9500
  1957. \hbadness=9500
  1958. \setmultitablespacing
  1959. \parskip=\multitableparskip
  1960. \parindent=\multitableparindent
  1961. \overfullrule=0pt
  1962. \global\colcount=0
  1963. \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
  1964. %
  1965. % To parse everything between @multitable and @item:
  1966. \setuptable#1 \endsetuptable
  1967. %
  1968. % \everycr will reset column counter, \colcount, at the end of
  1969. % each line. Every column entry will cause \colcount to advance by one.
  1970. % The table preamble
  1971. % looks at the current \colcount to find the correct column width.
  1972. \everycr{\noalign{%
  1973. %
  1974. % \filbreak%% keeps underfull box messages off when table breaks over pages.
  1975. % Maybe so, but it also creates really weird page breaks when the table
  1976. % breaks over pages. Wouldn't \vfil be better? Wait until the problem
  1977. % manifests itself, so it can be fixed for real --karl.
  1978. \global\colcount=0\relax}}%
  1979. %
  1980. % This preamble sets up a generic column definition, which will
  1981. % be used as many times as user calls for columns.
  1982. % \vtop will set a single line and will also let text wrap and
  1983. % continue for many paragraphs if desired.
  1984. \halign\bgroup&\global\advance\colcount by 1\relax
  1985. \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
  1986. %
  1987. % In order to keep entries from bumping into each other
  1988. % we will add a \leftskip of \multitablecolspace to all columns after
  1989. % the first one.
  1990. %
  1991. % If a template has been used, we will add \multitablecolspace
  1992. % to the width of each template entry.
  1993. %
  1994. % If the user has set preamble in terms of percent of \hsize we will
  1995. % use that dimension as the width of the column, and the \leftskip
  1996. % will keep entries from bumping into each other. Table will start at
  1997. % left margin and final column will justify at right margin.
  1998. %
  1999. % Make sure we don't inherit \rightskip from the outer environment.
  2000. \rightskip=0pt
  2001. \ifnum\colcount=1
  2002. % The first column will be indented with the surrounding text.
  2003. \advance\hsize by\leftskip
  2004. \else
  2005. \ifsetpercent \else
  2006. % If user has not set preamble in terms of percent of \hsize
  2007. % we will advance \hsize by \multitablecolspace.
  2008. \advance\hsize by \multitablecolspace
  2009. \fi
  2010. % In either case we will make \leftskip=\multitablecolspace:
  2011. \leftskip=\multitablecolspace
  2012. \fi
  2013. % Ignoring space at the beginning and end avoids an occasional spurious
  2014. % blank line, when TeX decides to break the line at the space before the
  2015. % box from the multistrut, so the strut ends up on a line by itself.
  2016. % For example:
  2017. % @multitable @columnfractions .11 .89
  2018. % @item @code{#}
  2019. % @tab Legal holiday which is valid in major parts of the whole country.
  2020. % Is automatically provided with highlighting sequences respectively marking
  2021. % characters.
  2022. \noindent\ignorespaces##\unskip\multistrut}\cr
  2023. }
  2024. \def\setmultitablespacing{% test to see if user has set \multitablelinespace.
  2025. % If so, do nothing. If not, give it an appropriate dimension based on
  2026. % current baselineskip.
  2027. \ifdim\multitablelinespace=0pt
  2028. %% strut to put in table in case some entry doesn't have descenders,
  2029. %% to keep lines equally spaced
  2030. \let\multistrut = \strut
  2031. %% Test to see if parskip is larger than space between lines of
  2032. %% table. If not, do nothing.
  2033. %% If so, set to same dimension as multitablelinespace.
  2034. \else
  2035. \gdef\multistrut{\vrule height\multitablelinespace depth\dp0
  2036. width0pt\relax} \fi
  2037. \ifdim\multitableparskip>\multitablelinespace
  2038. \global\multitableparskip=\multitablelinespace
  2039. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  2040. %% than skip between lines in the table.
  2041. \fi%
  2042. \ifdim\multitableparskip=0pt
  2043. \global\multitableparskip=\multitablelinespace
  2044. \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
  2045. %% than skip between lines in the table.
  2046. \fi}
  2047. \message{indexing,}
  2048. % Index generation facilities
  2049. % Define \newwrite to be identical to plain tex's \newwrite
  2050. % except not \outer, so it can be used within \newindex.
  2051. {\catcode`\@=11
  2052. \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
  2053. % \newindex {foo} defines an index named foo.
  2054. % It automatically defines \fooindex such that
  2055. % \fooindex ...rest of line... puts an entry in the index foo.
  2056. % It also defines \fooindfile to be the number of the output channel for
  2057. % the file that accumulates this index. The file's extension is foo.
  2058. % The name of an index should be no more than 2 characters long
  2059. % for the sake of vms.
  2060. %
  2061. \def\newindex#1{%
  2062. \iflinks
  2063. \expandafter\newwrite \csname#1indfile\endcsname
  2064. \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
  2065. \fi
  2066. \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
  2067. \noexpand\doindex{#1}}
  2068. }
  2069. % @defindex foo == \newindex{foo}
  2070. \def\defindex{\parsearg\newindex}
  2071. % Define @defcodeindex, like @defindex except put all entries in @code.
  2072. \def\newcodeindex#1{%
  2073. \iflinks
  2074. \expandafter\newwrite \csname#1indfile\endcsname
  2075. \openout \csname#1indfile\endcsname \jobname.#1
  2076. \fi
  2077. \expandafter\xdef\csname#1index\endcsname{%
  2078. \noexpand\docodeindex{#1}}
  2079. }
  2080. \def\defcodeindex{\parsearg\newcodeindex}
  2081. % @synindex foo bar makes index foo feed into index bar.
  2082. % Do this instead of @defindex foo if you don't want it as a separate index.
  2083. % The \closeout helps reduce unnecessary open files; the limit on the
  2084. % Acorn RISC OS is a mere 16 files.
  2085. \def\synindex#1 #2 {%
  2086. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  2087. \expandafter\closeout\csname#1indfile\endcsname
  2088. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  2089. \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
  2090. \noexpand\doindex{#2}}%
  2091. }
  2092. % @syncodeindex foo bar similar, but put all entries made for index foo
  2093. % inside @code.
  2094. \def\syncodeindex#1 #2 {%
  2095. \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
  2096. \expandafter\closeout\csname#1indfile\endcsname
  2097. \expandafter\let\csname#1indfile\endcsname=\synindexfoo
  2098. \expandafter\xdef\csname#1index\endcsname{% define \xxxindex
  2099. \noexpand\docodeindex{#2}}%
  2100. }
  2101. % Define \doindex, the driver for all \fooindex macros.
  2102. % Argument #1 is generated by the calling \fooindex macro,
  2103. % and it is "foo", the name of the index.
  2104. % \doindex just uses \parsearg; it calls \doind for the actual work.
  2105. % This is because \doind is more useful to call from other macros.
  2106. % There is also \dosubind {index}{topic}{subtopic}
  2107. % which makes an entry in a two-level index such as the operation index.
  2108. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
  2109. \def\singleindexer #1{\doind{\indexname}{#1}}
  2110. % like the previous two, but they put @code around the argument.
  2111. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
  2112. \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
  2113. \def\indexdummies{%
  2114. \def\ { }%
  2115. % Take care of the plain tex accent commands.
  2116. \def\"{\realbackslash "}%
  2117. \def\`{\realbackslash `}%
  2118. \def\'{\realbackslash '}%
  2119. \def\^{\realbackslash ^}%
  2120. \def\~{\realbackslash ~}%
  2121. \def\={\realbackslash =}%
  2122. \def\b{\realbackslash b}%
  2123. \def\c{\realbackslash c}%
  2124. \def\d{\realbackslash d}%
  2125. \def\u{\realbackslash u}%
  2126. \def\v{\realbackslash v}%
  2127. \def\H{\realbackslash H}%
  2128. % Take care of the plain tex special European modified letters.
  2129. \def\oe{\realbackslash oe}%
  2130. \def\ae{\realbackslash ae}%
  2131. \def\aa{\realbackslash aa}%
  2132. \def\OE{\realbackslash OE}%
  2133. \def\AE{\realbackslash AE}%
  2134. \def\AA{\realbackslash AA}%
  2135. \def\o{\realbackslash o}%
  2136. \def\O{\realbackslash O}%
  2137. \def\l{\realbackslash l}%
  2138. \def\L{\realbackslash L}%
  2139. \def\ss{\realbackslash ss}%
  2140. % Take care of texinfo commands likely to appear in an index entry.
  2141. % (Must be a way to avoid doing expansion at all, and thus not have to
  2142. % laboriously list every single command here.)
  2143. \def\@{@}% will be @@ when we switch to @ as escape char.
  2144. % Need these in case \tex is in effect and \{ is a \delimiter again.
  2145. % But can't use \lbracecmd and \rbracecmd because texindex assumes
  2146. % braces and backslashes are used only as delimiters.
  2147. \let\{ = \mylbrace
  2148. \let\} = \myrbrace
  2149. \def\_{{\realbackslash _}}%
  2150. \def\w{\realbackslash w }%
  2151. \def\bf{\realbackslash bf }%
  2152. %\def\rm{\realbackslash rm }%
  2153. \def\sl{\realbackslash sl }%
  2154. \def\sf{\realbackslash sf}%
  2155. \def\tt{\realbackslash tt}%
  2156. \def\gtr{\realbackslash gtr}%
  2157. \def\less{\realbackslash less}%
  2158. \def\hat{\realbackslash hat}%
  2159. \def\TeX{\realbackslash TeX}%
  2160. \def\dots{\realbackslash dots }%
  2161. \def\result{\realbackslash result}%
  2162. \def\equiv{\realbackslash equiv}%
  2163. \def\expansion{\realbackslash expansion}%
  2164. \def\print{\realbackslash print}%
  2165. \def\error{\realbackslash error}%
  2166. \def\point{\realbackslash point}%
  2167. \def\copyright{\realbackslash copyright}%
  2168. \def\tclose##1{\realbackslash tclose {##1}}%
  2169. \def\code##1{\realbackslash code {##1}}%
  2170. \def\uref##1{\realbackslash uref {##1}}%
  2171. \def\url##1{\realbackslash url {##1}}%
  2172. \def\env##1{\realbackslash env {##1}}%
  2173. \def\command##1{\realbackslash command {##1}}%
  2174. \def\option##1{\realbackslash option {##1}}%
  2175. \def\dotless##1{\realbackslash dotless {##1}}%
  2176. \def\samp##1{\realbackslash samp {##1}}%
  2177. \def\,##1{\realbackslash ,{##1}}%
  2178. \def\t##1{\realbackslash t {##1}}%
  2179. \def\r##1{\realbackslash r {##1}}%
  2180. \def\i##1{\realbackslash i {##1}}%
  2181. \def\b##1{\realbackslash b {##1}}%
  2182. \def\sc##1{\realbackslash sc {##1}}%
  2183. \def\cite##1{\realbackslash cite {##1}}%
  2184. \def\key##1{\realbackslash key {##1}}%
  2185. \def\file##1{\realbackslash file {##1}}%
  2186. \def\var##1{\realbackslash var {##1}}%
  2187. \def\kbd##1{\realbackslash kbd {##1}}%
  2188. \def\dfn##1{\realbackslash dfn {##1}}%
  2189. \def\emph##1{\realbackslash emph {##1}}%
  2190. \def\acronym##1{\realbackslash acronym {##1}}%
  2191. %
  2192. % Handle some cases of @value -- where the variable name does not
  2193. % contain - or _, and the value does not contain any
  2194. % (non-fully-expandable) commands.
  2195. \let\value = \expandablevalue
  2196. %
  2197. \unsepspaces
  2198. }
  2199. % If an index command is used in an @example environment, any spaces
  2200. % therein should become regular spaces in the raw index file, not the
  2201. % expansion of \tie (\\leavevmode \penalty \@M \ ).
  2202. {\obeyspaces
  2203. \gdef\unsepspaces{\obeyspaces\let =\space}}
  2204. % \indexnofonts no-ops all font-change commands.
  2205. % This is used when outputting the strings to sort the index by.
  2206. \def\indexdummyfont#1{#1}
  2207. \def\indexdummytex{TeX}
  2208. \def\indexdummydots{...}
  2209. \def\indexnofonts{%
  2210. % Just ignore accents.
  2211. \let\,=\indexdummyfont
  2212. \let\"=\indexdummyfont
  2213. \let\`=\indexdummyfont
  2214. \let\'=\indexdummyfont
  2215. \let\^=\indexdummyfont
  2216. \let\~=\indexdummyfont
  2217. \let\==\indexdummyfont
  2218. \let\b=\indexdummyfont
  2219. \let\c=\indexdummyfont
  2220. \let\d=\indexdummyfont
  2221. \let\u=\indexdummyfont
  2222. \let\v=\indexdummyfont
  2223. \let\H=\indexdummyfont
  2224. \let\dotless=\indexdummyfont
  2225. % Take care of the plain tex special European modified letters.
  2226. \def\oe{oe}%
  2227. \def\ae{ae}%
  2228. \def\aa{aa}%
  2229. \def\OE{OE}%
  2230. \def\AE{AE}%
  2231. \def\AA{AA}%
  2232. \def\o{o}%
  2233. \def\O{O}%
  2234. \def\l{l}%
  2235. \def\L{L}%
  2236. \def\ss{ss}%
  2237. \let\w=\indexdummyfont
  2238. \let\t=\indexdummyfont
  2239. \let\r=\indexdummyfont
  2240. \let\i=\indexdummyfont
  2241. \let\b=\indexdummyfont
  2242. \let\emph=\indexdummyfont
  2243. \let\strong=\indexdummyfont
  2244. \let\cite=\indexdummyfont
  2245. \let\sc=\indexdummyfont
  2246. %Don't no-op \tt, since it isn't a user-level command
  2247. % and is used in the definitions of the active chars like <, >, |...
  2248. %\let\tt=\indexdummyfont
  2249. \let\tclose=\indexdummyfont
  2250. \let\code=\indexdummyfont
  2251. \let\url=\indexdummyfont
  2252. \let\uref=\indexdummyfont
  2253. \let\env=\indexdummyfont
  2254. \let\command=\indexdummyfont
  2255. \let\option=\indexdummyfont
  2256. \let\file=\indexdummyfont
  2257. \let\samp=\indexdummyfont
  2258. \let\kbd=\indexdummyfont
  2259. \let\key=\indexdummyfont
  2260. \let\var=\indexdummyfont
  2261. \let\TeX=\indexdummytex
  2262. \let\dots=\indexdummydots
  2263. \def\@{@}%
  2264. }
  2265. % To define \realbackslash, we must make \ not be an escape.
  2266. % We must first make another character (@) an escape
  2267. % so we do not become unable to do a definition.
  2268. {\catcode`\@=0 \catcode`\\=\other
  2269. @gdef@realbackslash{\}}
  2270. \let\indexbackslash=0 %overridden during \printindex.
  2271. \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
  2272. % For \ifx comparisons.
  2273. \def\emptymacro{\empty}
  2274. % Most index entries go through here, but \dosubind is the general case.
  2275. %
  2276. \def\doind#1#2{\dosubind{#1}{#2}\empty}
  2277. % Workhorse for all \fooindexes.
  2278. % #1 is name of index, #2 is stuff to put there, #3 is subentry --
  2279. % \empty if called from \doind, as we usually are. The main exception
  2280. % is with defuns, which call us directly.
  2281. %
  2282. \def\dosubind#1#2#3{%
  2283. % Put the index entry in the margin if desired.
  2284. \ifx\SETmarginindex\relax\else
  2285. \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
  2286. \fi
  2287. {%
  2288. \count255=\lastpenalty
  2289. {%
  2290. \indexdummies % Must do this here, since \bf, etc expand at this stage
  2291. \escapechar=`\\
  2292. {%
  2293. \let\folio = 0% We will expand all macros now EXCEPT \folio.
  2294. \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
  2295. % so it will be output as is; and it will print as backslash.
  2296. %
  2297. \def\thirdarg{#3}%
  2298. %
  2299. % If third arg is present, precede it with space in sort key.
  2300. \ifx\thirdarg\emptymacro
  2301. \let\subentry = \empty
  2302. \else
  2303. \def\subentry{ #3}%
  2304. \fi
  2305. %
  2306. % First process the index-string with all font commands turned off
  2307. % to get the string to sort by.
  2308. {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
  2309. %
  2310. % Now produce the complete index entry, with both the sort key and the
  2311. % original text, including any font commands.
  2312. \toks0 = {#2}%
  2313. \edef\temp{%
  2314. \write\csname#1indfile\endcsname{%
  2315. \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
  2316. }%
  2317. %
  2318. % If third (subentry) arg is present, add it to the index string.
  2319. \ifx\thirdarg\emptymacro \else
  2320. \toks0 = {#3}%
  2321. \edef\temp{\temp{\the\toks0}}%
  2322. \fi
  2323. %
  2324. % If a skip is the last thing on the list now, preserve it
  2325. % by backing up by \lastskip, doing the \write, then inserting
  2326. % the skip again. Otherwise, the whatsit generated by the
  2327. % \write will make \lastskip zero. The result is that sequences
  2328. % like this:
  2329. % @end defun
  2330. % @tindex whatever
  2331. % @defun ...
  2332. % will have extra space inserted, because the \medbreak in the
  2333. % start of the @defun won't see the skip inserted by the @end of
  2334. % the previous defun.
  2335. %
  2336. % But don't do any of this if we're not in vertical mode. We
  2337. % don't want to do a \vskip and prematurely end a paragraph.
  2338. %
  2339. % Avoid page breaks due to these extra skips, too.
  2340. %
  2341. \iflinks
  2342. \ifvmode
  2343. \skip0 = \lastskip
  2344. \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
  2345. \fi
  2346. %
  2347. \temp % do the write
  2348. %
  2349. %
  2350. \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
  2351. \fi
  2352. }%
  2353. }%
  2354. \penalty\count255
  2355. }%
  2356. }
  2357. % The index entry written in the file actually looks like
  2358. % \entry {sortstring}{page}{topic}
  2359. % or
  2360. % \entry {sortstring}{page}{topic}{subtopic}
  2361. % The texindex program reads in these files and writes files
  2362. % containing these kinds of lines:
  2363. % \initial {c}
  2364. % before the first topic whose initial is c
  2365. % \entry {topic}{pagelist}
  2366. % for a topic that is used without subtopics
  2367. % \primary {topic}
  2368. % for the beginning of a topic that is used with subtopics
  2369. % \secondary {subtopic}{pagelist}
  2370. % for each subtopic.
  2371. % Define the user-accessible indexing commands
  2372. % @findex, @vindex, @kindex, @cindex.
  2373. \def\findex {\fnindex}
  2374. \def\kindex {\kyindex}
  2375. \def\cindex {\cpindex}
  2376. \def\vindex {\vrindex}
  2377. \def\tindex {\tpindex}
  2378. \def\pindex {\pgindex}
  2379. \def\cindexsub {\begingroup\obeylines\cindexsub}
  2380. {\obeylines %
  2381. \gdef\cindexsub "#1" #2^^M{\endgroup %
  2382. \dosubind{cp}{#2}{#1}}}
  2383. % Define the macros used in formatting output of the sorted index material.
  2384. % @printindex causes a particular index (the ??s file) to get printed.
  2385. % It does not print any chapter heading (usually an @unnumbered).
  2386. %
  2387. \def\printindex{\parsearg\doprintindex}
  2388. \def\doprintindex#1{\begingroup
  2389. \dobreak \chapheadingskip{10000}%
  2390. %
  2391. \indexfonts \rm
  2392. \tolerance = 9500
  2393. \indexbreaks
  2394. %
  2395. % See if the index file exists and is nonempty.
  2396. % Change catcode of @ here so that if the index file contains
  2397. % \initial {@}
  2398. % as its first line, TeX doesn't complain about mismatched braces
  2399. % (because it thinks @} is a control sequence).
  2400. \catcode`\@ = 11
  2401. \openin 1 \jobname.#1s
  2402. \ifeof 1
  2403. % \enddoublecolumns gets confused if there is no text in the index,
  2404. % and it loses the chapter title and the aux file entries for the
  2405. % index. The easiest way to prevent this problem is to make sure
  2406. % there is some text.
  2407. (Index is nonexistent)
  2408. \else
  2409. %
  2410. % If the index file exists but is empty, then \openin leaves \ifeof
  2411. % false. We have to make TeX try to read something from the file, so
  2412. % it can discover if there is anything in it.
  2413. \read 1 to \temp
  2414. \ifeof 1
  2415. (Index is empty)
  2416. \else
  2417. % Index files are almost Texinfo source, but we use \ as the escape
  2418. % character. It would be better to use @, but that's too big a change
  2419. % to make right now.
  2420. \def\indexbackslash{\rawbackslashxx}%
  2421. \catcode`\\ = 0
  2422. \escapechar = `\\
  2423. \begindoublecolumns
  2424. \input \jobname.#1s
  2425. \enddoublecolumns
  2426. \fi
  2427. \fi
  2428. \closein 1
  2429. \endgroup}
  2430. % These macros are used by the sorted index file itself.
  2431. % Change them to control the appearance of the index.
  2432. \def\initial#1{{%
  2433. % Some minor font changes for the special characters.
  2434. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
  2435. %
  2436. % Remove any glue we may have, we'll be inserting our own.
  2437. \removelastskip
  2438. %
  2439. % We like breaks before the index initials, so insert a bonus.
  2440. \penalty -300
  2441. %
  2442. % Typeset the initial. Making this add up to a whole number of
  2443. % baselineskips increases the chance of the dots lining up from column
  2444. % to column. It still won't often be perfect, because of the stretch
  2445. % we need before each entry, but it's better.
  2446. %
  2447. % No shrink because it confuses \balancecolumns.
  2448. \vskip 1.67\baselineskip plus .5\baselineskip
  2449. \leftline{\secbf #1}%
  2450. \vskip .33\baselineskip plus .1\baselineskip
  2451. %
  2452. % Do our best not to break after the initial.
  2453. \nobreak
  2454. }}
  2455. % This typesets a paragraph consisting of #1, dot leaders, and then #2
  2456. % flush to the right margin. It is used for index and table of contents
  2457. % entries. The paragraph is indented by \leftskip.
  2458. %
  2459. \def\entry#1#2{\begingroup
  2460. %
  2461. % Start a new paragraph if necessary, so our assignments below can't
  2462. % affect previous text.
  2463. \par
  2464. %
  2465. % Do not fill out the last line with white space.
  2466. \parfillskip = 0in
  2467. %
  2468. % No extra space above this paragraph.
  2469. \parskip = 0in
  2470. %
  2471. % Do not prefer a separate line ending with a hyphen to fewer lines.
  2472. \finalhyphendemerits = 0
  2473. %
  2474. % \hangindent is only relevant when the entry text and page number
  2475. % don't both fit on one line. In that case, bob suggests starting the
  2476. % dots pretty far over on the line. Unfortunately, a large
  2477. % indentation looks wrong when the entry text itself is broken across
  2478. % lines. So we use a small indentation and put up with long leaders.
  2479. %
  2480. % \hangafter is reset to 1 (which is the value we want) at the start
  2481. % of each paragraph, so we need not do anything with that.
  2482. \hangindent = 2em
  2483. %
  2484. % When the entry text needs to be broken, just fill out the first line
  2485. % with blank space.
  2486. \rightskip = 0pt plus1fil
  2487. %
  2488. % A bit of stretch before each entry for the benefit of balancing columns.
  2489. \vskip 0pt plus1pt
  2490. %
  2491. % Start a ``paragraph'' for the index entry so the line breaking
  2492. % parameters we've set above will have an effect.
  2493. \noindent
  2494. %
  2495. % Insert the text of the index entry. TeX will do line-breaking on it.
  2496. #1%
  2497. % The following is kludged to not output a line of dots in the index if
  2498. % there are no page numbers. The next person who breaks this will be
  2499. % cursed by a Unix daemon.
  2500. \def\tempa{{\rm }}%
  2501. \def\tempb{#2}%
  2502. \edef\tempc{\tempa}%
  2503. \edef\tempd{\tempb}%
  2504. \ifx\tempc\tempd\ \else%
  2505. %
  2506. % If we must, put the page number on a line of its own, and fill out
  2507. % this line with blank space. (The \hfil is overwhelmed with the
  2508. % fill leaders glue in \indexdotfill if the page number does fit.)
  2509. \hfil\penalty50
  2510. \null\nobreak\indexdotfill % Have leaders before the page number.
  2511. %
  2512. % The `\ ' here is removed by the implicit \unskip that TeX does as
  2513. % part of (the primitive) \par. Without it, a spurious underfull
  2514. % \hbox ensues.
  2515. \ #2% The page number ends the paragraph.
  2516. \fi%
  2517. \par
  2518. \endgroup}
  2519. % Like \dotfill except takes at least 1 em.
  2520. \def\indexdotfill{\cleaders
  2521. \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
  2522. \def\primary #1{\line{#1\hfil}}
  2523. \newskip\secondaryindent \secondaryindent=0.5cm
  2524. \def\secondary #1#2{
  2525. {\parfillskip=0in \parskip=0in
  2526. \hangindent =1in \hangafter=1
  2527. \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
  2528. }}
  2529. % Define two-column mode, which we use to typeset indexes.
  2530. % Adapted from the TeXbook, page 416, which is to say,
  2531. % the manmac.tex format used to print the TeXbook itself.
  2532. \catcode`\@=11
  2533. \newbox\partialpage
  2534. \newdimen\doublecolumnhsize
  2535. \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
  2536. % Grab any single-column material above us.
  2537. \output = {\global\setbox\partialpage = \vbox{%
  2538. %
  2539. % Here is a possibility not foreseen in manmac: if we accumulate a
  2540. % whole lot of material, we might end up calling this \output
  2541. % routine twice in a row (see the doublecol-lose test, which is
  2542. % essentially a couple of indexes with @setchapternewpage off). In
  2543. % that case, we must prevent the second \partialpage from
  2544. % simply overwriting the first, causing us to lose the page.
  2545. % This will preserve it until a real output routine can ship it
  2546. % out. Generally, \partialpage will be empty when this runs and
  2547. % this will be a no-op.
  2548. \unvbox\partialpage
  2549. %
  2550. % Unvbox the main output page.
  2551. \unvbox255
  2552. \kern-\topskip \kern\baselineskip
  2553. }}%
  2554. \eject % run that output routine to set \partialpage
  2555. %
  2556. % Use the double-column output routine for subsequent pages.
  2557. \output = {\doublecolumnout}%
  2558. %
  2559. % Change the page size parameters. We could do this once outside this
  2560. % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
  2561. % format, but then we repeat the same computation. Repeating a couple
  2562. % of assignments once per index is clearly meaningless for the
  2563. % execution time, so we may as well do it in one place.
  2564. %
  2565. % First we halve the line length, less a little for the gutter between
  2566. % the columns. We compute the gutter based on the line length, so it
  2567. % changes automatically with the paper format. The magic constant
  2568. % below is chosen so that the gutter has the same value (well, +-<1pt)
  2569. % as it did when we hard-coded it.
  2570. %
  2571. % We put the result in a separate register, \doublecolumhsize, so we
  2572. % can restore it in \pagesofar, after \hsize itself has (potentially)
  2573. % been clobbered.
  2574. %
  2575. \doublecolumnhsize = \hsize
  2576. \advance\doublecolumnhsize by -.04154\hsize
  2577. \divide\doublecolumnhsize by 2
  2578. \hsize = \doublecolumnhsize
  2579. %
  2580. % Double the \vsize as well. (We don't need a separate register here,
  2581. % since nobody clobbers \vsize.)
  2582. \advance\vsize by -\ht\partialpage
  2583. \vsize = 2\vsize
  2584. }
  2585. % The double-column output routine for all double-column pages except
  2586. % the last.
  2587. %
  2588. \def\doublecolumnout{%
  2589. \splittopskip=\topskip \splitmaxdepth=\maxdepth
  2590. % Get the available space for the double columns -- the normal
  2591. % (undoubled) page height minus any material left over from the
  2592. % previous page.
  2593. \dimen@ = \vsize
  2594. \divide\dimen@ by 2
  2595. %
  2596. % box0 will be the left-hand column, box2 the right.
  2597. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
  2598. \onepageout\pagesofar
  2599. \unvbox255
  2600. \penalty\outputpenalty
  2601. }
  2602. \def\pagesofar{%
  2603. % Re-output the contents of the output page -- any previous material,
  2604. % followed by the two boxes we just split, in box0 and box2.
  2605. \advance\vsize by \ht\partialpage
  2606. \unvbox\partialpage
  2607. %
  2608. \hsize = \doublecolumnhsize
  2609. \wd0=\hsize \wd2=\hsize
  2610. \hbox to\pagewidth{\box0\hfil\box2}%
  2611. }
  2612. \def\enddoublecolumns{%
  2613. \output = {%
  2614. % Split the last of the double-column material. Leave it on the
  2615. % current page, no automatic page break.
  2616. \balancecolumns
  2617. %
  2618. % If we end up splitting too much material for the current page,
  2619. % though, there will be another page break right after this \output
  2620. % invocation ends. Having called \balancecolumns once, we do not
  2621. % want to call it again. Therefore, reset \output to its normal
  2622. % definition right away. (We hope \balancecolumns will never be
  2623. % called on to balance too much material, but if it is, this makes
  2624. % the output somewhat more palatable.)
  2625. \global\output = {\onepageout{\pagecontents\PAGE}}%
  2626. }%
  2627. \eject
  2628. \endgroup % started in \begindoublecolumns
  2629. %
  2630. % \pagegoal was set to the doubled \vsize above, since we restarted
  2631. % the current page. We're now back to normal single-column
  2632. % typesetting, so reset \pagegoal to the normal \vsize (after the
  2633. % \endgroup where \vsize got restored).
  2634. \pagegoal = \vsize
  2635. }
  2636. \def\balancecolumns{%
  2637. % Called at the end of the double column material.
  2638. \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
  2639. \dimen@ = \ht0
  2640. \advance\dimen@ by \topskip
  2641. \advance\dimen@ by-\baselineskip
  2642. \divide\dimen@ by 2 % target to split to
  2643. %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
  2644. \splittopskip = \topskip
  2645. % Loop until we get a decent breakpoint.
  2646. {%
  2647. \vbadness = 10000
  2648. \loop
  2649. \global\setbox3 = \copy0
  2650. \global\setbox1 = \vsplit3 to \dimen@
  2651. \ifdim\ht3>\dimen@
  2652. \global\advance\dimen@ by 1pt
  2653. \repeat
  2654. }%
  2655. %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
  2656. \setbox0=\vbox to\dimen@{\unvbox1}%
  2657. \setbox2=\vbox to\dimen@{\unvbox3}%
  2658. %
  2659. \pagesofar
  2660. }
  2661. \catcode`\@ = \other
  2662. \message{sectioning,}
  2663. % Define chapters, sections, etc.
  2664. \newcount\chapno
  2665. \newcount\secno \secno=0
  2666. \newcount\subsecno \subsecno=0
  2667. \newcount\subsubsecno \subsubsecno=0
  2668. % This counter is funny since it counts through charcodes of letters A, B, ...
  2669. \newcount\appendixno \appendixno = `\@
  2670. \def\appendixletter{\char\the\appendixno}
  2671. % Each @chapter defines this as the name of the chapter.
  2672. % page headings and footings can use it. @section does likewise.
  2673. \def\thischapter{}
  2674. \def\thissection{}
  2675. \newcount\absseclevel % used to calculate proper heading level
  2676. \newcount\secbase\secbase=0 % @raise/lowersections modify this count
  2677. % @raisesections: treat @section as chapter, @subsection as section, etc.
  2678. \def\raisesections{\global\advance\secbase by -1}
  2679. \let\up=\raisesections % original BFox name
  2680. % @lowersections: treat @chapter as section, @section as subsection, etc.
  2681. \def\lowersections{\global\advance\secbase by 1}
  2682. \let\down=\lowersections % original BFox name
  2683. % Choose a numbered-heading macro
  2684. % #1 is heading level if unmodified by @raisesections or @lowersections
  2685. % #2 is text for heading
  2686. \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2687. \ifcase\absseclevel
  2688. \chapterzzz{#2}
  2689. \or
  2690. \seczzz{#2}
  2691. \or
  2692. \numberedsubseczzz{#2}
  2693. \or
  2694. \numberedsubsubseczzz{#2}
  2695. \else
  2696. \ifnum \absseclevel<0
  2697. \chapterzzz{#2}
  2698. \else
  2699. \numberedsubsubseczzz{#2}
  2700. \fi
  2701. \fi
  2702. }
  2703. % like \numhead, but chooses appendix heading levels
  2704. \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2705. \ifcase\absseclevel
  2706. \appendixzzz{#2}
  2707. \or
  2708. \appendixsectionzzz{#2}
  2709. \or
  2710. \appendixsubseczzz{#2}
  2711. \or
  2712. \appendixsubsubseczzz{#2}
  2713. \else
  2714. \ifnum \absseclevel<0
  2715. \appendixzzz{#2}
  2716. \else
  2717. \appendixsubsubseczzz{#2}
  2718. \fi
  2719. \fi
  2720. }
  2721. % like \numhead, but chooses numberless heading levels
  2722. \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
  2723. \ifcase\absseclevel
  2724. \unnumberedzzz{#2}
  2725. \or
  2726. \unnumberedseczzz{#2}
  2727. \or
  2728. \unnumberedsubseczzz{#2}
  2729. \or
  2730. \unnumberedsubsubseczzz{#2}
  2731. \else
  2732. \ifnum \absseclevel<0
  2733. \unnumberedzzz{#2}
  2734. \else
  2735. \unnumberedsubsubseczzz{#2}
  2736. \fi
  2737. \fi
  2738. }
  2739. % @chapter, @appendix, @unnumbered.
  2740. \def\thischaptername{No Chapter Title}
  2741. \outer\def\chapter{\parsearg\chapteryyy}
  2742. \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
  2743. \def\chapterzzz #1{%
  2744. \secno=0 \subsecno=0 \subsubsecno=0
  2745. \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
  2746. \chapmacro {#1}{\the\chapno}%
  2747. \gdef\thissection{#1}%
  2748. \gdef\thischaptername{#1}%
  2749. % We don't substitute the actual chapter name into \thischapter
  2750. % because we don't want its macros evaluated now.
  2751. \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
  2752. \toks0 = {#1}%
  2753. \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
  2754. {\the\chapno}}}%
  2755. \temp
  2756. \donoderef
  2757. \global\let\section = \numberedsec
  2758. \global\let\subsection = \numberedsubsec
  2759. \global\let\subsubsection = \numberedsubsubsec
  2760. }
  2761. \outer\def\appendix{\parsearg\appendixyyy}
  2762. \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
  2763. \def\appendixzzz #1{%
  2764. \secno=0 \subsecno=0 \subsubsecno=0
  2765. \global\advance \appendixno by 1
  2766. \message{\putwordAppendix\space \appendixletter}%
  2767. \chapmacro {#1}{\putwordAppendix{} \appendixletter}%
  2768. \gdef\thissection{#1}%
  2769. \gdef\thischaptername{#1}%
  2770. \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
  2771. \toks0 = {#1}%
  2772. \edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
  2773. {\putwordAppendix{} \appendixletter}}}%
  2774. \temp
  2775. \appendixnoderef
  2776. \global\let\section = \appendixsec
  2777. \global\let\subsection = \appendixsubsec
  2778. \global\let\subsubsection = \appendixsubsubsec
  2779. }
  2780. % @centerchap is like @unnumbered, but the heading is centered.
  2781. \outer\def\centerchap{\parsearg\centerchapyyy}
  2782. \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
  2783. % @top is like @unnumbered.
  2784. \outer\def\top{\parsearg\unnumberedyyy}
  2785. \outer\def\unnumbered{\parsearg\unnumberedyyy}
  2786. \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  2787. \def\unnumberedzzz #1{%
  2788. \secno=0 \subsecno=0 \subsubsecno=0
  2789. %
  2790. % This used to be simply \message{#1}, but TeX fully expands the
  2791. % argument to \message. Therefore, if #1 contained @-commands, TeX
  2792. % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
  2793. % expanded @cite (which turns out to cause errors because \cite is meant
  2794. % to be executed, not expanded).
  2795. %
  2796. % Anyway, we don't want the fully-expanded definition of @cite to appear
  2797. % as a result of the \message, we just want `@cite' itself. We use
  2798. % \the<toks register> to achieve this: TeX expands \the<toks> only once,
  2799. % simply yielding the contents of <toks register>. (We also do this for
  2800. % the toc entries.)
  2801. \toks0 = {#1}\message{(\the\toks0)}%
  2802. %
  2803. \unnumbchapmacro {#1}%
  2804. \gdef\thischapter{#1}\gdef\thissection{#1}%
  2805. \toks0 = {#1}%
  2806. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
  2807. \temp
  2808. \unnumbnoderef
  2809. \global\let\section = \unnumberedsec
  2810. \global\let\subsection = \unnumberedsubsec
  2811. \global\let\subsubsection = \unnumberedsubsubsec
  2812. }
  2813. % Sections.
  2814. \outer\def\numberedsec{\parsearg\secyyy}
  2815. \def\secyyy #1{\numhead1{#1}} % normally calls seczzz
  2816. \def\seczzz #1{%
  2817. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2818. \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
  2819. \toks0 = {#1}%
  2820. \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
  2821. {\the\chapno}{\the\secno}}}%
  2822. \temp
  2823. \donoderef
  2824. \nobreak
  2825. }
  2826. \outer\def\appendixsection{\parsearg\appendixsecyyy}
  2827. \outer\def\appendixsec{\parsearg\appendixsecyyy}
  2828. \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
  2829. \def\appendixsectionzzz #1{%
  2830. \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
  2831. \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
  2832. \toks0 = {#1}%
  2833. \edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
  2834. {\appendixletter}{\the\secno}}}%
  2835. \temp
  2836. \appendixnoderef
  2837. \nobreak
  2838. }
  2839. \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
  2840. \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
  2841. \def\unnumberedseczzz #1{%
  2842. \plainsecheading {#1}\gdef\thissection{#1}%
  2843. \toks0 = {#1}%
  2844. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
  2845. \temp
  2846. \unnumbnoderef
  2847. \nobreak
  2848. }
  2849. % Subsections.
  2850. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
  2851. \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
  2852. \def\numberedsubseczzz #1{%
  2853. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2854. \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
  2855. \toks0 = {#1}%
  2856. \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
  2857. {\the\chapno}{\the\secno}{\the\subsecno}}}%
  2858. \temp
  2859. \donoderef
  2860. \nobreak
  2861. }
  2862. \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
  2863. \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
  2864. \def\appendixsubseczzz #1{%
  2865. \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
  2866. \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
  2867. \toks0 = {#1}%
  2868. \edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
  2869. {\appendixletter}{\the\secno}{\the\subsecno}}}%
  2870. \temp
  2871. \appendixnoderef
  2872. \nobreak
  2873. }
  2874. \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
  2875. \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  2876. \def\unnumberedsubseczzz #1{%
  2877. \plainsubsecheading {#1}\gdef\thissection{#1}%
  2878. \toks0 = {#1}%
  2879. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
  2880. {\the\toks0}}}%
  2881. \temp
  2882. \unnumbnoderef
  2883. \nobreak
  2884. }
  2885. % Subsubsections.
  2886. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
  2887. \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
  2888. \def\numberedsubsubseczzz #1{%
  2889. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2890. \subsubsecheading {#1}
  2891. {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2892. \toks0 = {#1}%
  2893. \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
  2894. {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
  2895. \temp
  2896. \donoderef
  2897. \nobreak
  2898. }
  2899. \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
  2900. \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
  2901. \def\appendixsubsubseczzz #1{%
  2902. \gdef\thissection{#1}\global\advance \subsubsecno by 1 %
  2903. \subsubsecheading {#1}
  2904. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
  2905. \toks0 = {#1}%
  2906. \edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
  2907. {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
  2908. \temp
  2909. \appendixnoderef
  2910. \nobreak
  2911. }
  2912. \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
  2913. \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  2914. \def\unnumberedsubsubseczzz #1{%
  2915. \plainsubsubsecheading {#1}\gdef\thissection{#1}%
  2916. \toks0 = {#1}%
  2917. \edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
  2918. {\the\toks0}}}%
  2919. \temp
  2920. \unnumbnoderef
  2921. \nobreak
  2922. }
  2923. % These are variants which are not "outer", so they can appear in @ifinfo.
  2924. % Actually, they should now be obsolete; ordinary section commands should work.
  2925. \def\infotop{\parsearg\unnumberedzzz}
  2926. \def\infounnumbered{\parsearg\unnumberedzzz}
  2927. \def\infounnumberedsec{\parsearg\unnumberedseczzz}
  2928. \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
  2929. \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
  2930. \def\infoappendix{\parsearg\appendixzzz}
  2931. \def\infoappendixsec{\parsearg\appendixseczzz}
  2932. \def\infoappendixsubsec{\parsearg\appendixsubseczzz}
  2933. \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
  2934. \def\infochapter{\parsearg\chapterzzz}
  2935. \def\infosection{\parsearg\sectionzzz}
  2936. \def\infosubsection{\parsearg\subsectionzzz}
  2937. \def\infosubsubsection{\parsearg\subsubsectionzzz}
  2938. % These macros control what the section commands do, according
  2939. % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
  2940. % Define them by default for a numbered chapter.
  2941. \global\let\section = \numberedsec
  2942. \global\let\subsection = \numberedsubsec
  2943. \global\let\subsubsection = \numberedsubsubsec
  2944. % Define @majorheading, @heading and @subheading
  2945. % NOTE on use of \vbox for chapter headings, section headings, and such:
  2946. % 1) We use \vbox rather than the earlier \line to permit
  2947. % overlong headings to fold.
  2948. % 2) \hyphenpenalty is set to 10000 because hyphenation in a
  2949. % heading is obnoxious; this forbids it.
  2950. % 3) Likewise, headings look best if no \parindent is used, and
  2951. % if justification is not attempted. Hence \raggedright.
  2952. \def\majorheading{\parsearg\majorheadingzzz}
  2953. \def\majorheadingzzz #1{%
  2954. {\advance\chapheadingskip by 10pt \chapbreak }%
  2955. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2956. \parindent=0pt\raggedright
  2957. \rm #1\hfill}}\bigskip \par\penalty 200}
  2958. \def\chapheading{\parsearg\chapheadingzzz}
  2959. \def\chapheadingzzz #1{\chapbreak %
  2960. {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  2961. \parindent=0pt\raggedright
  2962. \rm #1\hfill}}\bigskip \par\penalty 200}
  2963. % @heading, @subheading, @subsubheading.
  2964. \def\heading{\parsearg\plainsecheading}
  2965. \def\subheading{\parsearg\plainsubsecheading}
  2966. \def\subsubheading{\parsearg\plainsubsubsecheading}
  2967. % These macros generate a chapter, section, etc. heading only
  2968. % (including whitespace, linebreaking, etc. around it),
  2969. % given all the information in convenient, parsed form.
  2970. %%% Args are the skip and penalty (usually negative)
  2971. \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  2972. \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
  2973. %%% Define plain chapter starts, and page on/off switching for it
  2974. % Parameter controlling skip before chapter headings (if needed)
  2975. \newskip\chapheadingskip
  2976. \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  2977. \def\chappager{\par\vfill\supereject}
  2978. \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
  2979. \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  2980. \def\CHAPPAGoff{%
  2981. \global\let\contentsalignmacro = \chappager
  2982. \global\let\pchapsepmacro=\chapbreak
  2983. \global\let\pagealignmacro=\chappager}
  2984. \def\CHAPPAGon{%
  2985. \global\let\contentsalignmacro = \chappager
  2986. \global\let\pchapsepmacro=\chappager
  2987. \global\let\pagealignmacro=\chappager
  2988. \global\def\HEADINGSon{\HEADINGSsingle}}
  2989. \def\CHAPPAGodd{
  2990. \global\let\contentsalignmacro = \chapoddpage
  2991. \global\let\pchapsepmacro=\chapoddpage
  2992. \global\let\pagealignmacro=\chapoddpage
  2993. \global\def\HEADINGSon{\HEADINGSdouble}}
  2994. \CHAPPAGon
  2995. \def\CHAPFplain{
  2996. \global\let\chapmacro=\chfplain
  2997. \global\let\unnumbchapmacro=\unnchfplain
  2998. \global\let\centerchapmacro=\centerchfplain}
  2999. % Plain chapter opening.
  3000. % #1 is the text, #2 the chapter number or empty if unnumbered.
  3001. \def\chfplain#1#2{%
  3002. \pchapsepmacro
  3003. {%
  3004. \chapfonts \rm
  3005. \def\chapnum{#2}%
  3006. \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
  3007. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  3008. \hangindent = \wd0 \centerparametersmaybe
  3009. \unhbox0 #1\par}%
  3010. }%
  3011. \nobreak\bigskip % no page break after a chapter title
  3012. \nobreak
  3013. }
  3014. % Plain opening for unnumbered.
  3015. \def\unnchfplain#1{\chfplain{#1}{}}
  3016. % @centerchap -- centered and unnumbered.
  3017. \let\centerparametersmaybe = \relax
  3018. \def\centerchfplain#1{{%
  3019. \def\centerparametersmaybe{%
  3020. \advance\rightskip by 3\rightskip
  3021. \leftskip = \rightskip
  3022. \parfillskip = 0pt
  3023. }%
  3024. \chfplain{#1}{}%
  3025. }}
  3026. \CHAPFplain % The default
  3027. \def\unnchfopen #1{%
  3028. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3029. \parindent=0pt\raggedright
  3030. \rm #1\hfill}}\bigskip \par\nobreak
  3031. }
  3032. \def\chfopen #1#2{\chapoddpage {\chapfonts
  3033. \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
  3034. \par\penalty 5000 %
  3035. }
  3036. \def\centerchfopen #1{%
  3037. \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
  3038. \parindent=0pt
  3039. \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
  3040. }
  3041. \def\CHAPFopen{
  3042. \global\let\chapmacro=\chfopen
  3043. \global\let\unnumbchapmacro=\unnchfopen
  3044. \global\let\centerchapmacro=\centerchfopen}
  3045. % Section titles.
  3046. \newskip\secheadingskip
  3047. \def\secheadingbreak{\dobreak \secheadingskip {-1000}}
  3048. \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
  3049. \def\plainsecheading#1{\sectionheading{sec}{}{#1}}
  3050. % Subsection titles.
  3051. \newskip \subsecheadingskip
  3052. \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
  3053. \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
  3054. \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
  3055. % Subsubsection titles.
  3056. \let\subsubsecheadingskip = \subsecheadingskip
  3057. \let\subsubsecheadingbreak = \subsecheadingbreak
  3058. \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
  3059. \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
  3060. % Print any size section title.
  3061. %
  3062. % #1 is the section type (sec/subsec/subsubsec), #2 is the section
  3063. % number (maybe empty), #3 the text.
  3064. \def\sectionheading#1#2#3{%
  3065. {%
  3066. \expandafter\advance\csname #1headingskip\endcsname by \parskip
  3067. \csname #1headingbreak\endcsname
  3068. }%
  3069. {%
  3070. % Switch to the right set of fonts.
  3071. \csname #1fonts\endcsname \rm
  3072. %
  3073. % Only insert the separating space if we have a section number.
  3074. \def\secnum{#2}%
  3075. \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
  3076. %
  3077. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
  3078. \hangindent = \wd0 % zero if no section number
  3079. \unhbox0 #3}%
  3080. }%
  3081. \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
  3082. }
  3083. \message{toc,}
  3084. \newwrite\tocfile
  3085. % Write an entry to the toc file, opening it if necessary.
  3086. % Called from @chapter, etc. We supply {\folio} at the end of the
  3087. % argument, which will end up as the last argument to the \...entry macro.
  3088. %
  3089. % We open the .toc file here instead of at @setfilename or any other
  3090. % given time so that @contents can be put in the document anywhere.
  3091. %
  3092. \newif\iftocfileopened
  3093. \def\writetocentry#1{%
  3094. \iftocfileopened\else
  3095. \immediate\openout\tocfile = \jobname.toc
  3096. \global\tocfileopenedtrue
  3097. \fi
  3098. \iflinks \write\tocfile{#1{\folio}}\fi
  3099. }
  3100. \newskip\contentsrightmargin \contentsrightmargin=1in
  3101. \newcount\savepageno
  3102. \newcount\lastnegativepageno \lastnegativepageno = -1
  3103. % Finish up the main text and prepare to read what we've written
  3104. % to \tocfile.
  3105. %
  3106. \def\startcontents#1{%
  3107. % If @setchapternewpage on, and @headings double, the contents should
  3108. % start on an odd page, unlike chapters. Thus, we maintain
  3109. % \contentsalignmacro in parallel with \pagealignmacro.
  3110. % From: Torbjorn Granlund <tege@matematik.su.se>
  3111. \contentsalignmacro
  3112. \immediate\closeout\tocfile
  3113. %
  3114. % Don't need to put `Contents' or `Short Contents' in the headline.
  3115. % It is abundantly clear what they are.
  3116. \unnumbchapmacro{#1}\def\thischapter{}%
  3117. \savepageno = \pageno
  3118. \begingroup % Set up to handle contents files properly.
  3119. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
  3120. % We can't do this, because then an actual ^ in a section
  3121. % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
  3122. %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
  3123. \raggedbottom % Worry more about breakpoints than the bottom.
  3124. \advance\hsize by -\contentsrightmargin % Don't use the full line length.
  3125. %
  3126. % Roman numerals for page numbers.
  3127. \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
  3128. }
  3129. % Normal (long) toc.
  3130. \def\contents{%
  3131. \startcontents{\putwordTableofContents}%
  3132. \openin 1 \jobname.toc
  3133. \ifeof 1 \else
  3134. \closein 1
  3135. \input \jobname.toc
  3136. \fi
  3137. \vfill \eject
  3138. \endgroup
  3139. \lastnegativepageno = \pageno
  3140. \pageno = \savepageno
  3141. }
  3142. % And just the chapters.
  3143. \def\summarycontents{%
  3144. \startcontents{\putwordShortContents}%
  3145. %
  3146. \let\chapentry = \shortchapentry
  3147. \let\unnumbchapentry = \shortunnumberedentry
  3148. % We want a true roman here for the page numbers.
  3149. \secfonts
  3150. \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
  3151. \rm
  3152. \hyphenpenalty = 10000
  3153. \advance\baselineskip by 1pt % Open it up a little.
  3154. \def\secentry ##1##2##3##4{}
  3155. \def\unnumbsecentry ##1##2{}
  3156. \def\subsecentry ##1##2##3##4##5{}
  3157. \def\unnumbsubsecentry ##1##2{}
  3158. \def\subsubsecentry ##1##2##3##4##5##6{}
  3159. \def\unnumbsubsubsecentry ##1##2{}
  3160. \openin 1 \jobname.toc
  3161. \ifeof 1 \else
  3162. \closein 1
  3163. \input \jobname.toc
  3164. \fi
  3165. \vfill \eject
  3166. \endgroup
  3167. \lastnegativepageno = \pageno
  3168. \pageno = \savepageno
  3169. }
  3170. \let\shortcontents = \summarycontents
  3171. % These macros generate individual entries in the table of contents.
  3172. % The first argument is the chapter or section name.
  3173. % The last argument is the page number.
  3174. % The arguments in between are the chapter number, section number, ...
  3175. % Chapter-level things, for both the long and short contents.
  3176. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
  3177. % See comments in \dochapentry re vbox and related settings
  3178. \def\shortchapentry#1#2#3{%
  3179. \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
  3180. }
  3181. % Typeset the label for a chapter or appendix for the short contents.
  3182. % The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
  3183. % We could simplify the code here by writing out an \appendixentry
  3184. % command in the toc file for appendices, instead of using \chapentry
  3185. % for both, but it doesn't seem worth it.
  3186. \setbox0 = \hbox{\shortcontrm \putwordAppendix }
  3187. \newdimen\shortappendixwidth \shortappendixwidth = \wd0
  3188. \def\shortchaplabel#1{%
  3189. % We typeset #1 in a box of constant width, regardless of the text of
  3190. % #1, so the chapter titles will come out aligned.
  3191. \setbox0 = \hbox{#1}%
  3192. \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
  3193. %
  3194. % This space should be plenty, since a single number is .5em, and the
  3195. % widest letter (M) is 1em, at least in the Computer Modern fonts.
  3196. % (This space doesn't include the extra space that gets added after
  3197. % the label; that gets put in by \shortchapentry above.)
  3198. \advance\dimen0 by 1.1em
  3199. \hbox to \dimen0{#1\hfil}%
  3200. }
  3201. \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
  3202. \def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
  3203. % Sections.
  3204. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
  3205. \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
  3206. % Subsections.
  3207. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
  3208. \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
  3209. % And subsubsections.
  3210. \def\subsubsecentry#1#2#3#4#5#6{%
  3211. \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
  3212. \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
  3213. % This parameter controls the indentation of the various levels.
  3214. \newdimen\tocindent \tocindent = 3pc
  3215. % Now for the actual typesetting. In all these, #1 is the text and #2 is the
  3216. % page number.
  3217. %
  3218. % If the toc has to be broken over pages, we want it to be at chapters
  3219. % if at all possible; hence the \penalty.
  3220. \def\dochapentry#1#2{%
  3221. \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
  3222. \begingroup
  3223. \chapentryfonts
  3224. \tocentry{#1}{\dopageno{#2}}%
  3225. \endgroup
  3226. \nobreak\vskip .25\baselineskip plus.1\baselineskip
  3227. }
  3228. \def\dosecentry#1#2{\begingroup
  3229. \secentryfonts \leftskip=\tocindent
  3230. \tocentry{#1}{\dopageno{#2}}%
  3231. \endgroup}
  3232. \def\dosubsecentry#1#2{\begingroup
  3233. \subsecentryfonts \leftskip=2\tocindent
  3234. \tocentry{#1}{\dopageno{#2}}%
  3235. \endgroup}
  3236. \def\dosubsubsecentry#1#2{\begingroup
  3237. \subsubsecentryfonts \leftskip=3\tocindent
  3238. \tocentry{#1}{\dopageno{#2}}%
  3239. \endgroup}
  3240. % Final typesetting of a toc entry; we use the same \entry macro as for
  3241. % the index entries, but we want to suppress hyphenation here. (We
  3242. % can't do that in the \entry macro, since index entries might consist
  3243. % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
  3244. \def\tocentry#1#2{\begingroup
  3245. \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
  3246. % Do not use \turnoffactive in these arguments. Since the toc is
  3247. % typeset in cmr, so characters such as _ would come out wrong; we
  3248. % have to do the usual translation tricks.
  3249. \entry{#1}{#2}%
  3250. \endgroup}
  3251. % Space between chapter (or whatever) number and the title.
  3252. \def\labelspace{\hskip1em \relax}
  3253. \def\dopageno#1{{\rm #1}}
  3254. \def\doshortpageno#1{{\rm #1}}
  3255. \def\chapentryfonts{\secfonts \rm}
  3256. \def\secentryfonts{\textfonts}
  3257. \let\subsecentryfonts = \textfonts
  3258. \let\subsubsecentryfonts = \textfonts
  3259. \message{environments,}
  3260. % Since these characters are used in examples, it should be an even number of
  3261. % \tt widths. Each \tt character is 1en, so two makes it 1em.
  3262. % Furthermore, these definitions must come after we define our fonts.
  3263. \newbox\dblarrowbox \newbox\longdblarrowbox
  3264. \newbox\pushcharbox \newbox\bullbox
  3265. \newbox\equivbox \newbox\errorbox
  3266. %{\tentt
  3267. %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
  3268. %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
  3269. %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
  3270. %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
  3271. % Adapted from the manmac format (p.420 of TeXbook)
  3272. %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
  3273. % depth .1ex\hfil}
  3274. %}
  3275. % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
  3276. \def\point{$\star$}
  3277. \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
  3278. \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
  3279. \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
  3280. \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
  3281. % Adapted from the TeXbook's \boxit.
  3282. {\tentt \global\dimen0 = 3em}% Width of the box.
  3283. \dimen2 = .55pt % Thickness of rules
  3284. % The text. (`r' is open on the right, `e' somewhat less so on the left.)
  3285. \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
  3286. \global\setbox\errorbox=\hbox to \dimen0{\hfil
  3287. \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
  3288. \advance\hsize by -2\dimen2 % Rules.
  3289. \vbox{
  3290. \hrule height\dimen2
  3291. \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
  3292. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
  3293. \kern3pt\vrule width\dimen2}% Space to right.
  3294. \hrule height\dimen2}
  3295. \hfil}
  3296. % The @error{} command.
  3297. \def\error{\leavevmode\lower.7ex\copy\errorbox}
  3298. % @tex ... @end tex escapes into raw Tex temporarily.
  3299. % One exception: @ is still an escape character, so that @end tex works.
  3300. % But \@ or @@ will get a plain tex @ character.
  3301. \def\tex{\begingroup
  3302. \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
  3303. \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
  3304. \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
  3305. \catcode `\%=14
  3306. \catcode 43=12 % plus
  3307. \catcode`\"=12
  3308. \catcode`\==12
  3309. \catcode`\|=12
  3310. \catcode`\<=12
  3311. \catcode`\>=12
  3312. \escapechar=`\\
  3313. %
  3314. \let\b=\ptexb
  3315. \let\bullet=\ptexbullet
  3316. \let\c=\ptexc
  3317. \let\,=\ptexcomma
  3318. \let\.=\ptexdot
  3319. \let\dots=\ptexdots
  3320. \let\equiv=\ptexequiv
  3321. \let\!=\ptexexclam
  3322. \let\i=\ptexi
  3323. \let\{=\ptexlbrace
  3324. \let\+=\tabalign
  3325. \let\}=\ptexrbrace
  3326. \let\*=\ptexstar
  3327. \let\t=\ptext
  3328. %
  3329. \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
  3330. \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
  3331. \def\@{@}%
  3332. \let\Etex=\endgroup}
  3333. % Define @lisp ... @endlisp.
  3334. % @lisp does a \begingroup so it can rebind things,
  3335. % including the definition of @endlisp (which normally is erroneous).
  3336. % Amount to narrow the margins by for @lisp.
  3337. \newskip\lispnarrowing \lispnarrowing=0.4in
  3338. % This is the definition that ^^M gets inside @lisp, @example, and other
  3339. % such environments. \null is better than a space, since it doesn't
  3340. % have any width.
  3341. \def\lisppar{\null\endgraf}
  3342. % Make each space character in the input produce a normal interword
  3343. % space in the output. Don't allow a line break at this space, as this
  3344. % is used only in environments like @example, where each line of input
  3345. % should produce a line of output anyway.
  3346. %
  3347. {\obeyspaces %
  3348. \gdef\sepspaces{\obeyspaces\let =\tie}}
  3349. % Define \obeyedspace to be our active space, whatever it is. This is
  3350. % for use in \parsearg.
  3351. {\sepspaces%
  3352. \global\let\obeyedspace= }
  3353. % This space is always present above and below environments.
  3354. \newskip\envskipamount \envskipamount = 0pt
  3355. % Make spacing and below environment symmetrical. We use \parskip here
  3356. % to help in doing that, since in @example-like environments \parskip
  3357. % is reset to zero; thus the \afterenvbreak inserts no space -- but the
  3358. % start of the next paragraph will insert \parskip
  3359. %
  3360. \def\aboveenvbreak{{\advance\envskipamount by \parskip
  3361. \endgraf \ifdim\lastskip<\envskipamount
  3362. \removelastskip \penalty-50 \vskip\envskipamount \fi}}
  3363. \let\afterenvbreak = \aboveenvbreak
  3364. % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins.
  3365. \let\nonarrowing=\relax
  3366. % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
  3367. % environment contents.
  3368. \font\circle=lcircle10
  3369. \newdimen\circthick
  3370. \newdimen\cartouter\newdimen\cartinner
  3371. \newskip\normbskip\newskip\normpskip\newskip\normlskip
  3372. \circthick=\fontdimen8\circle
  3373. %
  3374. \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  3375. \def\ctr{{\hskip 6pt\circle\char'010}}
  3376. \def\cbl{{\circle\char'012\hskip -6pt}}
  3377. \def\cbr{{\hskip 6pt\circle\char'011}}
  3378. \def\carttop{\hbox to \cartouter{\hskip\lskip
  3379. \ctl\leaders\hrule height\circthick\hfil\ctr
  3380. \hskip\rskip}}
  3381. \def\cartbot{\hbox to \cartouter{\hskip\lskip
  3382. \cbl\leaders\hrule height\circthick\hfil\cbr
  3383. \hskip\rskip}}
  3384. %
  3385. \newskip\lskip\newskip\rskip
  3386. \long\def\cartouche{%
  3387. \begingroup
  3388. \lskip=\leftskip \rskip=\rightskip
  3389. \leftskip=0pt\rightskip=0pt %we want these *outside*.
  3390. \cartinner=\hsize \advance\cartinner by-\lskip
  3391. \advance\cartinner by-\rskip
  3392. \cartouter=\hsize
  3393. \advance\cartouter by 18.4pt % allow for 3pt kerns on either
  3394. % side, and for 6pt waste from
  3395. % each corner char, and rule thickness
  3396. \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
  3397. % Flag to tell @lisp, etc., not to narrow margin.
  3398. \let\nonarrowing=\comment
  3399. \vbox\bgroup
  3400. \baselineskip=0pt\parskip=0pt\lineskip=0pt
  3401. \carttop
  3402. \hbox\bgroup
  3403. \hskip\lskip
  3404. \vrule\kern3pt
  3405. \vbox\bgroup
  3406. \hsize=\cartinner
  3407. \kern3pt
  3408. \begingroup
  3409. \baselineskip=\normbskip
  3410. \lineskip=\normlskip
  3411. \parskip=\normpskip
  3412. \vskip -\parskip
  3413. \def\Ecartouche{%
  3414. \endgroup
  3415. \kern3pt
  3416. \egroup
  3417. \kern3pt\vrule
  3418. \hskip\rskip
  3419. \egroup
  3420. \cartbot
  3421. \egroup
  3422. \endgroup
  3423. }}
  3424. % This macro is called at the beginning of all the @example variants,
  3425. % inside a group.
  3426. \def\nonfillstart{%
  3427. \aboveenvbreak
  3428. \inENV % This group ends at the end of the body
  3429. \hfuzz = 12pt % Don't be fussy
  3430. \sepspaces % Make spaces be word-separators rather than space tokens.
  3431. \singlespace
  3432. \let\par = \lisppar % don't ignore blank lines
  3433. \obeylines % each line of input is a line of output
  3434. \parskip = 0pt
  3435. \parindent = 0pt
  3436. \emergencystretch = 0pt % don't try to avoid overfull boxes
  3437. % @cartouche defines \nonarrowing to inhibit narrowing
  3438. % at next level down.
  3439. \ifx\nonarrowing\relax
  3440. \advance \leftskip by \lispnarrowing
  3441. \exdentamount=\lispnarrowing
  3442. \let\exdent=\nofillexdent
  3443. \let\nonarrowing=\relax
  3444. \fi
  3445. }
  3446. % Define the \E... control sequence only if we are inside the particular
  3447. % environment, so the error checking in \end will work.
  3448. %
  3449. % To end an @example-like environment, we first end the paragraph (via
  3450. % \afterenvbreak's vertical glue), and then the group. That way we keep
  3451. % the zero \parskip that the environments set -- \parskip glue will be
  3452. % inserted at the beginning of the next paragraph in the document, after
  3453. % the environment.
  3454. %
  3455. \def\nonfillfinish{\afterenvbreak\endgroup}
  3456. % @lisp: indented, narrowed, typewriter font.
  3457. \def\lisp{\begingroup
  3458. \nonfillstart
  3459. \let\Elisp = \nonfillfinish
  3460. \tt
  3461. \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
  3462. \gobble % eat return
  3463. }
  3464. % @example: Same as @lisp.
  3465. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
  3466. % @small... is usually equivalent to the non-small (@smallbook
  3467. % redefines). We must call \example (or whatever) last in the
  3468. % definition, since it reads the return following the @example (or
  3469. % whatever) command.
  3470. %
  3471. % This actually allows (for example) @end display inside an
  3472. % @smalldisplay. Too bad, but makeinfo will catch the error anyway.
  3473. %
  3474. \def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
  3475. \def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
  3476. \def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
  3477. \def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
  3478. % Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
  3479. % Originally contributed by Pavel@xerox.
  3480. \def\smalllispx{\begingroup
  3481. \def\Esmalllisp{\nonfillfinish\endgroup}%
  3482. \def\Esmallexample{\nonfillfinish\endgroup}%
  3483. \indexfonts
  3484. \lisp
  3485. }
  3486. % @display: same as @lisp except keep current font.
  3487. %
  3488. \def\display{\begingroup
  3489. \nonfillstart
  3490. \let\Edisplay = \nonfillfinish
  3491. \gobble
  3492. }
  3493. % @smalldisplay (when @smallbook): @display plus smaller fonts.
  3494. %
  3495. \def\smalldisplayx{\begingroup
  3496. \def\Esmalldisplay{\nonfillfinish\endgroup}%
  3497. \indexfonts \rm
  3498. \display
  3499. }
  3500. % @format: same as @display except don't narrow margins.
  3501. %
  3502. \def\format{\begingroup
  3503. \let\nonarrowing = t
  3504. \nonfillstart
  3505. \let\Eformat = \nonfillfinish
  3506. \gobble
  3507. }
  3508. % @smallformat (when @smallbook): @format plus smaller fonts.
  3509. %
  3510. \def\smallformatx{\begingroup
  3511. \def\Esmallformat{\nonfillfinish\endgroup}%
  3512. \indexfonts \rm
  3513. \format
  3514. }
  3515. % @flushleft (same as @format).
  3516. %
  3517. \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
  3518. % @flushright.
  3519. %
  3520. \def\flushright{\begingroup
  3521. \let\nonarrowing = t
  3522. \nonfillstart
  3523. \let\Eflushright = \nonfillfinish
  3524. \advance\leftskip by 0pt plus 1fill
  3525. \gobble
  3526. }
  3527. % @quotation does normal linebreaking (hence we can't use \nonfillstart)
  3528. % and narrows the margins.
  3529. %
  3530. \def\quotation{%
  3531. \begingroup\inENV %This group ends at the end of the @quotation body
  3532. {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
  3533. \singlespace
  3534. \parindent=0pt
  3535. % We have retained a nonzero parskip for the environment, since we're
  3536. % doing normal filling. So to avoid extra space below the environment...
  3537. \def\Equotation{\parskip = 0pt \nonfillfinish}%
  3538. %
  3539. % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
  3540. \ifx\nonarrowing\relax
  3541. \advance\leftskip by \lispnarrowing
  3542. \advance\rightskip by \lispnarrowing
  3543. \exdentamount = \lispnarrowing
  3544. \let\nonarrowing = \relax
  3545. \fi
  3546. }
  3547. \message{defuns,}
  3548. % Define formatter for defuns
  3549. % First, allow user to change definition object font (\df) internally
  3550. \def\setdeffont #1 {\csname DEF#1\endcsname}
  3551. \newskip\defbodyindent \defbodyindent=.4in
  3552. \newskip\defargsindent \defargsindent=50pt
  3553. \newskip\deftypemargin \deftypemargin=12pt
  3554. \newskip\deflastargmargin \deflastargmargin=18pt
  3555. \newcount\parencount
  3556. % define \functionparens, which makes ( and ) and & do special things.
  3557. % \functionparens affects the group it is contained in.
  3558. \def\activeparens{%
  3559. \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
  3560. \catcode`\[=\active \catcode`\]=\active}
  3561. % Make control sequences which act like normal parenthesis chars.
  3562. \let\lparen = ( \let\rparen = )
  3563. {\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
  3564. % Be sure that we always have a definition for `(', etc. For example,
  3565. % if the fn name has parens in it, \boldbrax will not be in effect yet,
  3566. % so TeX would otherwise complain about undefined control sequence.
  3567. \global\let(=\lparen \global\let)=\rparen
  3568. \global\let[=\lbrack \global\let]=\rbrack
  3569. \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
  3570. \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
  3571. % This is used to turn on special parens
  3572. % but make & act ordinary (given that it's active).
  3573. \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
  3574. % Definitions of (, ) and & used in args for functions.
  3575. % This is the definition of ( outside of all parentheses.
  3576. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
  3577. \global\advance\parencount by 1
  3578. }
  3579. %
  3580. % This is the definition of ( when already inside a level of parens.
  3581. \gdef\opnested{\char`\(\global\advance\parencount by 1 }
  3582. %
  3583. \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
  3584. % also in that case restore the outer-level definition of (.
  3585. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
  3586. \global\advance \parencount by -1 }
  3587. % If we encounter &foo, then turn on ()-hacking afterwards
  3588. \gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
  3589. %
  3590. \gdef\normalparens{\boldbrax\let&=\ampnr}
  3591. } % End of definition inside \activeparens
  3592. %% These parens (in \boldbrax) actually are a little bolder than the
  3593. %% contained text. This is especially needed for [ and ]
  3594. \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
  3595. \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
  3596. \def\ampnr{\&}
  3597. \def\lbrb{{\bf\char`\[}}
  3598. \def\rbrb{{\bf\char`\]}}
  3599. % First, defname, which formats the header line itself.
  3600. % #1 should be the function name.
  3601. % #2 should be the type of definition, such as "Function".
  3602. \def\defname #1#2{%
  3603. % Get the values of \leftskip and \rightskip as they were
  3604. % outside the @def...
  3605. \dimen2=\leftskip
  3606. \advance\dimen2 by -\defbodyindent
  3607. \noindent
  3608. \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
  3609. \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
  3610. \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
  3611. \parshape 2 0in \dimen0 \defargsindent \dimen1
  3612. % Now output arg 2 ("Function" or some such)
  3613. % ending at \deftypemargin from the right margin,
  3614. % but stuck inside a box of width 0 so it does not interfere with linebreaking
  3615. {% Adjust \hsize to exclude the ambient margins,
  3616. % so that \rightline will obey them.
  3617. \advance \hsize by -\dimen2
  3618. \rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
  3619. % Make all lines underfull and no complaints:
  3620. \tolerance=10000 \hbadness=10000
  3621. \advance\leftskip by -\defbodyindent
  3622. \exdentamount=\defbodyindent
  3623. {\df #1}\enskip % Generate function name
  3624. }
  3625. % Actually process the body of a definition
  3626. % #1 should be the terminating control sequence, such as \Edefun.
  3627. % #2 should be the "another name" control sequence, such as \defunx.
  3628. % #3 should be the control sequence that actually processes the header,
  3629. % such as \defunheader.
  3630. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  3631. \medbreak %
  3632. % Define the end token that this defining construct specifies
  3633. % so that it will exit this group.
  3634. \def#1{\endgraf\endgroup\medbreak}%
  3635. \def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
  3636. \parindent=0in
  3637. \advance\leftskip by \defbodyindent
  3638. \exdentamount=\defbodyindent
  3639. \begingroup %
  3640. \catcode 61=\active % 61 is `='
  3641. \obeylines\activeparens\spacesplit#3}
  3642. % #1 is the \E... control sequence to end the definition (which we define).
  3643. % #2 is the \...x control sequence for consecutive fns (which we define).
  3644. % #3 is the control sequence to call to resume processing.
  3645. % #4, delimited by the space, is the class name.
  3646. %
  3647. \def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
  3648. \medbreak %
  3649. % Define the end token that this defining construct specifies
  3650. % so that it will exit this group.
  3651. \def#1{\endgraf\endgroup\medbreak}%
  3652. \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
  3653. \parindent=0in
  3654. \advance\leftskip by \defbodyindent
  3655. \exdentamount=\defbodyindent
  3656. \begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
  3657. % @deftypemethod has an extra argument that nothing else does. Sigh.
  3658. % #1 is the \E... control sequence to end the definition (which we define).
  3659. % #2 is the \...x control sequence for consecutive fns (which we define).
  3660. % #3 is the control sequence to call to resume processing.
  3661. % #4, delimited by the space, is the class name.
  3662. % #5 is the method's return type.
  3663. %
  3664. \def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV %
  3665. \medbreak %
  3666. % Define the end token that this defining construct specifies
  3667. % so that it will exit this group.
  3668. \def#1{\endgraf\endgroup\medbreak}%
  3669. \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
  3670. \parindent=0in
  3671. \advance\leftskip by \defbodyindent
  3672. \exdentamount=\defbodyindent
  3673. \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
  3674. \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
  3675. \medbreak %
  3676. % Define the end token that this defining construct specifies
  3677. % so that it will exit this group.
  3678. \def#1{\endgraf\endgroup\medbreak}%
  3679. \def#2##1 ##2 {\def#4{##1}%
  3680. \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
  3681. \parindent=0in
  3682. \advance\leftskip by \defbodyindent
  3683. \exdentamount=\defbodyindent
  3684. \begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
  3685. % These parsing functions are similar to the preceding ones
  3686. % except that they do not make parens into active characters.
  3687. % These are used for "variables" since they have no arguments.
  3688. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
  3689. \medbreak %
  3690. % Define the end token that this defining construct specifies
  3691. % so that it will exit this group.
  3692. \def#1{\endgraf\endgroup\medbreak}%
  3693. \def#2{\begingroup\obeylines\spacesplit#3}%
  3694. \parindent=0in
  3695. \advance\leftskip by \defbodyindent
  3696. \exdentamount=\defbodyindent
  3697. \begingroup %
  3698. \catcode 61=\active %
  3699. \obeylines\spacesplit#3}
  3700. % This is used for \def{tp,vr}parsebody. It could probably be used for
  3701. % some of the others, too, with some judicious conditionals.
  3702. %
  3703. \def\parsebodycommon#1#2#3{%
  3704. \begingroup\inENV %
  3705. \medbreak %
  3706. % Define the end token that this defining construct specifies
  3707. % so that it will exit this group.
  3708. \def#1{\endgraf\endgroup\medbreak}%
  3709. \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
  3710. \parindent=0in
  3711. \advance\leftskip by \defbodyindent
  3712. \exdentamount=\defbodyindent
  3713. \begingroup\obeylines
  3714. }
  3715. \def\defvrparsebody#1#2#3#4 {%
  3716. \parsebodycommon{#1}{#2}{#3}%
  3717. \spacesplit{#3{#4}}%
  3718. }
  3719. % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
  3720. % type is just `struct', because we lose the braces in `{struct
  3721. % termios}' when \spacesplit reads its undelimited argument. Sigh.
  3722. % \let\deftpparsebody=\defvrparsebody
  3723. %
  3724. % So, to get around this, we put \empty in with the type name. That
  3725. % way, TeX won't find exactly `{...}' as an undelimited argument, and
  3726. % won't strip off the braces.
  3727. %
  3728. \def\deftpparsebody #1#2#3#4 {%
  3729. \parsebodycommon{#1}{#2}{#3}%
  3730. \spacesplit{\parsetpheaderline{#3{#4}}}\empty
  3731. }
  3732. % Fine, but then we have to eventually remove the \empty *and* the
  3733. % braces (if any). That's what this does.
  3734. %
  3735. \def\removeemptybraces\empty#1\relax{#1}
  3736. % After \spacesplit has done its work, this is called -- #1 is the final
  3737. % thing to call, #2 the type name (which starts with \empty), and #3
  3738. % (which might be empty) the arguments.
  3739. %
  3740. \def\parsetpheaderline#1#2#3{%
  3741. #1{\removeemptybraces#2\relax}{#3}%
  3742. }%
  3743. \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
  3744. \medbreak %
  3745. % Define the end token that this defining construct specifies
  3746. % so that it will exit this group.
  3747. \def#1{\endgraf\endgroup\medbreak}%
  3748. \def#2##1 ##2 {\def#4{##1}%
  3749. \begingroup\obeylines\spacesplit{#3{##2}}}%
  3750. \parindent=0in
  3751. \advance\leftskip by \defbodyindent
  3752. \exdentamount=\defbodyindent
  3753. \begingroup\obeylines\spacesplit{#3{#5}}}
  3754. % Split up #2 at the first space token.
  3755. % call #1 with two arguments:
  3756. % the first is all of #2 before the space token,
  3757. % the second is all of #2 after that space token.
  3758. % If #2 contains no space token, all of it is passed as the first arg
  3759. % and the second is passed as empty.
  3760. {\obeylines
  3761. \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
  3762. \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
  3763. \ifx\relax #3%
  3764. #1{#2}{}\else #1{#2}{#3#4}\fi}}
  3765. % So much for the things common to all kinds of definitions.
  3766. % Define @defun.
  3767. % First, define the processing that is wanted for arguments of \defun
  3768. % Use this to expand the args and terminate the paragraph they make up
  3769. \def\defunargs #1{\functionparens \sl
  3770. % Expand, preventing hyphenation at `-' chars.
  3771. % Note that groups don't affect changes in \hyphenchar.
  3772. \hyphenchar\tensl=0
  3773. #1%
  3774. \hyphenchar\tensl=45
  3775. \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
  3776. \interlinepenalty=10000
  3777. \advance\rightskip by 0pt plus 1fil
  3778. \endgraf\nobreak\vskip -\parskip\nobreak
  3779. }
  3780. \def\deftypefunargs #1{%
  3781. % Expand, preventing hyphenation at `-' chars.
  3782. % Note that groups don't affect changes in \hyphenchar.
  3783. % Use \boldbraxnoamp, not \functionparens, so that & is not special.
  3784. \boldbraxnoamp
  3785. \tclose{#1}% avoid \code because of side effects on active chars
  3786. \interlinepenalty=10000
  3787. \advance\rightskip by 0pt plus 1fil
  3788. \endgraf\nobreak\vskip -\parskip\nobreak
  3789. }
  3790. % Do complete processing of one @defun or @defunx line already parsed.
  3791. % @deffn Command forward-char nchars
  3792. \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
  3793. \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
  3794. \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
  3795. \catcode 61=\other % Turn off change made in \defparsebody
  3796. }
  3797. % @defun == @deffn Function
  3798. \def\defun{\defparsebody\Edefun\defunx\defunheader}
  3799. \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3800. \begingroup\defname {#1}{Function}%
  3801. \defunargs {#2}\endgroup %
  3802. \catcode 61=\other % Turn off change made in \defparsebody
  3803. }
  3804. % @deftypefun int foobar (int @var{foo}, float @var{bar})
  3805. \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
  3806. % #1 is the data type. #2 is the name and args.
  3807. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
  3808. % #1 is the data type, #2 the name, #3 the args.
  3809. \def\deftypefunheaderx #1#2 #3\relax{%
  3810. \doind {fn}{\code{#2}}% Make entry in function index
  3811. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}%
  3812. \deftypefunargs {#3}\endgroup %
  3813. \catcode 61=\other % Turn off change made in \defparsebody
  3814. }
  3815. % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
  3816. \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
  3817. % \defheaderxcond#1\relax$$$
  3818. % puts #1 in @code, followed by a space, but does nothing if #1 is null.
  3819. \def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
  3820. % #1 is the classification. #2 is the data type. #3 is the name and args.
  3821. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
  3822. % #1 is the classification, #2 the data type, #3 the name, #4 the args.
  3823. \def\deftypefnheaderx #1#2#3 #4\relax{%
  3824. \doind {fn}{\code{#3}}% Make entry in function index
  3825. \begingroup
  3826. \normalparens % notably, turn off `&' magic, which prevents
  3827. % at least some C++ text from working
  3828. \defname {\defheaderxcond#2\relax$$$#3}{#1}%
  3829. \deftypefunargs {#4}\endgroup %
  3830. \catcode 61=\other % Turn off change made in \defparsebody
  3831. }
  3832. % @defmac == @deffn Macro
  3833. \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
  3834. \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3835. \begingroup\defname {#1}{Macro}%
  3836. \defunargs {#2}\endgroup %
  3837. \catcode 61=\other % Turn off change made in \defparsebody
  3838. }
  3839. % @defspec == @deffn Special Form
  3840. \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
  3841. \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
  3842. \begingroup\defname {#1}{Special Form}%
  3843. \defunargs {#2}\endgroup %
  3844. \catcode 61=\other % Turn off change made in \defparsebody
  3845. }
  3846. % This definition is run if you use @defunx
  3847. % anywhere other than immediately after a @defun or @defunx.
  3848. \def\deffnx #1 {\errmessage{@deffnx in invalid context}}
  3849. \def\defunx #1 {\errmessage{@defunx in invalid context}}
  3850. \def\defmacx #1 {\errmessage{@defmacx in invalid context}}
  3851. \def\defspecx #1 {\errmessage{@defspecx in invalid context}}
  3852. \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
  3853. \def\deftypemethodx #1 {\errmessage{@deftypemethodx in invalid context}}
  3854. \def\deftypefunx #1 {\errmessage{@deftypefunx in invalid context}}
  3855. % @defmethod, and so on
  3856. % @defop CATEGORY CLASS OPERATION ARG...
  3857. \def\defop #1 {\def\defoptype{#1}%
  3858. \defopparsebody\Edefop\defopx\defopheader\defoptype}
  3859. \def\defopheader #1#2#3{%
  3860. \dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
  3861. \begingroup\defname {#2}{\defoptype{} on #1}%
  3862. \defunargs {#3}\endgroup %
  3863. }
  3864. % @deftypemethod CLASS RETURN-TYPE METHOD ARG...
  3865. %
  3866. \def\deftypemethod{%
  3867. \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
  3868. %
  3869. % #1 is the class name, #2 the data type, #3 the method name, #4 the args.
  3870. \def\deftypemethodheader#1#2#3#4{%
  3871. \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
  3872. \begingroup
  3873. \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
  3874. \deftypefunargs{#4}%
  3875. \endgroup
  3876. }
  3877. % @defmethod == @defop Method
  3878. %
  3879. \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
  3880. %
  3881. % #1 is the class name, #2 the method name, #3 the args.
  3882. \def\defmethodheader#1#2#3{%
  3883. \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
  3884. \begingroup
  3885. \defname{#2}{\putwordMethodon\ \code{#1}}%
  3886. \defunargs{#3}%
  3887. \endgroup
  3888. }
  3889. % @defcv {Class Option} foo-class foo-flag
  3890. \def\defcv #1 {\def\defcvtype{#1}%
  3891. \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
  3892. \def\defcvarheader #1#2#3{%
  3893. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3894. \begingroup\defname {#2}{\defcvtype{} of #1}%
  3895. \defvarargs {#3}\endgroup %
  3896. }
  3897. % @defivar == @defcv {Instance Variable}
  3898. \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
  3899. \def\defivarheader #1#2#3{%
  3900. \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
  3901. \begingroup\defname {#2}{Instance Variable of #1}%
  3902. \defvarargs {#3}\endgroup %
  3903. }
  3904. % These definitions are run if you use @defmethodx, etc.,
  3905. % anywhere other than immediately after a @defmethod, etc.
  3906. \def\defopx #1 {\errmessage{@defopx in invalid context}}
  3907. \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
  3908. \def\defcvx #1 {\errmessage{@defcvx in invalid context}}
  3909. \def\defivarx #1 {\errmessage{@defivarx in invalid context}}
  3910. % Now @defvar
  3911. % First, define the processing that is wanted for arguments of @defvar.
  3912. % This is actually simple: just print them in roman.
  3913. % This must expand the args and terminate the paragraph they make up
  3914. \def\defvarargs #1{\normalparens #1%
  3915. \interlinepenalty=10000
  3916. \endgraf\nobreak\vskip -\parskip\nobreak}
  3917. % @defvr Counter foo-count
  3918. \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
  3919. \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
  3920. \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
  3921. % @defvar == @defvr Variable
  3922. \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
  3923. \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3924. \begingroup\defname {#1}{Variable}%
  3925. \defvarargs {#2}\endgroup %
  3926. }
  3927. % @defopt == @defvr {User Option}
  3928. \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
  3929. \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
  3930. \begingroup\defname {#1}{User Option}%
  3931. \defvarargs {#2}\endgroup %
  3932. }
  3933. % @deftypevar int foobar
  3934. \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
  3935. % #1 is the data type. #2 is the name, perhaps followed by text that
  3936. % is actually part of the data type, which should not be put into the index.
  3937. \def\deftypevarheader #1#2{%
  3938. \dovarind#2 \relax% Make entry in variables index
  3939. \begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}%
  3940. \interlinepenalty=10000
  3941. \endgraf\nobreak\vskip -\parskip\nobreak
  3942. \endgroup}
  3943. \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
  3944. % @deftypevr {Global Flag} int enable
  3945. \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
  3946. \def\deftypevrheader #1#2#3{\dovarind#3 \relax%
  3947. \begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
  3948. \interlinepenalty=10000
  3949. \endgraf\nobreak\vskip -\parskip\nobreak
  3950. \endgroup}
  3951. % This definition is run if you use @defvarx
  3952. % anywhere other than immediately after a @defvar or @defvarx.
  3953. \def\defvrx #1 {\errmessage{@defvrx in invalid context}}
  3954. \def\defvarx #1 {\errmessage{@defvarx in invalid context}}
  3955. \def\defoptx #1 {\errmessage{@defoptx in invalid context}}
  3956. \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
  3957. \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
  3958. % Now define @deftp
  3959. % Args are printed in bold, a slight difference from @defvar.
  3960. \def\deftpargs #1{\bf \defvarargs{#1}}
  3961. % @deftp Class window height width ...
  3962. \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
  3963. \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
  3964. \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
  3965. % This definition is run if you use @deftpx, etc
  3966. % anywhere other than immediately after a @deftp, etc.
  3967. \def\deftpx #1 {\errmessage{@deftpx in invalid context}}
  3968. \message{macros,}
  3969. % @macro.
  3970. % To do this right we need a feature of e-TeX, \scantokens,
  3971. % which we arrange to emulate with a temporary file in ordinary TeX.
  3972. \ifx\eTeXversion\undefined
  3973. \newwrite\macscribble
  3974. \def\scanmacro#1{%
  3975. \begingroup \newlinechar`\^^M
  3976. \immediate\openout\macscribble=\jobname.tmp
  3977. \immediate\write\macscribble{#1}%
  3978. \immediate\closeout\macscribble
  3979. \let\xeatspaces\eatspaces
  3980. \input \jobname.tmp
  3981. \endgroup
  3982. }
  3983. \else
  3984. \def\scanmacro#1{%
  3985. \begingroup \newlinechar`\^^M
  3986. \let\xeatspaces\eatspaces\scantokens{#1}\endgroup}
  3987. \fi
  3988. \newcount\paramno % Count of parameters
  3989. \newtoks\macname % Macro name
  3990. \newif\ifrecursive % Is it recursive?
  3991. % Utility routines.
  3992. % Thisdoes \let #1 = #2, except with \csnames.
  3993. \def\cslet#1#2{%
  3994. \expandafter\expandafter
  3995. \expandafter\let
  3996. \expandafter\expandafter
  3997. \csname#1\endcsname
  3998. \csname#2\endcsname}
  3999. % Trim leading and trailing spaces off a string.
  4000. % Concepts from aro-bend problem 15 (see CTAN).
  4001. {\catcode`\@=11
  4002. \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
  4003. \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
  4004. \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
  4005. \def\unbrace#1{#1}
  4006. \unbrace{\gdef\trim@@@ #1 } #2@{#1}
  4007. }
  4008. % Trim a single trailing ^^M off a string.
  4009. {\catcode`\^^M=12\catcode`\Q=3%
  4010. \gdef\eatcr #1{\eatcra #1Q^^MQ}%
  4011. \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
  4012. \gdef\eatcrb#1Q#2Q{#1}%
  4013. }
  4014. % Macro bodies are absorbed as an argument in a context where
  4015. % all characters are catcode 10, 11 or 12, except \ which is active
  4016. % (as in normal texinfo). It is necessary to change the definition of \.
  4017. % It's necessary to have hard CRs when the macro is executed. This is
  4018. % done by making ^^M (\endlinechar) catcode 12 when reading the macro
  4019. % body, and then making it the \newlinechar in \scanmacro.
  4020. \def\macrobodyctxt{%
  4021. \catcode`\~=12
  4022. \catcode`\^=12
  4023. \catcode`\_=12
  4024. \catcode`\|=12
  4025. \catcode`\<=12
  4026. \catcode`\>=12
  4027. \catcode`\+=12
  4028. \catcode`\{=12
  4029. \catcode`\}=12
  4030. \catcode`\@=12
  4031. \catcode`\^^M=12
  4032. \usembodybackslash}
  4033. \def\macroargctxt{%
  4034. \catcode`\~=12
  4035. \catcode`\^=12
  4036. \catcode`\_=12
  4037. \catcode`\|=12
  4038. \catcode`\<=12
  4039. \catcode`\>=12
  4040. \catcode`\+=12
  4041. \catcode`\@=12
  4042. \catcode`\\=12}
  4043. % \mbodybackslash is the definition of \ in @macro bodies.
  4044. % It maps \foo\ => \csname macarg.foo\endcsname => #N
  4045. % where N is the macro parameter number.
  4046. % We define \csname macarg.\endcsname to be \realbackslash, so
  4047. % \\ in macro replacement text gets you a backslash.
  4048. {\catcode`@=0 @catcode`@\=@active
  4049. @gdef@usembodybackslash{@let\=@mbodybackslash}
  4050. @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
  4051. }
  4052. \expandafter\def\csname macarg.\endcsname{\realbackslash}
  4053. \def\macro{\recursivefalse\parsearg\macroxxx}
  4054. \def\rmacro{\recursivetrue\parsearg\macroxxx}
  4055. \def\macroxxx#1{%
  4056. \getargs{#1}% now \macname is the macname and \argl the arglist
  4057. \ifx\argl\empty % no arguments
  4058. \paramno=0%
  4059. \else
  4060. \expandafter\parsemargdef \argl;%
  4061. \fi
  4062. \expandafter\ifx \csname macsave.\the\macname\endcsname \relax
  4063. \cslet{macsave.\the\macname}{\the\macname}%
  4064. \else
  4065. \message{Warning: redefining \the\macname}%
  4066. \fi
  4067. \begingroup \macrobodyctxt
  4068. \ifrecursive \expandafter\parsermacbody
  4069. \else \expandafter\parsemacbody
  4070. \fi}
  4071. \def\unmacro{\parsearg\unmacroxxx}
  4072. \def\unmacroxxx#1{%
  4073. \expandafter\ifx \csname macsave.\the\macname\endcsname \relax
  4074. \errmessage{Macro \the\macname\ not defined.}%
  4075. \else
  4076. \cslet{#1}{macsave.#1}%
  4077. \expandafter\let \csname macsave.\the\macname\endcsname \undefined
  4078. \fi
  4079. }
  4080. % This makes use of the obscure feature that if the last token of a
  4081. % <parameter list> is #, then the preceding argument is delimited by
  4082. % an opening brace, and that opening brace is not consumed.
  4083. \def\getargs#1{\getargsxxx#1{}}
  4084. \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
  4085. \def\getmacname #1 #2\relax{\macname={#1}}
  4086. \def\getmacargs#1{\def\argl{#1}}
  4087. % Parse the optional {params} list. Set up \paramno and \paramlist
  4088. % so \defmacro knows what to do. Define \macarg.blah for each blah
  4089. % in the params list, to be ##N where N is the position in that list.
  4090. % That gets used by \mbodybackslash (above).
  4091. % We need to get `macro parameter char #' into several definitions.
  4092. % The technique used is stolen from LaTeX: let \hash be something
  4093. % unexpandable, insert that wherever you need a #, and then redefine
  4094. % it to # just before using the token list produced.
  4095. %
  4096. % The same technique is used to protect \eatspaces till just before
  4097. % the macro is used.
  4098. \def\parsemargdef#1;{\paramno=0\def\paramlist{}%
  4099. \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
  4100. \def\parsemargdefxxx#1,{%
  4101. \if#1;\let\next=\relax
  4102. \else \let\next=\parsemargdefxxx
  4103. \advance\paramno by 1%
  4104. \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
  4105. {\xeatspaces{\hash\the\paramno}}%
  4106. \edef\paramlist{\paramlist\hash\the\paramno,}%
  4107. \fi\next}
  4108. % These two commands read recursive and nonrecursive macro bodies.
  4109. % (They're different since rec and nonrec macros end differently.)
  4110. \long\def\parsemacbody#1@end macro%
  4111. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  4112. \long\def\parsermacbody#1@end rmacro%
  4113. {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
  4114. % This defines the macro itself. There are six cases: recursive and
  4115. % nonrecursive macros of zero, one, and many arguments.
  4116. % Much magic with \expandafter here.
  4117. % \xdef is used so that macro definitions will survive the file
  4118. % they're defined in; @include reads the file inside a group.
  4119. \def\defmacro{%
  4120. \let\hash=##% convert placeholders to macro parameter chars
  4121. \ifrecursive
  4122. \ifcase\paramno
  4123. % 0
  4124. \expandafter\xdef\csname\the\macname\endcsname{%
  4125. \noexpand\scanmacro{\temp}}%
  4126. \or % 1
  4127. \expandafter\xdef\csname\the\macname\endcsname{%
  4128. \bgroup\noexpand\macroargctxt
  4129. \noexpand\braceorline\csname\the\macname xxx\endcsname}%
  4130. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  4131. \egroup\noexpand\scanmacro{\temp}}%
  4132. \else % many
  4133. \expandafter\xdef\csname\the\macname\endcsname{%
  4134. \bgroup\noexpand\macroargctxt
  4135. \noexpand\csname\the\macname xx\endcsname}
  4136. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  4137. \csname\the\macname xxx\endcsname ##1,}%
  4138. \expandafter\expandafter
  4139. \expandafter\xdef
  4140. \expandafter\expandafter
  4141. \csname\the\macname xxx\endcsname
  4142. \paramlist{\egroup\noexpand\scanmacro{\temp}}%
  4143. \fi
  4144. \else
  4145. \ifcase\paramno
  4146. % 0
  4147. \expandafter\xdef\csname\the\macname\endcsname{%
  4148. \noexpand\norecurse{\the\macname}%
  4149. \noexpand\scanmacro{\temp}\egroup}%
  4150. \or % 1
  4151. \expandafter\xdef\csname\the\macname\endcsname{%
  4152. \bgroup\noexpand\macroargctxt
  4153. \noexpand\braceorline\csname\the\macname xxx\endcsname}%
  4154. \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
  4155. \egroup
  4156. \noexpand\norecurse{\the\macname}%
  4157. \noexpand\scanmacro{\temp}\egroup}%
  4158. \else % many
  4159. \expandafter\xdef\csname\the\macname\endcsname{%
  4160. \bgroup\noexpand\macroargctxt
  4161. \noexpand\csname\the\macname xx\endcsname}
  4162. \expandafter\xdef\csname\the\macname xx\endcsname##1{%
  4163. \csname\the\macname xxx\endcsname ##1,}%
  4164. \expandafter\expandafter
  4165. \expandafter\xdef
  4166. \expandafter\expandafter
  4167. \csname\the\macname xxx\endcsname
  4168. \paramlist{%
  4169. \egroup
  4170. \noexpand\norecurse{\the\macname}%
  4171. \noexpand\scanmacro{\temp}\egroup}%
  4172. \fi
  4173. \fi}
  4174. \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
  4175. % \braceorline decides whether the next nonwhitespace character is a
  4176. % {. If so it reads up to the closing }, if not, it reads the whole
  4177. % line. Whatever was read is then fed to the next control sequence
  4178. % as an argument (by \parsebrace or \parsearg)
  4179. \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
  4180. \def\braceorlinexxx{%
  4181. \ifx\nchar\bgroup\else
  4182. \expandafter\parsearg
  4183. \fi \next}
  4184. \message{cross references,}
  4185. \newwrite\auxfile
  4186. \newif\ifhavexrefs % True if xref values are known.
  4187. \newif\ifwarnedxrefs % True if we warned once that they aren't known.
  4188. % @inforef is relatively simple.
  4189. \def\inforef #1{\inforefzzz #1,,,,**}
  4190. \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
  4191. node \samp{\ignorespaces#1{}}}
  4192. % @node's job is to define \lastnode.
  4193. \def\node{\ENVcheck\parsearg\nodezzz}
  4194. \def\nodezzz#1{\nodexxx [#1,]}
  4195. \def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
  4196. \let\nwnode=\node
  4197. \let\lastnode=\relax
  4198. % The sectioning commands (@chapter, etc.) call these.
  4199. \def\donoderef{%
  4200. \ifx\lastnode\relax\else
  4201. \expandafter\expandafter\expandafter\setref{\lastnode}%
  4202. {Ysectionnumberandtype}%
  4203. \global\let\lastnode=\relax
  4204. \fi
  4205. }
  4206. \def\unnumbnoderef{%
  4207. \ifx\lastnode\relax\else
  4208. \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
  4209. \global\let\lastnode=\relax
  4210. \fi
  4211. }
  4212. \def\appendixnoderef{%
  4213. \ifx\lastnode\relax\else
  4214. \expandafter\expandafter\expandafter\setref{\lastnode}%
  4215. {Yappendixletterandtype}%
  4216. \global\let\lastnode=\relax
  4217. \fi
  4218. }
  4219. % @anchor{NAME} -- define xref target at arbitrary point.
  4220. %
  4221. \def\anchor#1{\setref{#1}{Ynothing}}
  4222. % \setref{NAME}{SNT} defines a cross-reference point NAME, namely
  4223. % NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have
  4224. % to set \indexdummies so commands such as @code in a section title
  4225. % aren't expanded. It would be nicer not to expand the titles in the
  4226. % first place, but there's so many layers that that is hard to do.
  4227. %
  4228. \def\setref#1#2{{%
  4229. \indexdummies
  4230. \dosetq{#1-title}{Ytitle}%
  4231. \dosetq{#1-pg}{Ypagenumber}%
  4232. \dosetq{#1-snt}{#2}
  4233. }}
  4234. % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
  4235. % the node name, #2 the name of the Info cross-reference, #3 the printed
  4236. % node name, #4 the name of the Info file, #5 the name of the printed
  4237. % manual. All but the node name can be omitted.
  4238. %
  4239. \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
  4240. \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
  4241. \def\ref#1{\xrefX[#1,,,,,,,]}
  4242. \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
  4243. \def\printedmanual{\ignorespaces #5}%
  4244. \def\printednodename{\ignorespaces #3}%
  4245. \setbox1=\hbox{\printedmanual}%
  4246. \setbox0=\hbox{\printednodename}%
  4247. \ifdim \wd0 = 0pt
  4248. % No printed node name was explicitly given.
  4249. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
  4250. % Use the node name inside the square brackets.
  4251. \def\printednodename{\ignorespaces #1}%
  4252. \else
  4253. % Use the actual chapter/section title appear inside
  4254. % the square brackets. Use the real section title if we have it.
  4255. \ifdim \wd1 > 0pt
  4256. % It is in another manual, so we don't have it.
  4257. \def\printednodename{\ignorespaces #1}%
  4258. \else
  4259. \ifhavexrefs
  4260. % We know the real title if we have the xref values.
  4261. \def\printednodename{\refx{#1-title}{}}%
  4262. \else
  4263. % Otherwise just copy the Info node name.
  4264. \def\printednodename{\ignorespaces #1}%
  4265. \fi%
  4266. \fi
  4267. \fi
  4268. \fi
  4269. %
  4270. % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
  4271. % insert empty discretionaries after hyphens, which means that it will
  4272. % not find a line break at a hyphen in a node names. Since some manuals
  4273. % are best written with fairly long node names, containing hyphens, this
  4274. % is a loss. Therefore, we give the text of the node name again, so it
  4275. % is as if TeX is seeing it for the first time.
  4276. \ifdim \wd1 > 0pt
  4277. \putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
  4278. \else
  4279. % _ (for example) has to be the character _ for the purposes of the
  4280. % control sequence corresponding to the node, but it has to expand
  4281. % into the usual \leavevmode...\vrule stuff for purposes of
  4282. % printing. So we \turnoffactive for the \refx-snt, back on for the
  4283. % printing, back off for the \refx-pg.
  4284. {\normalturnoffactive
  4285. % Only output a following space if the -snt ref is nonempty; for
  4286. % @unnumbered and @anchor, it won't be.
  4287. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
  4288. \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
  4289. }%
  4290. % [mynode],
  4291. [\printednodename],\space
  4292. % page 3
  4293. \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
  4294. \fi
  4295. \endgroup}
  4296. % \dosetq is the interface for calls from other macros
  4297. % Use \normalturnoffactive so that punctuation chars such as underscore
  4298. % and backslash work in node names. (\turnoffactive doesn't do \.)
  4299. \def\dosetq#1#2{%
  4300. {\let\folio=0
  4301. \normalturnoffactive
  4302. \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
  4303. \iflinks
  4304. \next
  4305. \fi
  4306. }%
  4307. }
  4308. % \internalsetq {foo}{page} expands into
  4309. % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
  4310. % When the aux file is read, ' is the escape character
  4311. \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
  4312. % Things to be expanded by \internalsetq
  4313. \def\Ypagenumber{\folio}
  4314. \def\Ytitle{\thissection}
  4315. \def\Ynothing{}
  4316. \def\Ysectionnumberandtype{%
  4317. \ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
  4318. \else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
  4319. \else \ifnum \subsubsecno=0 %
  4320. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
  4321. \else %
  4322. \putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
  4323. \fi \fi \fi }
  4324. \def\Yappendixletterandtype{%
  4325. \ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
  4326. \else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
  4327. \else \ifnum \subsubsecno=0 %
  4328. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
  4329. \else %
  4330. \putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
  4331. \fi \fi \fi }
  4332. \gdef\xreftie{'tie}
  4333. % Use TeX 3.0's \inputlineno to get the line number, for better error
  4334. % messages, but if we're using an old version of TeX, don't do anything.
  4335. %
  4336. \ifx\inputlineno\thisisundefined
  4337. \let\linenumber = \empty % Non-3.0.
  4338. \else
  4339. \def\linenumber{\the\inputlineno:\space}
  4340. \fi
  4341. % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
  4342. % If its value is nonempty, SUFFIX is output afterward.
  4343. \def\refx#1#2{%
  4344. \expandafter\ifx\csname X#1\endcsname\relax
  4345. % If not defined, say something at least.
  4346. \angleleft un\-de\-fined\angleright
  4347. \iflinks
  4348. \ifhavexrefs
  4349. \message{\linenumber Undefined cross reference `#1'.}%
  4350. \else
  4351. \ifwarnedxrefs\else
  4352. \global\warnedxrefstrue
  4353. \message{Cross reference values unknown; you must run TeX again.}%
  4354. \fi
  4355. \fi
  4356. \fi
  4357. \else
  4358. % It's defined, so just use it.
  4359. \csname X#1\endcsname
  4360. \fi
  4361. #2% Output the suffix in any case.
  4362. }
  4363. % This is the macro invoked by entries in the aux file.
  4364. %
  4365. \def\xrdef#1{\begingroup
  4366. % Reenable \ as an escape while reading the second argument.
  4367. \catcode`\\ = 0
  4368. \afterassignment\endgroup
  4369. \expandafter\gdef\csname X#1\endcsname
  4370. }
  4371. % Read the last existing aux file, if any. No error if none exists.
  4372. \def\readauxfile{\begingroup
  4373. \catcode`\^^@=\other
  4374. \catcode`\^^A=\other
  4375. \catcode`\^^B=\other
  4376. \catcode`\^^C=\other
  4377. \catcode`\^^D=\other
  4378. \catcode`\^^E=\other
  4379. \catcode`\^^F=\other
  4380. \catcode`\^^G=\other
  4381. \catcode`\^^H=\other
  4382. \catcode`\^^K=\other
  4383. \catcode`\^^L=\other
  4384. \catcode`\^^N=\other
  4385. \catcode`\^^P=\other
  4386. \catcode`\^^Q=\other
  4387. \catcode`\^^R=\other
  4388. \catcode`\^^S=\other
  4389. \catcode`\^^T=\other
  4390. \catcode`\^^U=\other
  4391. \catcode`\^^V=\other
  4392. \catcode`\^^W=\other
  4393. \catcode`\^^X=\other
  4394. \catcode`\^^Z=\other
  4395. \catcode`\^^[=\other
  4396. \catcode`\^^\=\other
  4397. \catcode`\^^]=\other
  4398. \catcode`\^^^=\other
  4399. \catcode`\^^_=\other
  4400. \catcode`\@=\other
  4401. \catcode`\^=\other
  4402. % It was suggested to define this as 7, which would allow ^^e4 etc.
  4403. % in xref tags, i.e., node names. But since ^^e4 notation isn't
  4404. % supported in the main text, it doesn't seem desirable. Furthermore,
  4405. % that is not enough: for node names that actually contain a ^
  4406. % character, we would end up writing a line like this: 'xrdef {'hat
  4407. % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
  4408. % argument, and \hat is not an expandable control sequence. It could
  4409. % all be worked out, but why? Either we support ^^ or we don't.
  4410. %
  4411. % The other change necessary for this was to define \auxhat:
  4412. % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
  4413. % and then to call \auxhat in \setq.
  4414. %
  4415. \catcode`\~=\other
  4416. \catcode`\[=\other
  4417. \catcode`\]=\other
  4418. \catcode`\"=\other
  4419. \catcode`\_=\other
  4420. \catcode`\|=\other
  4421. \catcode`\<=\other
  4422. \catcode`\>=\other
  4423. \catcode`\$=\other
  4424. \catcode`\#=\other
  4425. \catcode`\&=\other
  4426. \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
  4427. % Make the characters 128-255 be printing characters
  4428. {%
  4429. \count 1=128
  4430. \def\loop{%
  4431. \catcode\count 1=\other
  4432. \advance\count 1 by 1
  4433. \ifnum \count 1<256 \loop \fi
  4434. }%
  4435. }%
  4436. % The aux file uses ' as the escape (for now).
  4437. % Turn off \ as an escape so we do not lose on
  4438. % entries which were dumped with control sequences in their names.
  4439. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
  4440. % Reference to such entries still does not work the way one would wish,
  4441. % but at least they do not bomb out when the aux file is read in.
  4442. \catcode`\{=1
  4443. \catcode`\}=2
  4444. \catcode`\%=\other
  4445. \catcode`\'=0
  4446. \catcode`\\=\other
  4447. %
  4448. \openin 1 \jobname.aux
  4449. \ifeof 1 \else
  4450. \closein 1
  4451. \input \jobname.aux
  4452. \global\havexrefstrue
  4453. \global\warnedobstrue
  4454. \fi
  4455. % Open the new aux file. TeX will close it automatically at exit.
  4456. \openout\auxfile=\jobname.aux
  4457. \endgroup}
  4458. % Footnotes.
  4459. \newcount \footnoteno
  4460. % The trailing space in the following definition for supereject is
  4461. % vital for proper filling; pages come out unaligned when you do a
  4462. % pagealignmacro call if that space before the closing brace is
  4463. % removed. (Generally, numeric constants should always be followed by a
  4464. % space to prevent strange expansion errors.)
  4465. \def\supereject{\par\penalty -20000\footnoteno =0 }
  4466. % @footnotestyle is meaningful for info output only.
  4467. \let\footnotestyle=\comment
  4468. \let\ptexfootnote=\footnote
  4469. {\catcode `\@=11
  4470. %
  4471. % Auto-number footnotes. Otherwise like plain.
  4472. \gdef\footnote{%
  4473. \global\advance\footnoteno by \@ne
  4474. \edef\thisfootno{$^{\the\footnoteno}$}%
  4475. %
  4476. % In case the footnote comes at the end of a sentence, preserve the
  4477. % extra spacing after we do the footnote number.
  4478. \let\@sf\empty
  4479. \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
  4480. %
  4481. % Remove inadvertent blank space before typesetting the footnote number.
  4482. \unskip
  4483. \thisfootno\@sf
  4484. \footnotezzz
  4485. }%
  4486. % Don't bother with the trickery in plain.tex to not require the
  4487. % footnote text as a parameter. Our footnotes don't need to be so general.
  4488. %
  4489. % Oh yes, they do; otherwise, @ifset and anything else that uses
  4490. % \parseargline fail inside footnotes because the tokens are fixed when
  4491. % the footnote is read. --karl, 16nov96.
  4492. %
  4493. \long\gdef\footnotezzz{\insert\footins\bgroup
  4494. % We want to typeset this text as a normal paragraph, even if the
  4495. % footnote reference occurs in (for example) a display environment.
  4496. % So reset some parameters.
  4497. \interlinepenalty\interfootnotelinepenalty
  4498. \splittopskip\ht\strutbox % top baseline for broken footnotes
  4499. \splitmaxdepth\dp\strutbox
  4500. \floatingpenalty\@MM
  4501. \leftskip\z@skip
  4502. \rightskip\z@skip
  4503. \spaceskip\z@skip
  4504. \xspaceskip\z@skip
  4505. \parindent\defaultparindent
  4506. %
  4507. % Hang the footnote text off the number.
  4508. \hang
  4509. \textindent{\thisfootno}%
  4510. %
  4511. % Don't crash into the line above the footnote text. Since this
  4512. % expands into a box, it must come within the paragraph, lest it
  4513. % provide a place where TeX can split the footnote.
  4514. \footstrut
  4515. \futurelet\next\fo@t
  4516. }
  4517. \def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
  4518. \else\let\next\f@t\fi \next}
  4519. \def\f@@t{\bgroup\aftergroup\@foot\let\next}
  4520. \def\f@t#1{#1\@foot}
  4521. \def\@foot{\strut\egroup}
  4522. }%end \catcode `\@=11
  4523. % Set the baselineskip to #1, and the lineskip and strut size
  4524. % correspondingly. There is no deep meaning behind these magic numbers
  4525. % used as factors; they just match (closely enough) what Knuth defined.
  4526. %
  4527. \def\lineskipfactor{.08333}
  4528. \def\strutheightpercent{.70833}
  4529. \def\strutdepthpercent {.29167}
  4530. %
  4531. \def\setleading#1{%
  4532. \normalbaselineskip = #1\relax
  4533. \normallineskip = \lineskipfactor\normalbaselineskip
  4534. \normalbaselines
  4535. \setbox\strutbox =\hbox{%
  4536. \vrule width0pt height\strutheightpercent\baselineskip
  4537. depth \strutdepthpercent \baselineskip
  4538. }%
  4539. }
  4540. % @| inserts a changebar to the left of the current line. It should
  4541. % surround any changed text. This approach does *not* work if the
  4542. % change spans more than two lines of output. To handle that, we would
  4543. % have adopt a much more difficult approach (putting marks into the main
  4544. % vertical list for the beginning and end of each change).
  4545. %
  4546. \def\|{%
  4547. % \vadjust can only be used in horizontal mode.
  4548. \leavevmode
  4549. %
  4550. % Append this vertical mode material after the current line in the output.
  4551. \vadjust{%
  4552. % We want to insert a rule with the height and depth of the current
  4553. % leading; that is exactly what \strutbox is supposed to record.
  4554. \vskip-\baselineskip
  4555. %
  4556. % \vadjust-items are inserted at the left edge of the type. So
  4557. % the \llap here moves out into the left-hand margin.
  4558. \llap{%
  4559. %
  4560. % For a thicker or thinner bar, change the `1pt'.
  4561. \vrule height\baselineskip width1pt
  4562. %
  4563. % This is the space between the bar and the text.
  4564. \hskip 12pt
  4565. }%
  4566. }%
  4567. }
  4568. % For a final copy, take out the rectangles
  4569. % that mark overfull boxes (in case you have decided
  4570. % that the text looks ok even though it passes the margin).
  4571. %
  4572. \def\finalout{\overfullrule=0pt}
  4573. % @image. We use the macros from epsf.tex to support this.
  4574. % If epsf.tex is not installed and @image is used, we complain.
  4575. %
  4576. % Check for and read epsf.tex up front. If we read it only at @image
  4577. % time, we might be inside a group, and then its definitions would get
  4578. % undone and the next image would fail.
  4579. \openin 1 = epsf.tex
  4580. \ifeof 1 \else
  4581. \closein 1
  4582. % Do not bother showing banner with post-v2.7 epsf.tex (available in
  4583. % doc/epsf.tex until it shows up on ctan).
  4584. \def\epsfannounce{\toks0 = }%
  4585. \input epsf.tex
  4586. \fi
  4587. %
  4588. \newif\ifwarnednoepsf
  4589. \newhelp\noepsfhelp{epsf.tex must be installed for images to
  4590. work. It is also included in the Texinfo distribution, or you can get
  4591. it from ftp://ftp.tug.org/tex/epsf.tex.}
  4592. %
  4593. % Only complain once about lack of epsf.tex.
  4594. \def\image#1{%
  4595. \ifx\epsfbox\undefined
  4596. \ifwarnednoepsf \else
  4597. \errhelp = \noepsfhelp
  4598. \errmessage{epsf.tex not found, images will be ignored}%
  4599. \global\warnednoepsftrue
  4600. \fi
  4601. \else
  4602. \imagexxx #1,,,\finish
  4603. \fi
  4604. }
  4605. %
  4606. % Arguments to @image:
  4607. % #1 is (mandatory) image filename; we tack on .eps extension.
  4608. % #2 is (optional) width, #3 is (optional) height.
  4609. % #4 is just the usual extra ignored arg for parsing this stuff.
  4610. \def\imagexxx#1,#2,#3,#4\finish{%
  4611. % \epsfbox itself resets \epsf?size at each figure.
  4612. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
  4613. \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
  4614. % If the image is by itself, center it.
  4615. \ifvmode
  4616. \nobreak\medskip
  4617. \nobreak
  4618. \centerline{\epsfbox{#1.eps}}%
  4619. \bigbreak
  4620. \else
  4621. \epsfbox{#1.eps}%
  4622. \fi
  4623. }
  4624. \message{paper sizes,}
  4625. % And other related parameters.
  4626. \newdimen\defaultparindent \defaultparindent = 15pt
  4627. \chapheadingskip = 15pt plus 4pt minus 2pt
  4628. \secheadingskip = 12pt plus 3pt minus 2pt
  4629. \subsecheadingskip = 9pt plus 2pt minus 2pt
  4630. % Prevent underfull vbox error messages.
  4631. \vbadness = 10000
  4632. % Don't be so finicky about underfull hboxes, either.
  4633. \hbadness = 2000
  4634. % Following George Bush, just get rid of widows and orphans.
  4635. \widowpenalty=10000
  4636. \clubpenalty=10000
  4637. % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
  4638. % using an old version of TeX, don't do anything. We want the amount of
  4639. % stretch added to depend on the line length, hence the dependence on
  4640. % \hsize. This makes it come to about 9pt for the 8.5x11 format. We
  4641. % call this whenever the paper size is set.
  4642. %
  4643. \def\setemergencystretch{%
  4644. \ifx\emergencystretch\thisisundefined
  4645. % Allow us to assign to \emergencystretch anyway.
  4646. \def\emergencystretch{\dimen0}%
  4647. \else
  4648. \emergencystretch = \hsize
  4649. \divide\emergencystretch by 45
  4650. \fi
  4651. }
  4652. % Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
  4653. % 4) hoffset; 5) binding offset; 6) topskip. Then whoever calls us can
  4654. % set \parskip and call \setleading for \baselineskip.
  4655. %
  4656. \def\internalpagesizes#1#2#3#4#5#6{%
  4657. \voffset = #3\relax
  4658. \topskip = #6\relax
  4659. \splittopskip = \topskip
  4660. %
  4661. \vsize = #1\relax
  4662. \advance\vsize by \topskip
  4663. \outervsize = \vsize
  4664. \advance\outervsize by 2\topandbottommargin
  4665. \pageheight = \vsize
  4666. %
  4667. \hsize = #2\relax
  4668. \outerhsize = \hsize
  4669. \advance\outerhsize by 0.5in
  4670. \pagewidth = \hsize
  4671. %
  4672. \normaloffset = #4\relax
  4673. \bindingoffset = #5\relax
  4674. %
  4675. \parindent = \defaultparindent
  4676. \setemergencystretch
  4677. }
  4678. % @letterpaper (the default).
  4679. \def\letterpaper{{\globaldefs = 1
  4680. \parskip = 3pt plus 2pt minus 1pt
  4681. \setleading{13.2pt}%
  4682. %
  4683. % If page is nothing but text, make it come out even.
  4684. \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
  4685. }}
  4686. % Use @smallbook to reset parameters for 7x9.5 (or so) format.
  4687. \def\smallbook{{\globaldefs = 1
  4688. \parskip = 2pt plus 1pt
  4689. \setleading{12pt}%
  4690. %
  4691. \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
  4692. %
  4693. \lispnarrowing = 0.3in
  4694. \tolerance = 700
  4695. \hfuzz = 1pt
  4696. \contentsrightmargin = 0pt
  4697. \deftypemargin = 0pt
  4698. \defbodyindent = .5cm
  4699. %
  4700. \let\smalldisplay = \smalldisplayx
  4701. \let\smallexample = \smalllispx
  4702. \let\smallformat = \smallformatx
  4703. \let\smalllisp = \smalllispx
  4704. }}
  4705. % Use @afourpaper to print on European A4 paper.
  4706. \def\afourpaper{{\globaldefs = 1
  4707. \setleading{12pt}%
  4708. \parskip = 3pt plus 2pt minus 1pt
  4709. %
  4710. \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
  4711. %
  4712. \tolerance = 700
  4713. \hfuzz = 1pt
  4714. }}
  4715. % A specific text layout, 24x15cm overall, intended for A4 paper. Top margin
  4716. % 29mm, hence bottom margin 28mm, nominal side margin 3cm.
  4717. \def\afourlatex{{\globaldefs = 1
  4718. \setleading{13.6pt}%
  4719. %
  4720. \afourpaper
  4721. \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
  4722. %
  4723. \globaldefs = 0
  4724. }}
  4725. % Use @afourwide to print on European A4 paper in wide format.
  4726. \def\afourwide{%
  4727. \afourpaper
  4728. \internalpagesizes{9.5in}{6.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
  4729. %
  4730. \globaldefs = 0
  4731. }
  4732. % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
  4733. % Perhaps we should allow setting the margins, \topskip, \parskip,
  4734. % and/or leading, also. Or perhaps we should compute them somehow.
  4735. %
  4736. \def\pagesizes{\parsearg\pagesizesxxx}
  4737. \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
  4738. \def\pagesizesyyy#1,#2,#3\finish{{%
  4739. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
  4740. \globaldefs = 1
  4741. %
  4742. \parskip = 3pt plus 2pt minus 1pt
  4743. \setleading{13.2pt}%
  4744. %
  4745. \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
  4746. }}
  4747. % Set default to letter.
  4748. %
  4749. \letterpaper
  4750. \message{and turning on texinfo input format.}
  4751. % Define macros to output various characters with catcode for normal text.
  4752. \catcode`\"=\other
  4753. \catcode`\~=\other
  4754. \catcode`\^=\other
  4755. \catcode`\_=\other
  4756. \catcode`\|=\other
  4757. \catcode`\<=\other
  4758. \catcode`\>=\other
  4759. \catcode`\+=\other
  4760. \def\normaldoublequote{"}
  4761. \def\normaltilde{~}
  4762. \def\normalcaret{^}
  4763. \def\normalunderscore{_}
  4764. \def\normalverticalbar{|}
  4765. \def\normalless{<}
  4766. \def\normalgreater{>}
  4767. \def\normalplus{+}
  4768. % This macro is used to make a character print one way in ttfont
  4769. % where it can probably just be output, and another way in other fonts,
  4770. % where something hairier probably needs to be done.
  4771. %
  4772. % #1 is what to print if we are indeed using \tt; #2 is what to print
  4773. % otherwise. Since all the Computer Modern typewriter fonts have zero
  4774. % interword stretch (and shrink), and it is reasonable to expect all
  4775. % typewriter fonts to have this, we can check that font parameter.
  4776. %
  4777. \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
  4778. % Turn off all special characters except @
  4779. % (and those which the user can use as if they were ordinary).
  4780. % Most of these we simply print from the \tt font, but for some, we can
  4781. % use math or other variants that look better in normal text.
  4782. \catcode`\"=\active
  4783. \def\activedoublequote{{\tt\char34}}
  4784. \let"=\activedoublequote
  4785. \catcode`\~=\active
  4786. \def~{{\tt\char126}}
  4787. \chardef\hat=`\^
  4788. \catcode`\^=\active
  4789. \def^{{\tt \hat}}
  4790. \catcode`\_=\active
  4791. \def_{\ifusingtt\normalunderscore\_}
  4792. % Subroutine for the previous macro.
  4793. \def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
  4794. \catcode`\|=\active
  4795. \def|{{\tt\char124}}
  4796. \chardef \less=`\<
  4797. \catcode`\<=\active
  4798. \def<{{\tt \less}}
  4799. \chardef \gtr=`\>
  4800. \catcode`\>=\active
  4801. \def>{{\tt \gtr}}
  4802. \catcode`\+=\active
  4803. \def+{{\tt \char 43}}
  4804. %\catcode 27=\active
  4805. %\def^^[{$\diamondsuit$}
  4806. % Set up an active definition for =, but don't enable it most of the time.
  4807. {\catcode`\==\active
  4808. \global\def={{\tt \char 61}}}
  4809. \catcode`+=\active
  4810. \catcode`\_=\active
  4811. % If a .fmt file is being used, characters that might appear in a file
  4812. % name cannot be active until we have parsed the command line.
  4813. % So turn them off again, and have \everyjob (or @setfilename) turn them on.
  4814. % \otherifyactive is called near the end of this file.
  4815. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
  4816. \catcode`\@=0
  4817. % \rawbackslashxx output one backslash character in current font
  4818. \global\chardef\rawbackslashxx=`\\
  4819. %{\catcode`\\=\other
  4820. %@gdef@rawbackslashxx{\}}
  4821. % \rawbackslash redefines \ as input to do \rawbackslashxx.
  4822. {\catcode`\\=\active
  4823. @gdef@rawbackslash{@let\=@rawbackslashxx }}
  4824. % \normalbackslash outputs one backslash in fixed width font.
  4825. \def\normalbackslash{{\tt\rawbackslashxx}}
  4826. % Say @foo, not \foo, in error messages.
  4827. \escapechar=`\@
  4828. % \catcode 17=0 % Define control-q
  4829. \catcode`\\=\active
  4830. % Used sometimes to turn off (effectively) the active characters
  4831. % even after parsing them.
  4832. @def@turnoffactive{@let"=@normaldoublequote
  4833. @let\=@realbackslash
  4834. @let~=@normaltilde
  4835. @let^=@normalcaret
  4836. @let_=@normalunderscore
  4837. @let|=@normalverticalbar
  4838. @let<=@normalless
  4839. @let>=@normalgreater
  4840. @let+=@normalplus}
  4841. @def@normalturnoffactive{@let"=@normaldoublequote
  4842. @let\=@normalbackslash
  4843. @let~=@normaltilde
  4844. @let^=@normalcaret
  4845. @let_=@normalunderscore
  4846. @let|=@normalverticalbar
  4847. @let<=@normalless
  4848. @let>=@normalgreater
  4849. @let+=@normalplus}
  4850. % Make _ and + \other characters, temporarily.
  4851. % This is canceled by @fixbackslash.
  4852. @otherifyactive
  4853. % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
  4854. % That is what \eatinput is for; after that, the `\' should revert to printing
  4855. % a backslash.
  4856. %
  4857. @gdef@eatinput input texinfo{@fixbackslash}
  4858. @global@let\ = @eatinput
  4859. % On the other hand, perhaps the file did not have a `\input texinfo'. Then
  4860. % the first `\{ in the file would cause an error. This macro tries to fix
  4861. % that, assuming it is called before the first `\' could plausibly occur.
  4862. % Also back turn on active characters that might appear in the input
  4863. % file name, in case not using a pre-dumped format.
  4864. %
  4865. @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi
  4866. @catcode`+=@active @catcode`@_=@active}
  4867. % These look ok in all fonts, so just make them not special. The @rm below
  4868. % makes sure that the current font starts out as the newly loaded cmr10
  4869. @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
  4870. @textfonts
  4871. @rm
  4872. @c Local variables:
  4873. @c eval: (add-hook 'write-file-hooks 'time-stamp)
  4874. @c page-delimiter: "^\\\\message"
  4875. @c time-stamp-start: "def\\\\texinfoversion{"
  4876. @c time-stamp-format: "%:y-%02m-%02d"
  4877. @c time-stamp-end: "}"
  4878. @c End: