Chapter19. LineBreaking
19.3 Discretionaries
Adiscretionaryitem\discretionary{..}{..}{..}marksaplacewhereawordcan
bebroken.Eachofthethreeargumentsisageneraltext(seeChapter36):theyare,in
sequence,
thepre-breaktext,whichisappendedtothepartofthewordbeforethebreak,
thepost-breaktext,whichisprependedtothepartofthewordafterthebreak,and
theno-breaktext,whichisusedifthewordisnotbrokenatthediscretionaryitem.
Forexample:ab\discretionary{g}{h}{cd}efisthewordabcdef,butitcanbehy-
phenatedwithabgbeforethebreakandhefafter.Notethatthereisnoautomatichyphen
character.
Allthreetextsmaycontainanysortsoftokens,butanyprimitivecommandsandmacros
shouldexpandtoboxes,kerns,andcharacters.
19.3.1 Hyphensanddiscretionaries
Internally,T
E
Xinsertstheequivalentof
\discretionary{\char\hyphenchar\font}{}{}
ateveryplacewhereawordcanbebroken.Nosuchdiscretionaryisinsertedif\hyphenchar\font
isnotintherange0–255,orifitspositioninthefontisnotfilled.Whenafontisloaded,
its\hyphencharvalueissetto\defaulthyphenchar.The\hyphencharvaluecanbe
changedafterthis.
InplainT
E
Xthe\defaulthyphencharhasthevalue‘\-,soforallfontscharacter45
(the
ASCII
hyphencharacter)isthehyphensign,unlessitisspecifiedotherwise.
Theprimitivecommand\-(calleda‘discretionaryhyphen’)\-isequivalenttotheabove
\discretionary{\char\hyphenchar\font}{}{}.Breakingatsuchadiscretionary,whe-
therinsertedimplicitlybyT
E
Xorexplicitlybytheuser,hasacostof\hyphenpenalty.
Inunrestrictedhorizontalmodeanemptydiscretionary\discretionary{}{}{}isau-
tomaticallyinsertedaftercharacterswhosecharactercodeisthe\hyphencharvalueof
thefont,thusenablinghyphenationatthatpoint.Thepenaltyforbreakingalineatsuch
adiscretionarywithanemptypre-breaktextis\exhyphenpenalty,thatis,the‘explicit
hyphen’penalty.
Ifawordcontainsdiscretionarybreaks,forinstancebecauseofexplicithyphencharacters,
T
E
Xwillnotconsideritforfurtherhyphenation.Peoplehavesolvedtheensuingproblems
bytrickssuchas
\def\={\penalty10000 \hskip0pt -\penalty0 \hskip0pt\relax}
... integro\=differential equations...
TheskipsbeforeandafterthehyphenleadT
E
Xintotreatingthefirstandsecondhalfofthe
compoundexpressionasseparatewords;thepenaltybeforethefirstskipinhibitsbreaking
beforethehyphen.
180
VictorEijkhout–T
E
XbyTopic
Add and remove pages from pdf file 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 blank pages in pdf; copy pages from pdf into new pdf
Add and remove pages from pdf file 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 page pdf file; delete pages from pdf in reader
19.4. Hyphenation
19.3.2 Examplesofdiscretionaries
LanguagessuchasGermanorDutchhavewordsthatchangespellingwhenhyphenated
(German:‘backen’becomes‘bak-ken’;Dutch:‘autootje’becomes‘auto-tje’).Thispro-
blemcanbesolvedwithT
E
X’sdiscretionaries.
Forinstance,forGerman(thisisinspiredby[36]):
\catcode‘\"=\active
\def"#1{\ifx#1k\discretionary{k-}{k}{ck}\fi}
whichenablestheusertowriteba"ken.
InDutchthereisafurtherproblemwhichallowsanicesystematicsolution.Umlautcha-
racters(‘trema’istheDutchterm)shouldoftendisappearinabreak,forinstance‘na”apen’
hyphenatesas‘na-apen’,and‘onbe”invloedbaar’hyphenatesas‘onbe-invloedbaar’.Aso-
lution(inspiredby[5])is
\catcode‘\"=\active
\def"#1{\ifx#1i\discretionary{-}{i}{\"\i}%
\else \discretionary{-}{#1}{\"#1}\fi}
whichenablestheusertotypena"apenandonbe"invloedbaar.
19.4 Hyphenation
T
E
X’shyphenationalgorithmusesalistofpatternstodetermineatwhatplacesawordthat
isacandidateforhyphenationcanbebroken.Thoseaspectsofhyphenationconnectedwith
thesepatternsaretreatedinappendixHoftheT
E
Xbook;themethodofgeneratinghyphe-
nationpatternsautomaticallyisdescribedin[30].Peoplehavebeenknowntogeneratelists
ofpatternsbyhand;seeforinstance[28].Suchhand-generatedlistsmaybesuperiorto
automaticallygeneratedlists.
HereitwillmainlybedescribedhowT
E
Xdeclaresawordtobeacandidateforhyphena-
tion.Theproblemhereishowtocopewithpunctuationandthingssuchasquotationmarks
thatcanbeattachedtoaword.Also,implicitkerns,thatis,kernsinsertedbecauseoffont
information,mustbehandledproperly.
19.4.1 Startofaword
T
E
Xstartsatglueitems (iftheyare notinmathmode)lookingfora startingletter r of
aword:acharacterwithnon-zero\lccode,oraligaturestartingwithsuchacharacter
(upper/lowercasecodesareexplainedonpage48). Lookingforthisstartingletter,T
E
X
bypassesanyimplicitkerns,andcharacterswithzero\lccode(thisincludes,forinstance,
punctuationandquotationmarks),orligaturesstartingwithsuchacharacter.
Ifnosuitablestartingletterturnsup,thatis,ifsomethingisfoundthatisnotacharacteror
ligature,T
E
Xskipstothenextglue,andstartsthisalgorithmanew.Otherwiseatrialwordis
collectedconsistingofallfollowingcharacterswithnon-zero\lccodefromthesamefont
asthestartingletter,orligaturesconsistingcompletelyofsuchcharacters.Implicitkerns
areallowedbetweenthecharactersandligatures.
VictorEijkhout–T
E
XbyTopic
181
VB.NET PDF Password Library: add, remove, edit PDF file password
Define output file path. Dim outputFilePath As String = Program.RootPath + "\\" Output.pdf" ' Remove the password. doc.Save(outputFilePath). VB: Add Password
delete pages of pdf; delete pages from a pdf online
C# PDF Password Library: add, remove, edit PDF file password in C#
intputFilePath, userPassword); // Define output file path. Program.RootPath + "\\" Output.pdf"; // Remove the password C# Sample Code: Add Password to Plain
delete pages on pdf online; acrobat export pages from pdf
Chapter19. LineBreaking
Ifthestartingletterisfromafontforwhichthevalueof\hyphencharisinvalid,orfor
whichthischaracterdoesnotexist,hyphenationisabandonedforthisword.Ifthestarting
letterisanuppercaseletter(thatis,itisnotequaltoitsown\lccode),T
E
Xwillabandon
hyphenationunless\uchyphispositive.Thedefaultvalueforthisparameteris1inplain
T
E
X,implyingthatcapitalizedwordsaresubjecttohyphenation.
19.4.2 Endofaword
Followingthetrialwordcanbecharacters (fromanotherfont, orwithzero\lccode),
ligaturesorimplicitkerns.Aftertheseitems,ifany,mustfollow
glueoranexplicitkern,
apenalty,
awhatsit,or
a\mark,\insert,or\vadjustitem.
Inparticular,thewordwillnotbehyphenatedifitisfollowedbya
box,
rule,
mathformula,or
discretionaryitem.
Sincediscretionariesareinsertedafterthe\hyphencharofthefont,occurrenceofthis
characterinhibitsfurtherhyphenation.Also,placementofaccentsisimplementedusing
explicitkerns(seeChapter3),soany\accentcommandisconsideredtobetheendofa
word,andinhibitshyphenationoftheword.
19.4.3 T
E
X2versusT
E
X3
ThereisanoticeabledifferenceinthetreatmentofhyphenatedfragmentsbetweenT
E
X2
andT
E
X3.T
E
X2insiststhatthepartbeforethebreakshouldbeatleasttwocharacters,and
thepartafterthebreakthreecharacters,long.Typographicallythisisasounddecision:this
waytherearenotwo-characterpiecesofawordstrandedattheendorbeginningofthe
line.Bothbeforeandafterthebreakthereareatleastthreecharacters.
InT
E
X3twointegerparametershavebeenintroducedtocontrolthelengthofthesefrag-
ments:\lefthyphenminand\righthyphenmin.Thesearesetto2and3respectively
intheplainformatforT
E
X3.Ifthesumofthesetwois63ormore,allhyphenationis
suppressed.
AnotheradditioninT
E
X3,thepossibilitytohaveseveralsetsofhyphenationpatterns,is
treatedbelow.
19.4.4 Patternsandexceptions
Thestatements
\patternsgeneraltext
\hyphenationgeneraltext
182
VictorEijkhout–T
E
XbyTopic
C# PDF File Permission Library: add, remove, update PDF file
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
delete a page from a pdf without acrobat; delete page in pdf online
C# PDF Digital Signature Library: add, remove, update PDF digital
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
cut pages from pdf; delete pages from pdf online
19.5. Switchinghyphenationpatterns
arehyphenationassignments, whichareglobalassignments. The \patterns com-
mand,whichspecifiesalistofhyphenationpatterns,isallowedonlyinIniT
E
X(seeChap-
ter33),andallpatternsmustbespecifiedbeforethefirstparagraphistypeset.
Hyphenationexceptionscanbespecifiedatanytimewithstatementssuchas
\hyphenation{oxy-mo-ron gar-goyle}
whichspecifylocationswhereawordmaybehyphenated.Subsequent\hyphenation
statementsarecumulative.
InT
E
X3thesestatementsaretakentoholdforthelanguagethatisthecurrentvalueofthe
\languageparameter.
19.5 Switchinghyphenationpatterns
Whentypesettingparagraphs,T
E
X(version3)canuseseveralsetsofpatternsandhyphe-
nationexceptions,foratmost256languages.
Ifa\patternsor\hyphenationcommandisgiven(seeabove),T
E
Xstoresthepatterns
orexceptionsunderthecurrentvalueofthe\languageparameter.The\patternscom-
mandisonlyallowedinIniT
E
X,andpatternsmustbespecifiedbeforeanytypesettingis
done. Hyphenationexceptions,however, canbespecifiedcumulatively,andnotonlyin
IniT
E
X.
Inadditiontothe\languageparameter,whichcanbesetbytheuser,T
E
Xhasinternallya
‘currentlanguage’.Thisissettozeroatthestartofeveryparagraph.Foreverycharacterthat
isaddedtoaparagraphthecurrentlanguageiscomparedwiththevalueof\language,and
iftheydifferawhatsitelementisaddedtothehorizontallist,resettingthecurrentlanguage
tothevalueof\language.
Atthestartofaparagraph,thiswhatsitisinsertedafterthe\everypartokens,but\lastbox
canstillaccesstheindentationbox.
Asanexample,supposethataformathasbeencreatedsuchthatlanguage0isEnglish,and
language1isDutch.Englishhyphenationswillthenbeusediftheuserdoesnotspecify
otherwise;ifajobstartswith
\language=1
thewholedocumentwillbesetusingDutchhyphenations,becauseT
E
Xwillinsertacom-
mandchangingthecurrentlanguageatthestartofeveryparagraph.Forexample:
\language=1
T...
gives
.\hbox(0.0+0.0)x20.0
% indentation
.\setlanguage1 (hyphenmin 2,3) % language whatsit
.\tenrm T
% start of text
Thewhatsitcanbeinsertedexplicitly,withoutchangingthevalueof\language,byspe-
cifying
VictorEijkhout–T
E
XbyTopic
183
VB.NET PDF File Permission Library: add, remove, update PDF file
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
delete pages pdf file; delete pages from pdf document
C# PDF remove image library: remove, delete images from PDF in C#.
Image: Insert Image to PDF. Image: Remove Image from Redact Text Content. Redact Images. Redact Pages. Annotation & Highlight Text. Add Text. Add Text Box. Drawing
delete pages from pdf in preview; delete page pdf file reader
Chapter19. LineBreaking
\setlanguagenumber
However,thiswillhardlyeverbeneeded.Onecasewhereitmaybenecessaryiswhenthe
contentsofahorizontalboxareunboxedtoaparagraph:insidetheboxnowhatsitsare
addedautomatically,sinceinsidesuchaboxnohyphenationcantakeplace.Seepage68
foranotherproblemwithtextinhorizontalboxes.
184
VictorEijkhout–T
E
XbyTopic
C# PDF File Split Library: Split, seperate PDF into multiple files
process of splitting PDF document, developers can also remove certain PDF contains the first page and the later three pages respectively Add necessary references
add remove pages from pdf; delete pdf pages in preview
VB.NET PDF remove image library: remove, delete images from PDF in
C#.NET PDF file & pages edit, C#.NET PDF pages extract, copy, paste, C#.NET rotate PDF pages, C#.NET VB.NET: Remove Image from PDF Page. Add necessary references
delete page from pdf; cut pages out of pdf
Chapter20
Spacing
TheusualinterwordspaceinT
E
Xisspecifiedinthefontinformation,buttheusercan
overridethis.ThischapterexplainstherulesbywhichT
E
Xcalculatesinterwordspace.
\ Controlspace.Insertthesameamountofspaceasaspacetokenwouldif\spacefactor=
1000.
\spaceskip Interwordglueifnon-zero.
\xspaceskip Interwordglueifnon-zeroand\spacefactor≥2000.
\spacefactor 1000timestheratiobywhichthestretch(shrink)componentoftheinter-
wordglueshouldbemultiplied(divided).
\sfcode Valuefor\spacefactorassociatedwithacharacter.
\frenchspacing Macrotoswitchoffextraspaceafterpunctuation.
\nonfrenchspacing Macrotoswitchonextraspaceafterpunctuation.
20.1 Introduction
Inbetweenwordsinatext,T
E
Xinsertsspace.Thisspacehasanaturalcomponent,plus
stretchandshrinktomakejustified(right-aligned)textpossible.Now,incertainstylesof
typesetting,thereismorespaceafterpunctuation.Thischapterdiscussesthemechanism
thatT
E
Xusestorealizesucheffect.
Hereisthegeneralidea:
Aftereverycharactertoken,the\spacefactorquantityisupdatedwiththespace
factorcodeofthatcharacter.
Whenspaceisinserted,itsnaturalsizecanbeaugmented(if\spacefactor ≥
2000),andingeneralitsstretchismultiplied,anditsshrinkdivided,by\spacefactor/1000.
Therearefurtherrules,forinstancesothatin...word.) And...thespaceis
modifiedaccordingtotheperiod,nottheclosingparenthesis.
20.2 Automaticinterwordspace
Foreveryspacetokeninhorizontalmodetheinterwordglueofthecurrentfontisinserted,
withstretchandshrinkcomponents,alldeterminedby\fontdimenparameters. Tobe
185
Chapter20. Spacing
specific,fontdimension2isthenormalinterwordspace,dimension3istheamountof
stretchoftheinterwordspace,and4istheamountofshrink.Fontdimension7iscalledthe
‘extraspace’;seebelow(thelistofallthefontdimensionsappearsonpage54).
Ordinarilyallspacesbetweenwords(inonefont)wouldbetreatedthesame.Toallow
fordifferentlysizedspaces–forinstanceatypesetequivalentofthedoublespacingafter
punctuationintypewrittendocuments–T
E
Xassociateswitheachcharactera so-called
‘spacefactor’.
Whenacharacterisaddedtothecurrenthorizontallist,thespacefactorcode(\sfcode)
ofthatcharacterisassignedtothespacefactor\spacefactor.Therearetwoexceptions
tothisrule:
Whenthespacefactorcodeiszero,the\spacefactordoesnotchange.This
mechanismallowsspacefactorstopersistthroughparenthesesandsuch;seesec-
tion20.5.3.
Whenthespacefactorcodeofthelastcharacteris>1000andthecurrentspace
factoris<1000,thespacefactorbecomes1000.Thismechanismpreventselon-
gatedspacesafterinitials;seesection20.5.2.
Themaximumspacefactoris32767.
Thestretchcomponentoftheinterwordspaceismultipliedbythespacefactordividedby
1000;theshrinkcomponentisdividedbythisfactor.Theextraspace(fontdimension7)is
addedtothenaturalcomponentoftheinterwordspacewhenthespacefactoris ≥2000.
20.3 Userinterwordspace
Theusercanoverridetheinterwordspacecontainedinthe\fontdimenparametersby
settingthe\spaceskipandthe\xspaceskiptonon-zerovalues.If\spaceskipisnon-
zero,itistakeninsteadofthenormalinterwordspace(\fontdimen2plus\fontdimen3
minus\fontdimen4),butanon-zero\xspaceskipisusedasinterwordspaceifthespace
factoris ≥2000.
Ifthe\spaceskipisused,itsstretchandshrinkcomponentsaremultipliedanddivided
respectivelyby\spacefactor/1000.
Notethat,if\spaceskipand\xspaceskiparedefinedintermsofem,theychangewith
thefont.
Letthefollowingmacrosbegiven:
\def\a.{\vrule height10pt width4pt\spacefactor=1000\relax}
\def\b.{\vrule height10pt width4pt\spacefactor=3000\relax}
\def\c{\vrule height10pt width4pt\relax}
then
186
VictorEijkhout–T
E
XbyTopic
20.4. Controlspaceandtie
\vbox{
\fontdimen2\font=4pt % % normal space
\fontdimen7\font=3pt % % extra space
\a. \b. \c\par
% zero extra space
\fontdimen7\font=0pt
\a. \b. \c\par
% set \spaceskip for r normal l space
\spaceskip=2\fontdimen2\font
\a. \b. \c\par
% set \xspaceskip
\xspaceskip=2pt
\a. \b. \c\par
}
gives
In allofthese lines s theglue is setat natural width. In n the first line
thehighspacefactorvalueafter\bcausestheextraspace\fontdimen7
tobeadded.Ifthisiszero(secondline),theonlydifferencebetween
space factor values s is the e stretch/shrink k ratio. In n the third line the
\spaceskipistakenforallspacefactorvalues.Ifthe\xspaceskip
isnonzero,itistaken(fourthline)insteadofthe\spaceskipforthe
highvalue ofthe spacefactor.
20.4 Controlspaceandtie
Controlspace, \,isa horizontalcommandwhichinsertsa space, \actingasifthe
currentspacefactoris 1000. However, itdoesnotaffectthevalueof\spacefactor.
Controlspacehastwomainuses.First,itisconvenienttouseafteracontrolsequence:
\TeX\ is fun!Secondly,itcanbeusedafterabbreviationswhen\nonfrenchspacing
(seebelow)isineffect.Forexample:
\hbox spread 9pt{\nonfrenchspacing
The Reverend Dr. Drofnats}
gives
The Reverend Dr. Drofnats
while
\hbox spread 9pt{\nonfrenchspacing
The Reverend Dr.\ Drofnats}
gives
The Reverend Dr. . Drofnats
(Thespread 9ptisusedtomaketheeffectmorevisible.)
Theactivecharacter(inthe plainformat)tilde, ~,uses controlspace:itisdefinedas
\catcode‘\~=\active
\def~{\penalty10000\ }
VictorEijkhout–T
E
XbyTopic
187
Chapter20. Spacing
Suchanactive tildeiscalleda‘tie’;itinserts anordinaryamount ofspace, andpro-
hibits breakingatthisspace.
20.5 Moreonthespacefactor
20.5.1 Spacefactorassignments
Thespacefactorofaparticularcharactercanbeassignedas
\sfcode8-bitnumberequalsnumber
IniT
E
Xassigns aspacefactorcodeof1000toall characters exceptuppercasecharac-
ters; theygeta spacefactorcode of999. . The plainformatthenassigns space factor
codesgreaterthan1000tovariouspunctuationsymbols,forinstance\sfcode‘\.=3000,
whichtriples the stretchand d shrinkaftera fullstop. . Also, forallspacefactorvalues
≥2000theextraspaceisadded;seeabove.
20.5.2 Punctuation
Becausethespacefactorcannotjumpfromavaluebelow1000tooneabove,apunc-
tuation symbol after anuppercase characterwill not have the effect on the interword
spacethatpunctuationafteralowercasecharacterhas.
a% \sfcode‘a=1000, space factor becomes 1000
.% \sfcode‘.=3000, spacefactor becomes 3000
% subsequent spaces will be increased.
A% \sfcode‘A=999, space e factor becomes 999
.% \sfcode‘.=3000, space factor becomes 1000
% subsequent spaces will not be increased.
Thus,initialsarenotmistakenforsentenceends.Ifanuppercasecharacterdoesenda
sentence,forinstance
... and NASA.
thereareseveralsolutions:
... NASA\spacefactor=1000.
or
... NASA\hbox{}.
whichabusesthefactthatafteraboxthespacefactorissetto1000.TheLAT
E
Xmacro
\@isequivalenttothe firstpossibility.
In the plain format two macros s are defined that t switch h between n uniform interword
spacingandextraspaceafterpunctuation. Themacro\frenchspacing sets thespace
factorcodeofallpunctuationto1000;themacro\nonfrenchspacingsets it tova-
lues greaterthan1000.
Hereare theactualdefinitions from plain.tex:
188
VictorEijkhout–T
E
XbyTopic
20.5. Moreonthespacefactor
\def\frenchspacing{\sfcode‘\.\@m \sfcode‘\?\@m
\sfcode‘\!\@m \sfcode‘\:\@m
\sfcode‘\;\@m \sfcode‘\,\@m}
\def\nonfrenchspacing{\sfcode‘\.3000 \sfcode‘\?3000
\sfcode‘\!3000 \sfcode‘\:2000
\sfcode‘\;1500 \sfcode‘\,1250 }
where
\mathchardef\@m=1000
is givenintheplainformat.
Frenchspacingis asomewhatcontroversialissue:theT
E
Xbookactsasifnon-French
spacing is s standardpractice in n printing, , butforinstance in n [14]onefinds s ‘The space
ofthelineshouldbeusedafterallpointsinnormaltext’.Extraspaceafterpunctuation
maybeconsidereda‘typewriterhabit’, butthisisnotentirelytrue.Itusedtobealot
morecommonthanitisnowadays,andtherearerationalargumentsagainstit:thefull
stop(point, period)atthe end d ofa sentence, , whereextrapunctuationis mostvisible,
is rather small, , so o it carries s some extra visual space e of f its own above it. This s book
doesnotuseextraspaceafterpunctuation.
20.5.3 Othernon-letters
Thezerovalueofthespacefactorcode makes characters thatare notaletterandnot
punctuation‘transparent’forthespacefactor.
a% \sfcode‘a=1000, space factor becomes 1000
.% \sfcode‘.=3000, spacefactor becomes 3000
% subsequent spaces s will l be increased.
a% \sfcode‘a=1000, space factor becomes 1000
.% \sfcode‘.=3000, space factor becomes 3000
)% \sfcode‘)=0,
space factor stays 3000
% subsequent spaces s will l be increased.
20.5.4 Otherinfluencesonthespacefactor
The space factoris1000when T
E
Xstarts formingahorizontal list, inparticularafter
\indent, \noindent, and directly y after r a a display. . It is also 1000 0 after r a a \vrule,
an accent, , or r a box  (in n horizontal l mode), but it is not influenced by y \unhbox or
\unhcopy commands.
Inthefirstcolumnofa\valignthespacefactorofthesurroundinghorizontallistis
carried over; similarly, aftera a vertical l alignment the space factoris setto the e value
reachedinthelastcolumn.
VictorEijkhout–T
E
XbyTopic
189
Documents you may be interested
Documents you may be interested