Chapter5. Boxes
iscompletelyequivalenttojust
\vbox{...}
Itwasstatedabovethatthedepthofa\vboxiszeroifthelastitemisakernorglue,and
theheightofa\vtopiszerounlessthefirstiteminitisabox.Theaboveexamplesuseda
kernforthatfirstorlastitem,butif,inthecaseofa\vtop,thisitemisnotaglueorkern,
oneisapttooverlooktheeffectthatithasonthesurroundingbox.Forinstance,
\vtop{\write16{...}...}
haszeroheight,becausethewriteinstructionispackedintoa‘whatsit’itemthatisplaced
onthecurrent,thatis,thevertical,list.Theremedyhereis
\vtop{\leavevmode\write16{...}...}
whichputsthewhatsitinthebeginningoftheparagraph,insteadofaboveit.
Placementofitemsinaverticallistissometimesabittricky.Thereisforinstanceadiffe-
rencebetweenhowverticalandhorizontalboxesaretreatedinaverticallist.Considerthe
followingexamples.After\offinterlineskipthefirstexample
\vbox{\hbox{a}
\setbox0=\vbox{\hbox{(}}
\ht0=0pt \dp0=0pt \box0
\hbox{ b}}
gives
a
(b
whileaslightvariant
\vbox{\hbox{a}
\setbox0=\hbox{(}
\ht0=0pt \dp0=0pt \box0
\hbox{ b}}
gives
a
(
b
Thedifferenceiscausedbythefactthathorizontalboxesareplacedwithrespecttotheir
referencepoint,butverticalboxeswithrespecttotheirupperleftcorner.
5.9.5
Hangingthe\lastboxbackinthelist
Youcanpickthelastboxoffaverticallistthathasbeencompiledin(internal)vertical
mode.However,ifyoutrytohangitbackinthelisttheverticalspacingmaygohaywire.
Ifyoujusthangitback,
\setbox\tmpbox=\lastbox
\usethetmpbox \box\tmpbox
baselineskipglueisaddedasecondtime.Ifyou‘unskip’priortohangingtheboxback,
\setbox\tmpbox=\lastbox \unskip
\usethetmpbox \box\tmpbox
70
VictorEijkhout–T
E
XbyTopic
Delete pages from pdf - 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 file; cut pages from pdf reader
Delete pages from pdf - 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 pdf pages acrobat; delete pages from pdf without acrobat
5.9. Assortedremarks
thingsgowronginamoresubtleway.Theinternaldimen\prevdepth(whichcontrols
interlineglue;seeChapter15)willhaveavaluebasedonthelastbox,butwhatyouneed
fortheproper interlineglueisadepthbasedon onebox earlier.Thesolutionisnot to
unskip,buttospecify\nointerlineskip:
\setbox\tmpbox=\lastbox
\usethetmpbox \nointerlineskip \box\tmpbox
5.9.6
Dissectingparagraphswith\lastbox
Repeatedlyapplying\last...and\un...macroscanbeusedtotakeaparagraphapart.
Hereisanexampleofthat.
In typesetting advertisement copy, away ofjustifying paragraphs has becomepopular
inrecentyearsthatissomewherebetweenflushrightandraggedrightsetting.Linesthat
wouldstretchbeyondcertainlimitsaresetwiththeirglueatnaturalwidth.Thisparagraph
exemplifiesthisprocedure;themacrosfollownext.
\newbox\linebox \newbox\snapbox
\def\eatlines{
\setbox\linebox\lastbox
% check the last line
\ifvoid\linebox
\else
% if it’s not empty
\unskip\unpenalty
% take whatever is
{\eatlines}
% above it;
% collapse the line
\setbox\snapbox\hbox{\unhcopy\linebox}
% depending on the difference
\ifdim\wd\snapbox<.98\wd\linebox
\box\snapbox % take the one or the other,
\else \box\linebox \fi
\fi}
Thismacrocanbecalledas
\vbox{ ... some text ... \par\eatlines}
oritcanbeinsertedautomaticallywith\everypar;see[10].
Inthemacro\eatlines,the\lastboxistakenfromaverticallist.Ifthelistisempty
thelastboxwilltesttrueon\ifvoid.Theseboxescontaininglinesfromaparagraphare
actuallyhorizontalboxes:thetest\ifhboxappliedtothemwouldgiveatrueresult.
VictorEijkhout–T
E
XbyTopic
71
C# PDF File & Page Process Library SDK for C#.net, ASP.NET, MVC
C# view PDF online, C# convert PDF to tiff, C# read PDF, C# convert PDF to text, C# extract PDF pages, C# comment annotate PDF, C# delete PDF pages, C# convert
delete a page from a pdf in preview; acrobat export pages from pdf
C# PDF Page Insert Library: insert pages into PDF file in C#.net
how to merge PDF document files by C# code, how to rotate PDF document page, how to delete PDF page using C# .NET, how to reorganize PDF document pages and how
delete pdf pages android; delete pages in pdf reader
Chapter 6
Horizontaland VerticalMode
AtanypointinitsprocessingT
E
Xisinsomemode.Therearesixmodes,dividedinthree
categories:
1.
horizontalmodeandrestrictedhorizontalmode,
2.
verticalmodeandinternalverticalmode,and
3.
mathmodeanddisplaymathmode.
Themathmodeswillbetreatedelsewhere(seepage201).Hereweshalllookattheho-
rizontalandverticalmodes,thekindsofobjectsthatcanoccurinthecorrespondinglists,
andthecommandsthatareexclusiveforonemodeortheother.
\ifhmode Testwhetherthecurrentmodeis(possiblyrestricted)horizontalmode.
\ifvmode Testwhetherthecurrentmodeis(possiblyinternal)verticalmode.
\ifinner Testwhetherthecurrentmodeisaninternalmode.
\vadjust Specifyverticalmaterialfortheenclosingverticallistwhileinhorizontalmode.
\showlists Writetothelogfilethecontentsofthepartiallistscurrentlybeingbuiltin
allmodes.
6.1
Horizontalandverticalmode
When not typesettingmathematics,T
E
Xisin horizontal or vertical mode, building ho-
rizontalorverticallistsrespectively.Horizontalmodeistypically used to makelinesof
text;verticalmodeistypicallyusedtostackthelinesofaparagraphontopofeachother.
NotethatthesemodesaredifferentfromtheinternalstatesofT
E
X’sinputprocessor(see
page31).
6.1.1
Horizontalmode
Themainactivityinhorizontalmodeisbuildinglinesoftext.Textonthepageandtextin
a\vboxor\vtopisbuiltinhorizontalmode(thismightbecalled‘paragraphmode’);if
thetextisinan\hboxthereisonlyonelineoftext,andthecorrespondingmodeisthe
restrictedhorizontalmode.
72
VB.NET PDF Page Insert Library: insert pages into PDF file in vb.
Page: Insert PDF Pages. |. Home ›› XDoc.PDF ›› VB.NET PDF: Insert PDF Page. Add and Insert Multiple PDF Pages to PDF Document Using VB.
delete a page from a pdf file; cut pages from pdf preview
VB.NET PDF Page Extract Library: copy, paste, cut PDF pages in vb.
C:\test1.pdf") Dim pdf2 As PDFDocument = New PDFDocument("C:\test2.pdf") Dim pageindexes = New Integer() {1, 2, 4} Dim pages = pdf.DuplicatePage(pageindexes
delete a page from a pdf online; delete pages from pdf in reader
6.2. Horizontalandverticalcommands
Inhorizontalmodeallmaterialisaddedtoahorizontallist.Ifthislistisbuiltinunrestricted
horizontalmode,itwilllaterbebrokenintolinesandaddedtothesurroundingverticallist.
Eachelementofahorizontallistisoneofthefollowing:
abox(acharacter,ligature,\vrule,orabox),
adiscretionarybreak,
awhatsit(seeChapter30),
verticalmaterialenclosedin\mark,\vadjust,or\insert,
glueorleaders,akern,apenalty,oramath-on/offitem.
Theitemsinthelastpointarealldiscardable.Discardableitemsarecalledthat,because
theydisappearinabreak.BreakingofhorizontallistsistreatedinChapter19.
6.1.2
Verticalmode
Verticalmodecanbeusedto stackitemsontopofoneanother.Mostofthetime,these
itemsareboxescontainingthelinesofparagraphs.
Stackingmaterialcantakeplaceinsideaverticalbox,buttheitemsthatarestackedcan
alsoappearbythemselvesonthepage.InthelattercaseT
E
Xisinverticalmode;inthe
formercase,insideaverticalbox,T
E
Xoperatesininternalverticalmode.
Inverticalmodeallmaterialisaddedtoaverticallist.Ifthislistisbuiltinexternalvertical
mode,itwilllaterbebrokenwhenpagesareformed.
Eachelementofaverticallistisoneofthefollowing:
abox(ahorizontalorverticalboxoran\hrule),
awhatsit,
amark,
glueorleaders,akern,orapenalty.
Theitemsinthelastpointarealldiscardable.BreakingofverticallistsistreatedinChap-
ter27.
Therearea few exceptional conditionsat thebeginning ofa vertical list: thevalueof
\prevdepthissetto-1000pt.Furthermore,no\parskipglueisaddedatthetopofan
internalverticallist;atthetopofthemainverticallist(thetopofthe‘currentpage’)no
glueorotherdiscardableitemsareadded,and\topskipglueisaddedwhenthefirstbox
isplacedonthislist(seeChapters26and27).
6.2
Horizontalandverticalcommands
SomecommandsaresointrinsicallyhorizontalorverticalinnaturethattheyforceT
E
Xto
gointothatmode,ifpossible.AcommandthatforcesT
E
Xintohorizontalmodeiscalleda
horizontalcommand;similarlyacommandthatforcesT
E
Xintoverticalmodeiscalleda
verticalcommand.
However,notalltransitionsarepossible:T
E
Xcanswitchfrombothverticalmodesto(un-
restricted)horizontal modeandbackthroughhorizontalandvertical commands,but no
VictorEijkhout–T
E
XbyTopic
73
C# PDF Page Extract Library: copy, paste, cut PDF pages in C#.net
C#.NET PDF Library - Copy and Paste PDF Pages in C#.NET. Easy to C#.NET Sample Code: Copy and Paste PDF Pages Using C#.NET. C# programming
delete pdf pages in reader; delete pages in pdf online
VB.NET PDF delete text library: delete, remove text from PDF file
VB.NET PDF - How to Delete Text from PDF File in VB.NET. VB.NET Programming Guide to Delete Text from PDF File Using XDoc.PDF SDK for VB.NET.
delete pages on pdf file; delete pages in pdf
Chapter6. HorizontalandVerticalMode
transitionstoorfromrestrictedhorizontalmodearepossible(otherthanbyenclosingho-
rizontalboxesinverticalboxesortheotherwayaround).Averticalcommandinrestricted
horizontalmodethusgivesanerror;the\parcommandinrestrictedhorizontalmodehas
noeffect.
Thehorizontalcommandsarethefollowing:
any letter, otherchar, \char, acontrol sequence defined by \chardef, or
\noboundary;
\accent,\discretionary,thediscretionaryhyphen\-andcontrolspace\;
\unhboxand\unhcopy;
\vruleandthehorizontalskipcommands\hskip,\hfil,\hfill,\hss,and
\hfilneg;
\valign;
mathshift($).
Theverticalcommandsarethefollowing:
\unvboxand\unvcopy;
\hruleandtheverticalskipcommands\vskip,\vfil,\vfill,\vss,and
\vfilneg;
\halign;
\endand\dump.
Notethattheverticalcommandsdonotinclude\par;norare\indentand\noindent
horizontalcommands.
Theconnectionbetweenboxesandmodesisexploredbelow;seeChapter9formoreon
theconnectionbetweenrulesandmodes.
6.3
Theinternalmodes
Restrictedhorizontalmodeandinternalverticalmodearethevariantsofhorizontalmode
andverticalmodethatholdinsidean\hboxand\vbox(or\vtopor\vcenter)respec-
tively.However,restrictedhorizontalmodeisrathermorerestrictedinnaturethaninternal
verticalmode.Thethirdinternalmodeisnon-displaymathmode(seeChapter23).
6.3.1
Restrictedhorizontalmode
Themaindifferencebetweenrestrictedhorizontalmode,themodeinan\hbox,andunre-
strictedhorizontalmode,themodeinwhichparagraphsinverticalboxesandonthepage
arebuilt,isthatyoucannotbreakoutofrestrictedhorizontalmode:\pardoesnothingin
thismode.Furthermore,averticalcommandinrestrictedhorizontalmodegivesanerror.
In unrestrictedhorizontal modeitwould causea\partokentobeinsertedandvertical
modetobeentered(seealsoChapter17).
74
VictorEijkhout–T
E
XbyTopic
C# Word - Delete Word Document Page in C#.NET
doc.Save(outPutFilePath); Delete Consecutive Pages from Word in C#. int[] detelePageindexes = new int[] { 1, 3, 5, 7, 9 }; // Delete pages.
add and delete pages in pdf online; delete pages from a pdf document
C# PDF metadata Library: add, remove, update PDF metadata in C#.
Allow C# Developers to Read, Add, Edit, Update and Delete PDF Metadata in .NET Project. Remove and delete metadata from PDF file.
delete a page from a pdf online; add remove pages from pdf
6.4. Boxesandmodes
6.3.2
Internalverticalmode
Internalverticalmode,theverticalmodeinsidea\vbox,isalotlikeexternalverticalmode,
themodeinwhichpagesarebuilt.Ahorizontalcommandininternalverticalmode,for
instance,isperfectlyvalid:T
E
Xthenstartsbuildingaparagraphinunrestrictedhorizontal
mode.
Onedifferenceisthat thecommands\unskipand \unkernhavenoeffectinexternal
verticalmode,and\lastboxisalwaysemptyinexternalverticalmode.Seefurtherpages
60and96.
Theentriesofalignments(seeChapter25)areprocessedininternalmodes:restrictedho-
rizontalmodefortheentriesofan\halign,andinternalverticalmodefortheentriesof
a\valign.Thematerialin\vadjustand \insertitemsisalsoprocessedininternal
verticalmode;furthermore,T
E
Xentersthismodewhenprocessingthe\outputtokenlist.
Thecommands\endand\dump(thelatterexistsonlyinIniT
E
X)arenotallowedininternal
verticalmode;furthermore,\dumpisnotallowedinsideagroup(seeChapter33).
6.4
Boxesandmodes
Therearehorizontal and vertical boxes, and thereishorizontaland verticalmode.Not
surprisingly,thereisaconnectionbetweentheboxesandthemodes.Onecanaskabout
thisconnectionintwoways.
6.4.1
Whatboxdoyouuseinwhatmode?
Thisisthewrongquestion.Bothhorizontalandverticalboxescanbeusedinbothhori-
zontal and verticalmode.Theirplacementisdetermined by theprevailing modeatthat
moment.
6.4.2
Whatmodeholdsinwhatbox?
Thisistherightquestion.Whenan\hboxstarts,T
E
Xisinrestrictedhorizontalmode.Thus
everythinginahorizontalboxislineduphorizontally.
Whena\vboxisstarted,T
E
Xisininternalverticalmode.Boxesofbothkindsandother
itemsarethenstackedontopofeachother.
6.4.3
Mode-dependentbehaviourofboxes
Anybox(seeChapter5forthefulldefinition)can beusedinhorizontal,vertical,and
math mode.Unboxingcommands,however,arespecificforhorizontalorverticalmode.
Both\unhboxand\unhcopyarehorizontalcommands,sotheycanmakeT
E
Xswitch
fromverticaltohorizontalmode;both\unvboxand\unvcopyareverticalcommands,
sotheycanmakeT
E
Xswitchfromhorizontaltoverticalmode.
VictorEijkhout–T
E
XbyTopic
75
Chapter6. HorizontalandVerticalMode
Inhorizontalmodethe\spacefactorissetto1000afteraboxhasbeenplaced.Inverti-
calmodethe\prevdepthissettothedepthoftheboxplaced.Neitherstatementholdsfor
unboxingcommands:afteran\unhboxor\unhcopythespacefactorisnotaltered,andaf-
ter\unvboxor\unvcopythe\prevdepthremainsunchanged.Afterall,thesecommands
donotaddabox,butapieceofa(horizontalorvertical)list.
Theoperations\raise and \lowercan only beapplied to abox in horizontal mode;
similarly,\moveleftand\moverightcanonlybeappliedinverticalmode.
6.5
Modesandglue
BothinhorizontalandverticalmodeT
E
Xcaninsertglueitemsthesizeofwhichisdeter-
minedbytheprecedingobjectinthelist.
Forhorizontalmodetheamountofgluethatisinsertedforaspacetokendependsonthe
\spacefactorofthepreviousobjectinthelist.ThisistreatedinChapter20.
InverticalmodeT
E
Xinsertsgluetokeepboxesatacertaindistancefromeachother.This
glueisinfluencedbytheheightofthecurrentitemandthedepthofthepreviousone.The
depthofitemsisrecordedinthe\prevdepthparameter(seeChapter15).
Thetwoquantities\prevdepthand\spacefactorusethesameinternalregisterofT
E
X.
Thusthe\prevdepthcanbeusedoraskedonlyinverticalmode,andthe\spacefactor
onlyinhorizontalmode.
6.6
Migratingmaterial
Thethreecontrolsequences\insert,\mark,and\vadjustcanbegiveninaparagraph
(thefirsttwocanalsooccurinverticalmode)tospecifymaterialthatwillwinduponthe
surroundingverticallist.Notethatthisneednotbethemainverticallist:itcanbeavertical
boxcontainingaparagraphoftext.Inthiscasea\markor\insertcommandwill not
reachthepagebreakingalgorithm.
Whenseveralmigratingitemsarespecifiedinacertainlineoftext,theirleft-to-rightorder
ispreservedwhentheyareplacedonthesurroundingverticallist.Theseitemsareplaced
directlyafterthehorizontalboxcontainingthelineoftextinwhichtheywerespecified:
theycomebeforeanypenaltyorglueitemsthatareautomaticallyinserted(seepage178).
6.6.1
\vadjust
Thecommand
\vadjustfiller{verticalmodematerial}
isonlyallowedinhorizontalandmathmodes(butitisnotahorizontalcommand).Ver-
ticalmodematerialspecifiedby\vadjustismovedfromthehorizontallistinwhichthe
commandisgiventothesurroundingverticallist,directlyaftertheboxinwhichitoccur-
red.
76
VictorEijkhout–T
E
XbyTopic
6.7. Testingmodes
Inthecurrentline a\vadjustitemwasplacedtoputthebulletinthemargin.
Anyvertical material in a\vadjustitem isprocessed in internal vertical mode, even
thoughitwillwinduponthemainverticallist.Forinstance,the\ifinnertestistrueina
\vadjust,andatthestartoftheverticalmaterial\prevdepth=-1000pt.
6.7
Testingmodes
Thethreeconditionals\ifhmode,\ifvmode,and\ifinnercandistinguishbetweenthe
fourmodesofT
E
Xthatarenotmathmodes.The\ifinnertestistrueifT
E
Xisinrestric-
tedhorizontalmodeorinternalverticalmode(orinnon-displaymathmode).Exceptional
condition:duringa\writeT
E
Xisina‘nomode’state.Thetests\ifhmode,\ifvmode,
and\ifmmodearethenallfalse.
Inspectionofallcurrentlists,includingthe‘recentcontributions’(seeChapter27),ispos-
siblethroughthecommand\showlists.Thiscommandwritestothelogfilethecontents
ofallliststhatarebeingbuiltatthemomentthecommandisgiven.
Considertheexample
a\hfil\break b\par
c\hfill\break d
\hbox{e\vbox{f\showlists
Herethefirstparagraphhasbeenbrokenintotwolines,andthesehavebeenaddedtothe
currentpage.Thesecondparagraphhasnotbeenconcludedorbrokenintolines.
Thelogfileshowsthefollowing.T
E
Xwas busybuilding aparagraph (starting with an
indentationbox20ptwide):
### horizontal mode entered at line 3
\hbox(0.0+0.0)x20.0
\tenrm f
spacefactor 1000
Thisparagraphwasinsideaverticalbox:
### internal vertical mode entered at line 3
prevdepth ignored
Theverticalboxwasinahorizontalbox,
### restricted horizontal mode entered at line 3
\tenrm e
spacefactor 1000
whichwaspartofanas-yetunfinishedparagraph:
### horizontal mode entered at line 2
\hbox(0.0+0.0)x20.0
\tenrm c
\glue 0.0 plus 1.0fill
\penalty -10000
\tenrm d
VictorEijkhout–T
E
XbyTopic
77
Chapter6. HorizontalandVerticalMode
etc.
spacefactor 1000
Notehowtheinfiniteglueandthe\breakpenaltyarestillpartofthehorizontallist.
Finally,thefirstparagraphhasbeenbrokenintolinesandaddedtothecurrentpage:
### vertical mode entered at line 0
### current page:
\glue(\topskip) 5.69446
\hbox(4.30554+0.0)x469.75499, glue set 444.75497fil
.\hbox(0.0+0.0)x20.0
.\tenrm a
.\glue 0.0 plus 1.0fil
.\penalty -10000
.\glue(\rightskip) 0.0
\penalty 300
\glue(\baselineskip) 5.05556
\hbox(6.94444+0.0)x469.75499, glue set 464.19943fil
.\tenrm b
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0
etc.
total height 22.0 plus 1.0
goal height 643.20255
prevdepth 0.0
78
VictorEijkhout–T
E
XbyTopic
Chapter7
Numbers
Inthischapterintegersandtheirdenotationswillbetreated,theconversionsthatarepossi-
bleeitherway,allocationanduseof\countregisters,andarithmeticwithintegers.
\number Convertanumbertodecimalrepresentation.
\romannumeral Convertapositivenumbertolowercaseromanrepresentation.
\ifnum Testrelationsbetweennumbers.
\ifodd Testwhetheranumberisodd.
\ifcase Enumeratedcasestatement.
\count Prefixforcountregisters.
\countdef Defineacontrolsequencetobeasynonymfora\countregister.
\newcount Allocateanunused\countregister.
\advance Arithmeticcommandtoaddtoorsubtractfromanumericvariable.
\multiply Arithmeticcommandtomultiplyanumericvariable.
\divide Arithmeticcommandtodivideanumericvariable.
7.1
Numbersandnumbers
An importantpart ofthegrammarofT
E
Xistherigorousdefinition of anumber,the
syntacticentitythatT
E
Xexpectswhensemanticallyanintegerisexpected.Thisdefinition
willtakethelargestpartofthischapter.Towardstheend,\countregisters,arithmetic,and
testsfornumbersaretreated.
Forclarityofdiscussion adistinction willbemadeherebetweenintegersandnumbers,
butnotethatanumbercanbebothan‘integer’anda‘number’.‘Integer’willbetaken
todenoteamathematicalnumber: aquantitythatcanbeaddedormultiplied.‘Number’
willbetakentorefertotheprintedrepresentationofaninteger:astringofdigits,inother
words.
7.2
Integers
QuiteafewdifferentsortsofobjectscanfunctionasintegersinT
E
X.Inthissectionthey
willallbetreated,accompaniedbytherelevantlinesfromthegrammarofT
E
X.
79
Documents you may be interested
Documents you may be interested