Difference between revisions of "Command/definecounter"
< Command
Jump to navigation
Jump to search
m (Link to LMTX source. Page needs to get remade…) |
|||
(One intermediate revision by one other user not shown) | |||
Line 56: | Line 56: | ||
\startsetups[MySetup] | \startsetups[MySetup] | ||
− | \ifnum\rawcountervalue[MyCounter]>0 | + | \ifnum\rawcountervalue[MyCounter]>0{% |
MyCounter = \rawcountervalue[MyCounter] | MyCounter = \rawcountervalue[MyCounter] | ||
− | \fi | + | }\fi |
\stopsetups | \stopsetups | ||
Line 86: | Line 86: | ||
View the source for more details: | View the source for more details: | ||
− | https://source.contextgarden.net/tex/context/base/ | + | https://source.contextgarden.net/tex/context/base/mkxl/strc-num.mkxl |
Latest revision as of 06:48, 5 April 2024
Creates a new numeric counter.
Examples
Picture
The following partial example adds a picture at the end of each chapter:
\definecounter[EventCount] [ way=bytext, prefix=no, ] \startTEXpage \incrementcounter[EventCount] \externalfigure[{\rawcountervalue[EventCount]}] [ height=\paperheight, orientation=90, ] \stopTEXpage
The pictures are numbered sequentially, starting at 1.
Show Section Number
The following example writes a counter in a layer, starting with the value of 1:
\definecounter[MyCounter][ way=bytext, prefix=no ] \setnumber[MyCounter][-1] \setuphead[section][ page=left, before={\incrementcounter[MyCounter]}, ] \definelayer[MyLayer][ width=\paperwidth, height=\paperheight, position=no, repeat=no, ] \setupbackgrounds[page][ setups=MySetup, background=MyLayer, ] \startsetups[MySetup] \ifnum\rawcountervalue[MyCounter]>0{% MyCounter = \rawcountervalue[MyCounter] }\fi \stopsetups \starttext \startsection[title=S1] \stopsection \startsection[title=S2] \stopsection \stoptext
The initial value for the counter is set to -1 so that its value is 0 on the first page, then 1 on the second page.
See Also
- Counters
- \incrementcounter - Increase the counter value
- \decrementcounter - Decrease the counter value
- \rawcounter - Retrieve the unformatted value
- \rawcountervalue - Retrieve the unformatted value
- \convertedcounter - Retrieve the formatted value
Source Code
View the source for more details:
https://source.contextgarden.net/tex/context/base/mkxl/strc-num.mkxl