; TeX output 1996.10.10:1137sof߆TG cmtt12footnote7tDtGGcmr17|'a7tpsortmanqteaupackagez[for7tcustomisingfosotnotesinLdKGXQ cmr12AT[-E;gX`2gG cmmi12"@\!", cmsy109.RobinFVairbairns2K cmsy8yΙOctobSer10,19969INff cmbx121aLUserffinterfaceIK`y cmr10TheJ'ExX2 b> cmmi10"+ doGcuments(thesourcesofthecoGdeinthispackqageareIvqarious,_butballofithasbGeenmassagedbytheauthor;^wherethecodecomesfromIelsewhere,UUthereareattributionsgivenbGelow,somewhereorother).XThePginterfacetothepackqage'soptionsisverysimple|eachoneispre-Isentedasanoptioninthe\usepackagecommand. eF*orexample,;touseaIuseful5andconsistentset,theauthorinvokesthepackqagewiththecommandI\usepackage[perpage,para,symbol]{footnote}.񉍍IN cmbx121.1gOption ߆T cmtt12perpageuTIThis1optionresetsfoGotnotenumbering1foreachpageofthedocument.7ItisderivedIfrompagefoots.stybyBrianT.SchellenbGerger(bts@unx.sas.com),.]butI'veIdone)quitealotofL5ffA͉TU>'ExX(2")Ʋ)-isationofthecoGde.CItneedstwo)passestodothisIcorrectly(thoughitcomesascloseaspGossibleonthe rstpass).D=Y*ougenerallyIhavetomaketwopasseswithL5ffA͉TU>'ExXanyway*,Vtogetthecross-referencesright,VsoIanadditionalpassforthispurpGoseshouldn'tcauseanyadditionalproblem. TheIoptionqincludescoGdetoreportthat`Label(s)mayhavechanged',xwhichwillhelpItheUUpGoorusertorealisethatanotherrunisinorder...I1.2gOptionparauTIThisoption(derivedfromcoGdebyDominikW*ujastykandChrisRowley)causesIfoGotnotesB\tobetypesetasasingleparagraphatthebottomofthepageonwhichIthey^oGccur.Inthecasethatthereisonlyonefootnoteonthepage,anoe ectwillIbGe3;observed.fiHowever,: ifthereareseveralfoGotnotesonthepage,: theywillberunItogetherinthepagefoGot,eachintroGducedbyitsfoGotnotemark.:ThisarrangementIcansaveconsiderablespace,butoneshouldbGearinmindJillKnuth'sadmonitionIonpage125oftheTU>'ExXbGook:!p0J cmsl10Don'tusefoGotnotesinyourbooks,Y'Don. GTheIpffr @ -:q% cmsy6L|{Ycmr8ThisX lehasvÎersionnumb'ExXwouldnormallysettheIfoGotnotesUUamere\skip\footinsdistantfromthebottomofthetext.I1.5gOptionmarginaluTIThis;optionadjuststhepGositionoffootnotemarkrelativetothestartofthelineinIwhich6theyappGear(thetheoptionisincompatiblewithoptionpara,nforobviousIreasons).XWhen^thisoptionisine ect,`thefoGotnoteisset\footnotemarginrelativetoIthe leftmarginofthepage;ethedefaultsettingfor\footnotemarginis-0.8em,Iwhich'_meansthatthefoGotnotemarkwillbesetjutting0.8emintothemargin.IIf\footnotemargin isapGositivelength,8thefootnotemarkwillbesetwithitsIrightledge\footnotemarginfromthemargin. (Intheabsenceoftheoption,I\footnotemarginUUissetto1.8em.)I1.6gOptionflushmarginuTIThisoptionisasoptionmarginal,EbutsetsthefoGotnotemarker ushwith,butIjustUUinsidethemarginfrom,thetextofthefoGotnote.I1.7gOptionnoruleuTIThismoptionsuppressesthe`normal'foGotnoterule,andadvqances\skip\footinsIaUUbittocompGensate!čI2aLCos3de:32PreliminariesIW*ellUU|herewego:qlet'smakethepackqage le:Ls1S% cmsy9h&ow cmss9pack9age#g iXNowUUdeclarewhatenvironmentweneed:Ls2S"ߤN cmtt9\NeedsTeXFormat{LaTeX2e}2 soXSometimes,owejHneedalittleverbGosityfordebugging.ThiscanbGeachievedby Iun-commentingUUthisline:Ls3S%\setcounter{errorcontextlines}{999}!čI3aLTheffpackage's`initialcos3de'IThisconditionalusedtobGedeclaredinsidepagefoots.sty(Idon'tmuchlikeIit,but...);I'veIrenameditfrom\ifisdigitandmovedit`outer'(damnthatImechanism).Ls4S%\newif\if@@digitXThiscommandisde neddi erentlyinMattSwift's)m#R cmss10newcludepackqage(yettoIhitUUthestreets),andwealsode neithereinacompatiblewayLs5S\providecommand\protected@writeaux{% Ls6]\protected@write\@auxoutLs7S}XTheNcounterhereisusedtodetectwhetheranyhackingneedsdoingtoL5ffA͉TU>'ExX's Ioutput qroutine.AfterproGcessingoptions,;xthevqalueofthecounteris<0iftheIbottomUUoptionhasbGeenexercised,and+': cmti10o}'dd]޲ifparaoptionhasbeenexercised.Ls8S\def\FN@outputflag{0}XThe samejobforwhetherwearetopatch\footnoteisdonewiththiscounter.IIts}vqalueis9iftheperpageoptionhasbGeenexercised(thecuriousvaluebGeingIchosentsuchthatifeitherof\FN@outputflagor\PP@footflaghasbGeentouched,ItheirUUsumisnon-zero.Ls9S\def\PP@footflag{0}XNowwede neajolllylittlemacrotoadvqanceamacrocount(#1)byagivenIamountUU(#2).I10S\def\@advance@macro#1#2{\expandafter\@tempcnta#1\relax I11\advance\@tempcnta#2\relaxI12\edef#1{\the\@tempcnta}}XFinally*,mwehde nethelengthusedbythemarginaloption,mandinitialiseitas IifUUwe'venothadtheoption.I13S\newdimen\footnotemarginI14S\footnotemargin1.8em\relax!čI4aLTheff,߆Tff cmtt12symboloptionIThis>isadeclarationthatappGearsintheoriginalL5ffA͉TU>'ExXbook.FjSinceitappearedin Itheoldpagefoots.sty(presumablysinceitgoGessonaturallywiththeperpageIoption),UUI'veaddedthistrivialpieceofcustomisationtothepackqage.I15S\DeclareOption{symbol}{\renewcommand\thefootnote{\fnsymbol{footnote}}}I5aLTheffparaoptionIThebasisofthecoGdeforthisoptioncomesfromTU>'ExXbook,pp.398 .(\DirtyIT*ricks"),>thoughvitdoGes(ofcourse)avoidrede ning\\whichhassomeother3soI(somewhatTsigni cant)usesinL5ffA͉TU>'ExX!(TheusershouldbGeawareofKnuth'snote Ion@pthelimitationsofthismethoGdofdoingthejob:GtheTU>'ExXstackisusedfourItimespGerfootnote,܋andthestackislimited(seetheTU>'ExXbook,܋p.300 .).JIfyouIhaveverylargenumbGersoffootnotes(inthehundreds),BandencountertheerrorI\!?TeXcapacityexceeded,sorry(...savesize...)",ecyou.mayneedtoIbreak5yourtextintosmallersectionsandcompiletheseparately*.MFortunately5(sayItheTLcommentsontheoriginalfnpara.sty)thisisveryeasytodowithL5ffA͉TU>'ExX,IprovidedUUthatyouresetthefoGotnotecountertomakethejoinsseamless.XFirstwede neameansofhiding\parinacasewhereweneeditwithintheIdeclarationUUoftheparaoptionI16S\def\FN@unhbox@par#1{\unhbox#1\par}XW*eUUneedsometempGoraryboxesI17S\let\FN@tempboxa\@tempboxa I18S\newbox\FN@tempboxbI19S\newbox\FN@tempboxcXDe neUUtheparaoption {I20S%\typeout{Declaringpara}I21S\DeclareOption{para}{%{XW*eAwillpatchthesourceofL5ffA͉TU>'ExXforthis;Mwedon'tdothejobhere|we IsimplyUUseta agforthepGostambletodoitusingpatch.texXAnotherUUdirectcribfromtheTU>'ExXbGook:I22S\newskip\footglue\footglue=1emplus.3emminus.3emXThestandardclassessetthefoGotnotemark ushwiththetextofthefootnote,IbutUUthat'snotappropriateforparagraphfoGotnotes,we nd.XThere's:notmuch:pGointinpatchingthiscoGdefromtheoriginal,?sincetheonlyIthings$ ithasincommonwiththeoriginalarethefoGotnotemarkandthefootnoteItextUU(whichlastistheargument).I23S\long\def\@makefntext#1{\@makefnmark\nobreak\hskip.5em\relax#1}XW*eʧalsoneedtopatchtheoutputroutine'shandlingoffoGotnotes.ѾSincethisIisn't theonlyinstanceofthisrequirementinthispackqage,wesimplyseta agforIitUUtobGedonelater.I24S\@advance@macro\FN@outputflag1XW*eUUneedtorecordavqalueforthebaselineskipwheninfoGotnotes:I25S{\footnotesize\newdimen\footnotebaselineskip I26]\globalI27]\footnotebaselineskip=\normalbaselineskip}XNowUUwederiveafudgefactorfromthebaselineskipwe'vejustestablished^1|s:I28S\@tempdima=\footnotebaselineskip\multiply\@tempdimaby1024I29S\divide\@tempdimaby\columnwidth\multiply\@tempdimaby64I30S\xdef\fudgefactor{\strip@pt\@tempdima}I31S%\typeout{Donethat-\string\fudgefactoris\fudgefactor}I32S\def\makefootnoteparagraph{\unvbox\footins\makehboxofhboxesI33]\setbox\FN@tempboxa=\hbox{\unhbox\FN@tempboxa\removehboxes}IS\ffr J= "5-:Aacmr61LWJe2use\strip@ptwhicÎhisde nedforuseintheL#A TAEMXFd22cmmi8"%`kernel,mbutnotdo#3\relax I80p2\def\ft@page{0}%I81f\elseI82p2\expandafter\ifnum\ft@page<#3\relaxI83yw^\def\ft@page{#3}I84yw^\def\ft@foot{0}%I85f\fi\fi}%XifUUthe`actualpage'wasn'tnumeric,wesimplyreset\ft@pageI86ap{\def\ft@page{0}}%6<soXNowQadvqanceour`expGected'footnotenumber;ifQit'sdi erentfromwhatwould IbGe8typesetwithoutourintervention,qcreateamacro\ft@happ}'arent-page[iD3r-hnatur}'al-footnote[iIthatUUcontainsthenumbGerthatinfactneedstobetypeset.I87]\@advance@macro\ft@foot1 I88]\def\@tempa{#2}%I89]\ifx\@tempa\ft@foot\elseI90kJ\expandafter\xdef\csnameft@#1-#2\endcsname{\ft@foot}%I91]\fiI92]}XDon'trneedthatde nitioninthebGodyrofthecoGde(thoughsomethingsimilar IisUUresurrectedatenddoGcument).I93S\@onlypreamble\newfoot@markXAsimplebitofcoGdetodetectwhethertheargumentit'so eredisanumbGerI(atUUleasttotheextentofstartingwithadigit).XApparentUUexternalinterfaceis:I\@ifdigit{hp}'ossdigits!i5R}{hdigittextظi/Z}{hnon-digittextظiCI}I94S\def\@ifdigit#1{\expandafter\@digithelp\string#1\@digithelp}%XBehold, .apieceofhorriblecoGde,slowlyreducinginnumbGeroftokensasII nd waystoimproveit,8whichdoGesthegutsof}(\@ifdigit.(TheoriginalwasaIsequence,ofI\ifscomparingtoeachdigitinturn;thisoneatleastismorefun...)I95S\def\@digithelp#1#2\@digithelp{% I96]\ifnum`#1<`0I97f\@triple@expandafter\@secondoftwoI98]\elseI99f\ifnum`#1>`9E100p2\@triple@expandafter\@secondoftwoE101f\elseE102p2\@triple@expandafter\@firstoftwoE103f\fiE104]\fi}XSinceOweuse\@triple@expandafter,wehadbGetterde neit.a(IOthinkthe IkernelUUcoulddowithit,infact...)E105S\providecommand\@triple@expandafter{\expandafterE106]\expandafter\expandafter}X\enddoc@newfoot@mark~isusedtodetectchanngesattheendoftherun,Cwhen Ithenew.aux leisscanned.It'smostlythesameas\newfoot@mark,exceptatIitsUUlastgasp...E107S\def\enddoc@newfoot@mark#1#2#3{% E108]\@ifdigit{#3}{%E109f\expandafter\ifnum\ft@page>#3\relaxE110p2\def\ft@page{0}%E111f\elseE112p2\expandafter\ifnum\ft@page<#3\relaxE113yw^\def\ft@page{#3}E114yw^\def\ft@foot{0}%E115f\fi\fi}%E116ap{\def\ft@page{0}}%7F?soXIfour`expGected'footnotenumberisdi erentfromwhatwouldbGetypGesetwith- Iout8ourintervention,qcheck8therewasamacro\ft@happ}'arent-page[iD3r-hnatur}'al-footnote[iIcontainingUUthenumbGerthatinfactneedstobetypeset.E117]\@advance@macro\ft@foot1 E118]\def\@tempa{#2}%E119]\ifx\@tempa\ft@foot\elseE120f\expandafter\ifx\csnameft@#1-#2\endcsname\ft@footE121f\else\@tempswatrueE122f\fiE123]\fiE124]}XAtΩtheendofthedoGcument,rede ne\newfoot@marktopGerformacheckfor IfoGotnoteUUlabelsmisbehavingwhenthe.aux leisscanned:E125S\AtEndDocument{%E126]\def\ft@page{0}E127]\def\ft@foot{0}E128]\let\newfoot@mark\enddoc@newfoot@markE129]}XMarkwe'vepatchingtodo,sandarrangethattheresetlist(ofV\c@pagetakes ImostUUofthestrain...E130S\@advance@macro\PP@footflag9E131S\@addtoreset{footnote}{page}%E132S}!čI7aLTheffbottomoptionIAllthisneedstodoistoresetthevqalueof_\FN@outputflagtobGenegative.2Thisis IsimplyKbysubtractingtwofromit(whichdoGesn'ta ectitsoddness...,orKshouldIthatUUbGeo}'ddity}?)E133S\DeclareOption{bottom}{% E134]\@advance@macro\FN@outputflag{-2}E135S}I8aLTheffmarginaloptionIAgain,UUtheproGcessingoftheoptionisprettytrivial:E136S\DeclareOption{marginal}{%E137]\footnotemargin-0.8em\relaxE138S}I9aLTheffflushmarginoptionIAgain,UUtheproGcessingoftheoptionisprettytrivial:E139S\DeclareOption{flushmargin}{%E140]\footnotemargin0pt\relaxE141S}8 Q_soI10ifdTheffnoruleoptionIPrettyUUsimpletoGo...E142S\DeclareOption{norule}{% E143]\renewcommand\footnoterule{}%E144]\advance\skip\footins4\p@\@plus2\p@\relaxE145S}!čI11ifdTheffstartoftheendgameIExerciseUUtheoptionsthattheuserhasrequested...E146S\ProcessOptionsI12ifdTheffoutputroutinehacksINow;dodjweneedtomessabGoutwiththeoutputroutine?Ifeitherfnparaor IbottomJhasbGeeninvoked,LYweJdo.n Inordertodothisjob,weuseDavidKastrup'sIpatch.tex:E147S\expandafter\@tempcntb\PP@footflag\relax E148S\@advance@macro\FN@outputflag\@tempcntb\relaxE149S%Werelyon\@advance@macrotoset\@tempcntaforusE150S\ifnum\@tempcnta=0E151S\elseE152S\advance\@tempcnta-\@tempcntb\relaxI...qsoUUwe'vepatchingtodo. XSincepatchwon'tletuscomparebraces(forobviousreasons),butmoresig-Ini cantlywon'tallowususeof\bgroupor\egroup,weneedprivqatecopiesoftheIbraceUUcharactersforoneofourpatches:E153S\let\FN@obrace{ E154S\let\FN@cbrace}%thishasthemerit(atleast)ofsatisfyingemacs...XNowUUwegetthepatcher:E155S\input{patch}XNowUUweneedtodoourpatchesandthentogetoutoftheway*.E156S\ifnum\FN@outputflag<0XOptionUUbGottomwasrequested. XIn-'ExXbGook.E176\penalty-10\relax E177\hskip\footglueE178\FN@cbrace%endof\@makefntextparameterE179yw^\FN@cbrace%endof\hboxE180kJ\dp\FN@tempboxa=0pt\ht\FN@tempboxa=\fudgefactor\wd\FN@tempboxaE181kJ\box\FN@tempboxaE182kJ}}E183S\fiXFinally*,$do=.weneedtopatch\footnote? )SThisissignalledbysetting I\PP@footflagDtoanon-zerovqalue,?andweset\@tempcntbtothatbGeforetheIlastUUpatchingsession:E184S\ifnum\@tempcntb=0 E185S\elseE186S\gpatch\footnote{}%Notethat\footnotedoesn'thavearguments,E187:%whateveritsaysinthebook...E188:{\@footnotemark{\PP@footnote\@footnotemark}}E189S\gpatch\footnotemark{}{\@footnotemark{\PP@footnote\@footnotemark}}E190S\fiI&effr J= "5-:2LWJell,XanegativÎep0ptE198p2\hboxto1.8em{\hss\@makefnmark}%E199f\elseE200p2\ifdim\footnotemargin=0ptE201yw^\llap{$^{\@thefnmark}$}%E202p2\elseE203yw^\llap{\hboxto-\footnotemargin{$^{\@thefnmark}$\hss}}%E204p2\fiE205f\fiE206f#1}E207S\fiE208Sh$5" cmmi9=pack9age#g i11n ; .#fcmti8,߆Tff cmtt12+': cmti10)m#R cmss10&ow cmss9% cmsy9$5" cmmi9"ߤN cmtt9!p0J cmsl10 ߆T cmtt12N cmbx12 cmmi10K`y cmr10ٓRcmr7r