2022.2

Table Of Contents
ControlScript:Pagenumbering
ThistopicexplainshowtowriteaControlScriptthatchangesthepagenumberinginPrintsections.
NotethatwhenyouaddaControlScript,italreadycontainsascripttomakethepagenumberingcon-
tinueoverallPrintsections.
ForinformationaboutControlScriptsingeneral,see"ControlScripts"onpage838and"ControlScript
API"onpage1271.Ifyoudon'tknowhowtowritescripts,see"Writingyourownscripts"onpage808.
How to change page numbering in a control script
AControlScriptcanmakethepagenumberingcontinueoverallPrintsectionsorletitrestartonasec-
tion.ThisisdonebysettingtherestartPageNumber fieldonasectiontotrueorfalse.
Forexample:merge.template.contexts.PRINT.sections['Section
2'].restartPageNumber = true;.(Alsosee"section"onpage1305and"ControlScriptAPI"on
page1271.)
Pagenumberingstartswithpage1foreachsection.IfforasectionrestartPageNumberissetto
false,thatsectionwillstartwiththepagenumberfollowingthelastpageoftheprevioussection.
Notethatevenifasectionisnotenabled(soitwillnotbeoutputted),itsrestartPageNumberflagis
stilltakenintoaccountforcomposingthepagenumbersequences.
Bydefault,eachsectionhasrestartPageNumber = falsewhenthefirstcontrolscriptruns.
Tip: Ifyouarelookingtocreateashort,simpletableofcontentsinone section,youcouldadda
StandardScriptthatusesthepageRef()function.Foranexample,see"pageref()"on
page1260.
Foramulti-page,cross-sectiontableofcontentsyoumustuseaPostPaginationScript;see
"CreatingaTableOfContents"onpage852.
Examples
Restarting the page numbers several times
Assumethatatemplatehasfoursections(of1pageeach)inthePrintcontextandaControlScriptsets
thepagenumberingasfollows:
1. SectionA(1page)restartPageNumber=true
2. SectionB(1page)restartPageNumber=true
3. SectionC(1page)restartPageNumber=false
4. SectionD(1page)restartPageNumber=true
Thecodewouldlooklikethis:
Page 841