﻿
Chapter2. CategoryCodesandInternalStates
{\catcode‘\^^M=13 %
\gdef\obeylines{\catcode‘\^^M=13 \def^^M{\par}}%
}
Emptylinesintheinputarenottakenintoaccountinthisdeﬁnition:thesedisappear,be-
causetwoconsecutive\partokensare(inthiscase)equivalenttoone.Aslightlymodiﬁed
deﬁnitionforthelineendas
\def^^M{\par\leavevmode}
remediesthis:noweverylineendforcesT
E
Xtostartaparagraph.Foremptylinesthiswill
thenbeanemptyparagraph.
2.11.2 Changingthe\endlinechar
Occasionallyyoumaywanttochangethe\endlinechar,orthe\catcodeoftheordi-
narylineterminator^^M,forinstancetoobtainspecialeffectssuchasmacroswherethe
argumentisterminatedbythelineend.Seepage122foraworked-outexample.
Thereareacoupleoftraps.Considerthefollowing:
{\catcode‘\^^M=12 \endlinechar=‘\^^J \catcode‘\^^J=5
...
... }
Thiscausesunintendedoutputofbothcharacter13(^^M)and10(^^J),causedbytheline
terminatorsoftheﬁrstandlastline.
Terminatingtheﬁrstandlastlinewithacommentworks,butreplacingtheﬁrstlinebythe
twolines
{\endlinechar=‘\^^J \catcode‘\^^J=5
\catcode‘\^^M=12
isalsoasolution.
Ofcourse, in many casesit isnotnecessary to substituteanotherend-of-linecharacter;
amuchsimplersolutionisthentoput
\endlinechar=-1
whichtreatsalllinesasiftheyendwithacomment.
ThecharacterthatT
E
Xappendsattheendofaninputlineistreatedlikeanyothercharacter.
Usuallyoneisnotawareofthis,asitscategorycodeisspecial,butthereareafewwaysto
letitbeprocessedinanunusualway.
Terminatinganinputlinewith^^will(ordinarily,when\endlinechar
is13)give‘M’intheoutput,whichisthe
ASCII
characterwithcode13+64.
If\^^Mhasbeendeﬁned,terminatinganinputlinewithabackslashwill
executethiscommand.Theplainformatdeﬁnes
\def\^^M{\ }
whichmakesa‘controlreturn’equivalenttoacontrolspace.
40
VictorEijkhout–T
E
XbyTopic
Delete a page from a pdf online - remove PDF pages in C#.net, ASP.NET, MVC, Ajax, WinForms, WPF
Provides Users with Mature Document Manipulating Function for Deleting PDF Pages
delete page on pdf document; delete a page from a pdf reader
Delete a page from a pdf online - VB.NET PDF Page Delete Library: remove PDF pages in vb.net, ASP.NET, MVC, Ajax, WinForms, WPF
Visual Basic Sample Codes to Delete PDF Document Page in .NET
delete pages from pdf acrobat; delete pdf pages ipad
2.12.1 Theinputprocessorasaseparateprocess
T
E
X’slevelsofprocessingareallworkingatthesametimeandincrementally,butconcep-
tuallytheycanoftenbeconsideredtobeseparateprocessesthateachacceptthecompleted
outputofthepreviousstage.Thejugglingwithspacesprovidesaniceillustrationforthis.
Considerthedeﬁnition
\def\DoAssign{\count42=800}
andthecall
\DoAssign 0
Theinputprocessor,thepartofT
E
Xthatbuildstokens,inscanningthiscallskipsthespace
beforethezero,sotheexpansionofthiscallis
\count42=8000
number800,so800isassignedandthezeroisprinted’.Notethatthesamewouldhappen
ifthezeroappearedonthenextline.
fromthatforskippedspaces:
\def\c.{\relax}
a\c.b
expandsto
a\relaxb
whichgivesasoutput
‘ab’
becausespacesafterthe\relaxcontrolsequenceareonlyskippedwhenthelineisﬁrst
\def\c.{\ignorespaces}
a\c. b
ontheotherhand,expandsto
a\ignorespacesb
Executingthe\ignorespacescommandremovesthesubsequentspacetoken,sotheout-
putis
‘ab’.
frombeingskipped.
2.12.2 Theinputprocessornotasaseparateprocess
ConsideringthetokenizingofT
E
Xtobeaseparateprocessisaconvenientview,butsome-
VictorEijkhout–T
E
XbyTopic
41
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
Provides you with examples for adding an (empty) page to a PDF and adding empty pages You may feel free to define some continuous PDF pages and delete.
delete page in pdf; delete blank pages in pdf online
C# HTML5 PDF Viewer SDK to view PDF document online in C#.NET
RasterEdge. PRODUCTS: ONLINE DEMOS: Online HTML5 Document Viewer; Online XDoc.PDF C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages;
Chapter2. CategoryCodesandInternalStates
\catcode‘\^^M=13{}
makesthelineendactive,andsubsequentlygivesan‘undeﬁnedcontrolsequence’errorfor
thelineendofthislineitself.Executionofthecommandsonthelinethusinﬂuencesthe
scanningprocessofthatsameline.
Bycontrast,
\catcode‘\^^M=13
doesnotgiveanerror.Thereasonforthisisthat T
E
scanningthenumber13;thatis,atatimewhentheassignmenthasnotbeenperformedyet.
Thelineendisthenconvertedtotheoptionalspacecharacterdelimitingthenumbertobe
assigned.
2.12.3 Recursiveinvocationoftheinputprocessor
describedassomethingsimilartothelumpingtogetheroflettersintoacontrolsequence
token.Realityissomewhatmorecomplicatedthanthis.T
E
X’stokenscanningmechanism
isinvokedbothfor input fromﬁleand forinput fromlistsoftokenssuch asthemacro
deﬁnition.Onlyintheﬁrstcaseistheterminologyofinternalstatesapplicable.
Macroparametercharactersaretreatedthesameinbothcases,however.Ifthiswerenot
thecaseitwouldnotbepossibletowritethingssuchas
\def\a{\def\b{\def\c####1{####1}}}
Seepage114foranexplanationofsuchnesteddeﬁnitions.
2.13 The@convention
AnyonewhohaseverbrowsedthrougheithertheplainformatortheLAT
E
Xformatwillhave
noticedthatalotofcontrolsequencescontainan‘at’sign:@.Thesearecontrolsequences
thataremeanttobeinaccessibletotheordinaryuser.
Nearthebeginningoftheformatﬁlestheinstruction
\catcode‘@=11
occurs,makingtheatsignintoaletter,meaningthatitcanbeusedincontrolsequences.
\catcode‘@=12
Nowwhyisitthatuserscannotcallacontrolsequencewithanatsigndirectly,although
theycancallmacrosthatcontainlotsofthose‘at-deﬁnitions’?Thereasonisthatthecontrol
sequencescontainingan@areinternalizedbyT
E
Xatdeﬁnitiontime,afterwhichtheyarea
token,notastringofcharacters.Macroexpansionthenjustinsertssuchtokens,andatthat
timethecategorycodesoftheconstituentcharactersdonotmatteranymore.
42
VictorEijkhout–T
E
XbyTopic
C# PDF Page Insert Library: insert pages into PDF file in C#.net
Free components and online source codes for .NET framework 2.0+. PDF document files by C# code, how to rotate PDF document page, how to delete PDF page using C#
delete pages from pdf preview; delete pages on pdf online
VB.NET PDF- View PDF Online with VB.NET HTML5 PDF Viewer
RasterEdge. PRODUCTS: ONLINE DEMOS: Online HTML5 Document Viewer; Online XDoc.PDF C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages;
delete page on pdf reader; delete blank page from pdf
Chapter3
Characters
Internally,T
E
Xrepresentscharactersbytheir(integer)charactercode.Thischaptertreats
thosecodes,andthecommandsthathaveaccesstothem.
\char Explicitdenotationofacharactertobetypeset.
\chardef Deﬁneacontrolsequencetobeasynonymforacharactercode.
\accent Commandtoplaceaccentcharacters.
\if Testequalityofcharactercodes.
\ifx Testequalityofbothcharacterandcategorycodes.
\let Deﬁneacontrolsequencetobeasynonymofatoken.
\uccode Queryorsetthecharactercodethatistheuppercasevariantofagivencode.
\lccode Queryorsetthecharactercodethatisthelowercasevariantofagivencode.
\uppercase Convertthegeneraltextargumenttoitsuppercaseform.
\lowercase Convertthegeneraltextargumenttoitslowercaseform.
\string Convertatokentoastringofoneormorecharacters.
\escapechar Numberofthecharacterthatistobeusedfortheescapecharacterwhen
controlsequencesarebeingconvertedintocharactertokens.IniT
E
Xdefault:92(\).
3.1
Charactercodes
ConceptuallyitiseasiesttothinkthatT
E
Xworkswithcharactersinternally,butinfactT
E
X
workswithintegers:the‘charactercodes’.
Thewaycharactersareencodedinacomputermaydifferfromsystemtosystem.Therefore
T
E
theuserterminal)isconvertedtoacharactercodeaccordingtothecharactercodetable.
Acategorycodeisthenassignedbasedonthis(seeChapter2).Thecharactercodetableis
basedonthe7-bit
ASCII
tablefornumbersunder128(seeChapter38).
Thereisanexplicitconversionbetweencharacters(better:charactertokens)andcharacter
codesusingtheleftquote(grave,backquote)character‘:atallplaceswhereT
E
Xexpects
anumberyoucanusetheleftquotefollowedbyacharactertokenorasingle-character
controlsequence.Thusboth\count‘aand\count‘\aaresynonymsfor\count97.See
alsoChapter7.
43
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
in VB.NET. Ability to create a blank PDF page with related by using following online VB.NET source code. Support .NET WinForms, ASP
cut pages out of pdf; delete blank pages in pdf
VB.NET PDF - Convert PDF Online with VB.NET HTML5 PDF Viewer
RasterEdge. PRODUCTS: ONLINE DEMOS: Online HTML5 Document Viewer; Online XDoc.PDF C# File: Split PDF; C# Page: Insert PDF pages; C# Page: Delete PDF pages;
add and delete pages in pdf online; delete page pdf online
Chapter3. Characters
Thepossibilityofasingle-charactercontrolsequenceisnecessaryincertaincasessuchas
whichwouldbemisunderstoodifthebackslashwereleftout.Forinstance
\catcode‘%=11
wouldconsiderthe=11tobeacomment.Single-charactercontrolsequencescanbeformed
fromcharacterswithanycategorycode.
Aftertheconversiontocharactercodesanyconnectionwithexternalrepresentationshas
disappeared.Ofcourse,formostcharactersthevisibleoutputwill‘equal’theinput(thatis,
an‘a’causesan‘a’).Thereareexceptions,however,evenamongthecommonsymbols.In
theComputerModernromanfontsthereareno‘lessthan’and‘greaterthan’signs,sothe
input‘<>’willgive‘¡¿’intheoutput.
InordertomakeT
E
Xmachineindependentattheoutputside,thecharactercodesarealso
usedinthedviﬁle:opcodesn=0...127denotesimplytheinstruction‘takecharactern
in[23].
3.2
Controlsequencesforcharacters
Thereareanumberofwaysinwhichacontrolsequencecandenoteacharacter.The\char
commandspeciﬁesacharactertobetypeset;the\letcommandintroducesasynonymfor
acharactertoken,thatis,thecombinationofcharactercodeandcategorycode.
3.3
Denotingcharacterstobetypeset:\char
Characterscanbedenotednumerically by, forexample, \char98.This commandtells
T
E
construction.
\char"62.Notethat\char’’62isincorrect; theprocessthatreplacestwo quotesby a
doublequoteworksatalaterstageofprocessing(thevisualprocessor)thannumberscan-
ning(theexecutionprocessor).
Becauseoftheexplicitconversiontocharactercodesbythebackquotecharacteritisalso
possibletogeta‘b’ –providedthatyou areusingafontorganizedabitlikethe
ASCII
table–with\char‘bor\char‘\b.
The\charcommandlookssuperﬁciallyabitlikethe^^substitutionmechanism(Chap-
ter2).Bothmechanismsaccesscharacterswithoutdirectlydenotingthem.However,the
^^mechanismoperatesinaveryearlystageofprocessing(intheinputprocessorofT
E
X,
butbeforecategorycodeassignment);the\charcommand,ontheotherhand,comesin
theﬁnalstagesofprocessing.Ineffectitsays‘typesetcharacternumberso-and-so’.
44
VictorEijkhout–T
E
XbyTopic
VB.NET PDF - Annotate PDF Online with VB.NET HTML5 PDF Viewer
Ability to insert a text note after selected text. Allow users to draw freehand shapes on PDF page. VB.NET HTML5 PDF Viewer: Annotate PDF Online.
best pdf editor delete pages; delete page from pdf
C# PDF remove image library: remove, delete images from PDF in C#.
Delete and remove all image objects contained in a specific to remove a specific image from PDF document page. Free .NET PDF SDK library download and online C#
add and delete pages from pdf; delete pages pdf online
3.3. Denotingcharacterstobetypeset:\char
Thereisaconstructiontoletacontrolsequencestandforsomecharactercode:the com-
mand.Thesyntaxofthisis
\chardefcontrolsequenceequalsnumber,
wherethenumbercanbeanexplicitrepresentationoracountervalue,butitcanalsobe
acharactercodeobtained using theleft quotecommand (seeabove; thefull deﬁnition
of number is given in Chapter7). In theplain format thelatter possibilityisused in
deﬁnitionssuchas
\chardef\%=‘\%
whichcouldhavebeengivenequivalentlyas
\chardef\%=37
Afterthiscommand,thecontrolsymbol\%usedonitsown isasynonymfor\char37,
thatis,thecommandtotypesetcharacter37(usuallythepercentcharacter).
Acontrolsequencethathasbeendeﬁnedwitha\chardefcommandcanalsobeusedas
anumber.Thisfactisusedinallocationcommandssuchas\newbox(seeChapters7
and31).Tokensdeﬁnedwith\mathchardefcanalsobeusedthisway.
3.3.1
Implicitcharactertokens:\let
Anotherconstructiondeﬁningacontrolsequencetostandfor(amongotherthings)acha-
racteris\let:
\letcontrolsequenceequalstoken
with acharactertokenontherighthand sideofthe(optional)equalssign.Theresultis
calledanimplicitcharactertoken.(Seepage117forafurtherdiscussionof\let.)
Intheplainformatthereareforinstancesynonymsfortheopenandclosebrace:
\let\bgroup={ \let\egroup=}
Theresultingcontrolsequencesarecalled‘implicitbraces’(seeChapter10).
Assigningcharactersby\letisdifferentfromdeﬁningcontrolsequencesby\chardef,
inthesensethat\letmakesthecontrolsequencestandforthecombinationofacharacter
codeandcategorycode.
Asanexample
\catcode‘|=2 % make the bar an end of group
\let\b=| % make \b a bar character
{\def\m{...}\b \m
givesan‘undeﬁnedcontrolsequence\m’becausethe\bclosedthegroupinsidewhich\m
wasdeﬁned.Ontheotherhand,
\let\b=| % make \b a bar character
\catcode‘|=2 % make the bar character end of group
{\def\m{...}\b \m
VictorEijkhout–T
E
XbyTopic
45
Chapter3. Characters
leavesonegroupopen,anditprintsaverticalbar(orwhateverisinposition124ofthe
currentfont).Theﬁrstoftheseexamplesimpliesthatevenwhenthebraceshavebeenre-
deﬁned(forinstanceintoactivecharactersformacrosthatformatCcode)thebeginning-of-
groupandend-of-groupfunctionalityisavailablethroughthecontrolsequences\bgroup
and\egroup.
Hereisanotherexampletoshowthatimplicitcharactertokensarehardtodistinguishfrom
realcharactertokens.Aftertheabovesequence
\catcode‘|=2 \let\b=|
thetests
\if\b|
and
\ifcat\b}
arebothtrue.
Yetanotherexamplecanbefoundintheplainformat:thecommands
\let\sp=^ \let\sb=_
allowpeoplewithout an underscoreorcircumﬂex on theirkeyboard to makesub-and
superscriptsinmathematics.Forinstance:
x\sp2\sb{ij} gives x2
ij
If apersontypingintheformatitselfdoesnot havethesekeys,somefurthertricksare
needed:
{\lccode‘,=94 \lccode‘.=95 \catcode‘,=7 \catcode‘.=8
\lowercase{\global\let\sp=, \global\let\sb=.}}
will do thejob; seebelow foran explanationoflowercasecodes. The^^method asit
wasinT
E
Xversion2 (seepage32)cannotbeusedhere,asitwouldrequiretypingtwo
charactersthatcanordinarilynotbeinput.WiththeextensioninT
E
Xversion3itwould
alsobepossibletowrite
{\catcode‘\,=7
\global\let\sp=,,5e \global\let\sb=,,5f}
Findingoutjustwhatacontrolsequencehasbeendeﬁnedtobewith\letcanbedone
using\meaning:thesequence
\let\x=3 \meaning\x
gives‘the character 3’.
3.4
Accents
Accentscanbeplacedbythehorizontalcommand:
\accent8-bitnumberoptionalassignmentscharacter
46
VictorEijkhout–T
E
XbyTopic
3.5. Testingcharacters
wherecharacterisacharacterofcategory11or12,a\char8-bitnumbercommand,or
a\chardeftoken.Ifnoneofthesefourtypesofcharacterfollows,theaccentistaken
tobea\charcommanditself;thisgivesanaccent‘suspendedinmid-air’.Otherwisethe
accentisplacedontopofthefollowingcharacter.Fontchangesbetweentheaccentandthe
charactercanbeeffectedbytheoptionalassignments.
Anunpleasantimplicationofthefactthatan\accentcommandhastobefollowedbya
characteristhatitisnotpossibletoplaceanaccentonaligature,ortwoaccentsontopof
eachother.Insomelanguages,suchasHindiorVietnamese,suchdoubleaccentsdooccur.
Positioningaccentsontopofeachotherispossible,however,inmathmode.
Thewidthofacharacterwithanaccentisthesameasthatoftheunaccentedcharacter.T
E
X
assumesthattheaccentasitappearsinthefontﬁleisproperlypositionedforacharacter
thatisashighasthex-heightofthefont;forcharacterswithotherheightsitcorrespondin-
glylowersorraisestheaccent.
Nogenuineunder-accentsexistinT
E
X.Theyareimplementedaslowplacedover-accents.
Awayofhandlingthemmorecorrectlywouldbetowriteamacrothatmeasuresthefollo-
wingcharacter,andraisesordropstheaccentaccordingly.Thecedillamacro,\c,inplain
T
E
Xdoessomethingalongtheselines.However,itdoesnotdroptheaccentforcharacters
withdescenders.
Thehorizontal positioning of an accent iscontrolledby \fontdimen1, slant perpoint.
Kernsareusedforthehorizontalmovement.Notethat,althoughtheyareinsertedautoma-
tically,thesekernsareclassiﬁedasexplicitkerns.Thereforetheyinhibithyphenationinthe
partsofthewordbeforeandafterthekern.
Asanexampleofkerningforaccents,herefollowsthedumpofahorizontallist.
\setbox0=\hbox{\it \‘l}
\showbox0
gives
\hbox(9.58334+0.0)x2.55554
.\kern -0.61803 (for accent)
.\hbox(6.94444+0.0)x5.11108, shifted -2.6389
..\tenit ^^R
.\kern -4.49306 (for accent)
.\tenit l
Notethattheaccentisplacedﬁrst,soafterwardstheitaliccorrectionofthelastcharacter
isstillavailable.
3.5
Testingcharacters
Equalityofcharactercodesistestedby\if:
\iftoken
1
token
2
VictorEijkhout–T
E
XbyTopic
47
Chapter3. Characters
Tokensfollowingthisconditional areexpanded untiltwounexpandabletokensareleft.
Thecondition isthen trueifthosetokensarecharactertokens withthesamecharacter
code,regardlessofcategorycode.
Anunexpandablecontrolsequenceisconsideredtohavecharactercode256andcategory
code16(sothatitisunequaltoanythingexceptanothercontrolsequence),exceptinthe
havethecharactercodeandcategorycodeofthatcharacter.Thiswasmentionedabove.
Thetest\ifcatforcategorycodeswasmentionedinChapter2;thetest
\ifxtoken
1
token
2
canbeusedtotestforcategorycodeandcharactercodesimultaneously.Thetokensfollo-
wingthistestarenotexpanded.However,iftheyaremacros,T
E
Xteststheirexpansionsfor
equality.
Quantitiesdeﬁnedby\chardefcanbetestedwith\ifnum:
\chardef\a=‘x \chardef\b=‘y \ifnum\a=\b % is false
basedonthefact(seeChapter7)thatchardeftokenscanbeusedasnumbers.
3.6
Uppercaseandlowercase
3.6.1
Uppercaseandlowercasecodes
Toeachofthecharactercodescorrespond an uppercasecodeandalowercasecode(for
stillmorecodesseebelow).Thesecanbeassignedby
\uccodenumberequalsnumber
and
\lccodenumberequalsnumber.
InIniT
E
Xcodes‘a..‘z,‘A..‘Zhaveuppercasecode‘A..‘Zandlowercasecode‘a..‘z.
Allothercharactercodeshavebothuppercaseandlowercasecodezero.
3.6.2
Uppercaseandlowercasecommands
Thecommands \uppercase{...}and \lowercase{...}go through their argument
lists,replacingallcharactercodesofexplicitcharactertokensbytheiruppercaseandlower-
casecoderespectivelyifthesearenon-zero,withoutchangingthecategorycodes.
Theargumentof\uppercaseand\lowercaseisageneraltext,whichisdeﬁnedas
generaltext−→ﬁller{balancedtextrightbrace
(forthedeﬁnitionofﬁllerseeChapter36)meaningthattheleftbracecanbeimplicit,
buttheclosingrightbracemustbeanexplicitcharactertokenwithcategorycode2.T
E
X
performsexpansiontoﬁndtheopeningbrace.
Uppercasingandlowercasingareexecutedintheexecutionprocessor;theyarenot‘macro
expansion’activitieslike\numberor\string.Thesequence(attemptingtoproduce\A)
48
VictorEijkhout–T
E
XbyTopic
3.7. Codesofacharacter
\expandafter\csname\uppercase{a}\endcsname
givesanerror(T
E
Xinsertsan\endcsnamebeforethe\uppercasebecause\uppercase
isunexpandable),but
\uppercase{\csname a\endcsname}
works.
Asanexampleofthecorrectuseof\uppercase,hereisamacrothattestsifacharacter
isuppercase:
\def\ifIsUppercase#1{\uppercase{\if#1}#1}
Thesametestcanbeperformedby\ifnum‘#1=\uccode‘#1.
Hyphenationofwordsstartingwithanuppercasecharacter,thatis,acharacternotequalto
itsown\lccode,issubjecttothe\uchyphparameter:ifthisispositive,hyphenationof
capitalizedwordsisallowed.SeealsoChapter19.
3.6.3
Uppercaseandlowercaseformsofkeywords
EachcharacterinT
E
Xkeywords,suchaspt,canbegiveninuppercaseorlowercaseform.
Forinstance,pT,Pt,pt,andPTallhavethesamemeaning.T
E
Xdoesnotusethe\uccode
ASCII
differencebetweenuppercaseandlower-
casecharacters–totheircharactercode.Thishassomeimplicationsforimplementations
ofT
E
Xfornon-romanalphabets;seepage370oftheT
E
Xbook,[25].
3.6.4
Creativeuseof\uppercaseand\lowercase
Thefactthat\uppercaseand\lowercasedonotchangecategorycodescansometimes
beusedtocreatecertaincharacter-code–category-codecombinationsthatwouldotherwise
bedifﬁculttoproduce.Seeforinstancetheexplanationofthe\newifmacroinChapter13,
andanotherexampleonpage46.
For aslightlydifferentapplication, considertheproblem (solvedby Rainer Sch¨opf) of,
givenacounter\newcount\mycount,writingcharacternumber\mycounttotheterminal.
Hereisasolution:
\lccode‘a=\mycount \chardef\terminal=16
\lowercase{\write\terminal{a}}
The\lowercasecommandeffectivelychangestheargumentof the\writecommand
from‘a’intowhateveritshouldbe.
3.7
Codesofacharacter
Eachcharactercodehasanumberofcodenamesassociatedwithit.Theseareintegersin
variousrangesthatdeterminehowthecharacteristreatedinvariouscontexts,orhowthe
occurrenceofthatcharacterchangestheworkingsofT
E
Xincertaincontexts.
Thecodenamesareasfollows:
VictorEijkhout–T
E
XbyTopic
49