ebook img

TEX by topic: a TEXnician's reference PDF

287 Pages·1992·1.301 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview TEX by topic: a TEXnician's reference

T X BY TOPIC, A T XNICIAN’S REFERENCE E E VICTOREIJKHOUT∗ ELECTRONICVERSION1.0,DECEMBER2001 ∗ This is – apart from minor changes – the full text of the book TEX by Topic, copyright 1991- 2001VictorEijkhout.Thisbookwasprintedin1991byAddison-WesleyUK,ISBN0-201-56882-9, reprinted in 1993. This book may be copied; the pdf file of this book may be printed and given away,anditmaybeincludedinarchivesandonwebsites;thebookmaybedistributedinunaltered formbothonpaperandelectronicmedia.Youarenotallowedtomakeanychangestothefileorto reverseengineeritssource;youarenotallowedtochargeforitsdistribution–whetherinphysicalor electronicform–beyondreasonablematerialcosts. Ifyouhavecommentsorwanttoexpressyourappreciationthatyouaregettingthisbookthatformerly soldfor≈$30forfree,pleasevisithttp://www.eijkhout.net/tbt/.Ifyoualreadymadeadonation,thank you.Youareacredittoyourspecies. Contents 1 TheStructureoftheTEXProcessor 1 1.1 FourTEXprocessors 1 1.2 Theinputprocessor 2 1.2.1 Characterinput 2 1.2.2 Two-levelinputprocessing 2 1.3 Theexpansionprocessor 3 1.3.1 Theprocessofexpansion 3 1.3.2 Specialcases:\expandafter,\noexpand,and\the 3 1.3.3 Bracesintheexpansionprocessor 4 1.4 Theexecutionprocessor 4 1.5 Thevisualprocessor 5 1.6 Examples 5 1.6.1 Skippedspaces 5 1.6.2 Internalquantitiesandtheirrepresentations 6 2 CategoryCodes andInternalStates 7 2.1 Introduction 7 2.2 Initialprocessing 7 2.3 Categorycodes 8 2.4 Fromcharacterstotokens 10 2.5 Theinputprocessorasafinitestateautomaton 10 2.5.1 StateN:newline 10 2.5.2 StateS:skippingspaces 10 2.5.3 StateM:middleofline 10 2.6 Accessingthefullcharacterset 11 2.7 Transitionsbetweeninternalstates 11 2.7.1 0:escapecharacter 11 2.7.2 1–4,7–8,11–13:non-blankcharacters 12 2.7.3 5:endofline 12 2.7.4 6:parameter 12 2.7.5 7:superscript 12 2.7.6 9:ignoredcharacter 12 2.7.7 10:space 12 2.7.8 14:comment 12 2.7.9 15:invalid 13 2.8 Lettersandothercharacters 13 2.9 The\partoken 14 2.10 Spaces 14 2.10.1 Skippedspaces 14 2.10.2 Optionalspaces 15 1 Contents 2.10.3 Ignoredandobeyedspaces 15 2.10.4 Moreignoredspaces 16 2.10.5 hspacetokeni 16 2.10.6 Controlspace 17 2.10.7 ‘ ’ 17 2.11 Moreaboutlineends 17 2.11.1 Obeylines 17 2.11.2 Changingthe\endlinechar 18 2.11.3 Moreremarksabouttheend-of-linecharacter 19 2.12 Moreabouttheinputprocessor 19 2.12.1 Theinputprocessorasaseparateprocess 19 2.12.2 Theinputprocessornotasaseparateprocess 20 2.12.3 Recursiveinvocationoftheinputprocessor 20 2.13 The@convention 20 3 Characters 21 3.1 Charactercodes 21 3.2 Controlsequencesforcharacters 22 3.3 Denotingcharacterstobetypeset:\char 22 3.3.1 Implicitcharactertokens:\let 23 3.4 Accents 24 3.5 Testingcharacters 25 3.6 Uppercaseandlowercase 25 3.6.1 Uppercaseandlowercasecodes 25 3.6.2 Uppercaseandlowercasecommands 26 3.6.3 Uppercaseandlowercaseformsofkeywords 26 3.6.4 Creativeuseof\uppercaseand\lowercase 26 3.7 Codesofacharacter 27 3.8 Convertingtokensintocharacterstrings 27 3.8.1 Outputofcontrolsequences 27 3.8.2 Categorycodesofa\string 28 4 Fonts 29 4.1 Fonts 29 4.2 Fontdeclaration 30 4.2.1 Fontsandtfmfiles 30 4.2.2 Queryingthecurrentfontandfontnames 30 4.2.3 \nullfont 31 4.3 Fontinformation 31 4.3.1 Fontdimensions 31 4.3.2 Kerning 32 4.3.3 Italiccorrection 32 4.3.4 Ligatures 32 4.3.5 Boundaryligatures 33 5 Boxes 34 5.1 Boxes 35 5.2 Boxregisters 35 5.2.1 Allocation:\newbox 35 5.2.2 Usage:\setbox,\box,\copy 36 5.2.3 Testing:\ifvoid,\ifhbox,\ifvbox 36 5.2.4 The\lastbox 36 5.3 Naturaldimensionsofboxes 37 2 VictorEijkhout–TEXbyTopic Contents 5.3.1 Dimensionsofcreatedhorizontalboxes 37 5.3.2 Dimensionsofcreatedverticalboxes 37 5.3.3 Examples 38 5.4 Moreaboutboxdimensions 39 5.4.1 Predetermineddimensions 39 5.4.2 Changestoboxdimensions 40 5.4.3 Movingboxesaround 40 5.4.4 Boxdimensionsandboxplacement 40 5.4.5 Boxesandnegativeglue 41 5.5 Overfullandunderfullboxes 42 5.6 Openingandclosingboxes 42 5.7 Unboxing 43 5.8 Textinboxes 44 5.9 Assortedremarks 44 5.9.1 Forgettingthe\box 44 5.9.2 Special-purposeboxes 45 5.9.3 Theheightofaverticalboxinhorizontalmode 45 5.9.4 Moresubtletieswithverticalboxes 45 5.9.5 Hangingthe\lastboxbackinthelist 46 5.9.6 Dissectingparagraphswith\lastbox 46 6 Horizontaland VerticalMode 48 6.1 Horizontalandverticalmode 48 6.1.1 Horizontalmode 48 6.1.2 Verticalmode 49 6.2 Horizontalandverticalcommands 49 6.3 Theinternalmodes 50 6.3.1 Restrictedhorizontalmode 50 6.3.2 Internalverticalmode 50 6.4 Boxesandmodes 51 6.4.1 Whatboxdoyouuseinwhatmode? 51 6.4.2 Whatmodeholdsinwhatbox? 51 6.4.3 Mode-dependentbehaviourofboxes 51 6.5 Modesandglue 51 6.6 Migratingmaterial 52 6.6.1 \vadjust 52 6.7 Testingmodes 52 7 Numbers 54 7.1 Numbersandhnumberis 54 7.2 Integers 54 7.2.1 Denotations:integers 55 7.2.2 Denotations:characters 55 7.2.3 Internalintegers 56 7.2.4 Internalintegers:othercodesofacharacter 57 7.2.5 hspecialintegeri 57 7.2.6 Otherinternalquantities:coersiontointeger 57 7.2.7 Trailingspaces 57 7.3 Numbers 57 7.4 Integerregisters 58 7.5 Arithmetic 58 VictorEijkhout–TEXbyTopic 3 Contents 7.5.1 Arithmeticstatements 59 7.5.2 Floating-pointarithmetic 59 7.5.3 Fixed-pointarithmetic 59 7.6 Numbertesting 59 7.7 Remarks 60 7.7.1 Characterconstants 60 7.7.2 Expandingtoofar/howfar 60 8 DimensionsandGlue 62 8.1 Definitionofhglueiandhdimeni 62 8.1.1 Definitionofdimensions 63 8.1.2 Definitionofglue 64 8.1.3 Conversionofhglueitohdimeni 64 8.1.4 Registersfor\dimenand\skip 65 8.1.5 Arithmetic:addition 65 8.1.6 Arithmetic:multiplicationanddivision 66 8.2 Moreaboutdimensions 66 8.2.1 Unitsofmeasurement 66 8.2.2 Dimensiontesting 67 8.2.3 Defineddimensions 67 8.3 Moreaboutglue 67 8.3.1 Stretchandshrink 67 8.3.2 Gluesetting 69 8.3.3 Badness 69 8.3.4 Glueandbreaking 69 8.3.5 \kern 70 8.3.6 Glueandmodes 70 8.3.7 Thelastglueiteminalist:backspacing 70 8.3.8 Examplesofbackspacing 71 8.3.9 Glueintraceoutput 71 9 RulesandLeaders 73 9.1 Rules 73 9.1.1 Ruledimensions 74 9.2 Leaders 74 9.2.1 Ruleleaders 75 9.2.2 Boxleaders 76 9.2.3 Evenlyspacedleaders 76 9.3 Assortedremarks 77 9.3.1 Rulesandmodes 77 9.3.2 Endingaparagraphwithleaders 77 9.3.3 Leadersandboxregisters 77 9.3.4 Outputinleaderboxes 78 9.3.5 Boxleadersintraceoutput 78 9.3.6 Leadersandshiftedmargins 78 10 Grouping 79 10.1 Thegroupingmechanism 79 10.2 Localandglobalassignments 80 10.3 Groupdelimiters 80 10.4 Moreaboutbraces 81 10.4.1 Bracecounters 81 10.4.2 Thebraceasatoken 81 4 VictorEijkhout–TEXbyTopic Contents 10.4.3 Openandclosingbracecontrolsymbols 82 11 Macros 83 11.1 Introduction 83 11.2 Layoutofamacrodefinition 84 11.3 Prefixes 84 11.4 Thedefinitiontype 85 11.5 Theparametertext 85 11.5.1 Undelimitedparameters 85 11.5.2 Delimitedparameters 86 11.5.3 Exampleswithdelimitedarguments 86 11.5.4 Emptyarguments 88 11.5.5 Themacroparametercharacter 88 11.5.6 Bracedelimiting 89 11.6 Constructionofcontrolsequences 89 11.7 Tokenassignmentsby\letand\futurelet 90 11.7.1 \let 90 11.7.2 \futurelet 90 11.8 Assortedremarks 91 11.8.1 Activecharacters 91 11.8.2 Macrosversusprimitives 91 11.8.3 Tailrecursion 91 11.9 Macrotechniques 92 11.9.1 Unknownnumberofarguments 92 11.9.2 Examiningtheargument 93 11.9.3 Optionalmacroparameterswith\futurelet 95 11.9.4 Two-stepmacros 95 11.9.5 Acommentenvironment 96 12 Expansion 98 12.1 Introduction 98 12.2 Ordinaryexpansion 98 12.3 Reversingexpansionorder 99 12.3.1 Onestepexpansion:\expandafter 99 12.3.2 Totalexpansion:\edef 100 12.3.3 \afterassignment 100 12.3.4 \aftergroup 101 12.4 Preventingexpansion 102 12.4.1 \noexpand 102 12.4.2 \noexpandandactivecharacters 102 12.5 \relax 103 12.5.1 \relaxand\csname 103 12.5.2 Preventingexpansionwith\relax 104 12.5.3 TEXinsertsa\relax 104 12.5.4 Thevalueofnon-macros;\the 105 12.6 Examples 105 12.6.1 Expandingafter 105 12.6.2 Defininginsidean\edef 106 12.6.3 Expansionand\write 107 12.6.4 Controlledexpansioninsidean\edef 108 12.6.5 Multiplepreventionofexpansion 108 12.6.6 Moreexampleswith\relax 108 VictorEijkhout–TEXbyTopic 5 Contents 12.6.7 Example:categorycodesavingandrestoring 109 12.6.8 Combining\aftergroupandboxes 110 12.6.9 Moreexpansion 110 13 Conditionals 111 13.1 Theshapeofconditionals 111 13.2 Characterandcontrolsequencetests 112 13.2.1 \if 112 13.2.2 \ifcat 112 13.2.3 \ifx 112 13.3 Modetests 113 13.4 Numericaltests 113 13.5 Othertests 114 13.5.1 Dimensiontesting 114 13.5.2 Boxtests 114 13.5.3 I/Otests 114 13.5.4 Casestatement 114 13.5.5 Specialtests 115 13.6 The\newifmacro 115 13.7 Evaluationofconditionals 116 13.8 Assortedremarks 117 13.8.1 Thetestgobblesuptokens 117 13.8.2 Thetestwantstogobbleupthe\elseor\fi 117 13.8.3 Macrosandconditionals;theuseof\expandafter 118 13.8.4 Incorrectmatching 119 13.8.5 Conditionalsandgrouping 119 13.8.6 Atrick 120 13.8.7 Moreexamplesofexpansioninconditionals 120 14 TokenLists 123 14.1 Tokenlists 123 14.2 Useoftokenlists 123 14.3 htokenparameteri 124 14.4 Tokenlistregisters 124 14.5 Examples 125 14.5.1 Operationsontokenlists:stackmacros 125 14.5.2 Executingtokenlists 126 15 BaselineDistances 128 15.1 Interlineglue 128 15.2 Theperceiveddepthofboxes 130 15.3 Terminology 130 15.4 Additionalremarks 131 16 ParagraphStart 132 16.1 Whendoesaparagraphstart 132 16.2 Whathappenswhenaparagraphstarts 133 16.3 Assortedremarks 133 16.3.1 Startingaparagraphwithabox 133 16.3.2 Startingaparagraphwithagroup 133 16.4 Examples 134 16.4.1 Stretchableindentation 134 16.4.2 Suppressingindentation 134 16.4.3 Anindentationscheme 134 6 VictorEijkhout–TEXbyTopic Contents 16.4.4 Aparagraphskipscheme 135 17 ParagraphEnd 137 17.1 Thewayparagraphsend 137 17.1.1 The\parcommandandthe\partoken 138 17.1.2 Paragraphfilling:\parfillskip 138 17.2 Assortedremarks 138 17.2.1 Endingaparagraphandagroupatthesametime 138 17.2.2 Endingaparagraphwith\hfill\break 139 17.2.3 Endingaparagraphwitharule 139 17.2.4 Nopagebreaksinbetweenparagraphs 139 17.2.5 Finite\parfillskip 139 17.2.6 Aprecautionforparagraphsthatdonotindent 140 18 ParagraphShape 141 18.1 Thewidthoftextlines 141 18.2 Shapeparameters 141 18.2.1 Hangingindentation 141 18.2.2 Generalparagraphshapes:\parshape 142 18.3 Assortedremarks 143 18.3.1 Centredlastlines 143 18.3.2 Indentingintothemargin 143 18.3.3 Hangaparagraphfromanobject 144 18.3.4 Anotherapproachtohangingindentation 144 18.3.5 Hangingindentationversus\leftskipshifting 145 18.3.6 Moreexamples 145 19 LineBreaking 146 19.1 Paragraphbreakcostcalculation 147 19.1.1 Badness 147 19.1.2 Penaltiesandotherbreaklocations 147 19.1.3 Demerits 148 19.1.4 Thenumberoflinesofaparagraph 149 19.1.5 Betweenthelines 149 19.2 Theprocessofbreaking 149 19.2.1 Threepasses 150 19.2.2 Tolerancevalues 150 19.3 Discretionaries 150 19.3.1 Hyphensanddiscretionaries 150 19.3.2 Examplesofdiscretionaries 151 19.4 Hyphenation 151 19.4.1 Startofaword 152 19.4.2 Endofaword 152 19.4.3 TEX2versusTEX3 153 19.4.4 Patternsandexceptions 153 19.5 Switchinghyphenationpatterns 153 20 Spacing 155 20.1 Automaticinterwordspace 155 20.2 Userinterwordspace 156 20.3 Controlspaceandtie 156 20.4 Moreonthespacefactor 157 20.4.1 Spacefactorassignments 157 20.4.2 Punctuation 157 VictorEijkhout–TEXbyTopic 7 Contents 20.4.3 Othernon-letters 158 20.4.4 Otherinfluencesonthespacefactor 158 21 CharactersinMathMode 159 21.1 Mathematicalcharacters 159 21.2 Delimiters 160 21.2.1 Delimitercodes 161 21.2.2 Explicit\delimitercommands 161 21.2.3 Findingadelimiter;successors 161 21.2.4 \big,\Big,\bigg,and\Bigg 162 21.3 Radicals 162 21.4 Mathaccents 163 22 FontsinFormulas 164 22.1 Determiningthefontofacharacterinmathmode 164 22.2 Initialfamilysettings 164 22.3 Familydefinition 165 22.4 Somespecificfontchanges 165 22.4.1 ChangethefontofordinarycharactersanduppercaseGreek 165 22.4.2 ChangeuppercaseGreekindependentoftextfont 166 22.4.3 ChangethefontoflowercaseGreek 166 22.5 Assortedremarks 166 22.5.1 Newfontsinformulas 166 22.5.2 Evaluatingthefamilies 167 23 MathematicsTypesetting 168 23.1 Mathmodes 169 23.2 Stylesinmathmode 169 23.2.1 Superscriptsandsubscripts 170 23.2.2 Choiceofstyles 170 23.3 Classesofmathematicalobjects 171 23.4 Largeoperatorsandtheirlimits 171 23.5 Verticalcentring:\vcenter 172 23.6 Mathematicalspacing:muglue 172 23.6.1 Classificationofmuglue 173 23.6.2 Muskipregisters 173 23.6.3 Otherspacesinmathmode 174 23.7 Generalizedfractions 174 23.8 Underlining,overlining 175 23.9 Linebreakinginmathformulas 175 23.10 Fontdimensionsoffamilies2and3 175 23.10.1 Symbolfontattributes 175 23.10.2 Extensionfontattributes 176 23.10.3 Example:subscriptlowering 177 24 DisplayMath 178 24.1 Displays 178 24.2 Displaysinparagraphs 179 24.3 Verticalmaterialarounddisplays 179 24.4 Gluesettingofthedisplaymathlist 180 24.5 Centringthedisplayformula:displacement 180 24.6 Equationnumbers 180 24.6.1 Ordinaryequationnumbers 181 24.6.2 Theequationnumberonaseparateline 181 8 VictorEijkhout–TEXbyTopic Contents 24.7 Non-centreddisplays 181 25 Alignment 183 25.1 Introduction 183 25.2 Horizontalandverticalalignment 183 25.2.1 Horizontalalignments:\halign 184 25.2.2 Verticalalignments:\valign 184 25.2.3 Materialbetweenthelines:\noalign 184 25.2.4 Sizeofthealignment 185 25.3 Thepreamble 185 25.3.1 Infinitepreambles 185 25.3.2 Bracecountinginpreambles 186 25.3.3 Expansioninthepreamble 186 25.3.4 \tabskip 186 25.4 Thealignment 187 25.4.1 Readinganentry 187 25.4.2 Alternatespecifications:\omit 187 25.4.3 Spanningacrossmultiplecolumns:\span 188 25.4.4 Rulesinalignments 188 25.4.5 Endofaline:\crand\crcr 189 25.5 Example:mathalignments 189 26 PageShape 191 26.1 Thereferencepointforglobalpositioning 191 26.2 \topskip 191 26.3 Pageheightanddepth 192 27 PageBreaking 193 27.1 Thecurrentpageandtherecentcontributions 193 27.2 Activatingthepagebuilder 194 27.3 Pagelengthbookkeeping 194 27.4 Breakpoints 195 27.4.1 Possiblebreakpoints 195 27.4.2 Breakpointpenalties 195 27.4.3 Breakpointcomputation 196 27.5 \vsplit 197 27.6 Examplesofpagebreaking 198 27.6.1 Fillingupapage 198 27.6.2 Determiningthebreakpoint 198 27.6.3 Thepagebuilderafteraparagraph 199 28 OutputRoutines 200 28.1 The\outputtokenlist 200 28.2 Outputand\box255 201 28.3 Marks 201 28.4 Assortedremarks 203 28.4.1 Hazardsinnon-trivialoutputroutines 203 28.4.2 Pagenumbering 203 28.4.3 HeadlinesandfootlinesinplainTEX 203 28.4.4 Example:nowidowlines 203 28.4.5 Example:noindentationtopofpage 204 28.4.6 Moreexamplesofoutputroutines 205 29 Insertions 206 29.1 Insertionitems 206 VictorEijkhout–TEXbyTopic 9

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.