Difference between revisions of "Command/definecounter"

From Wiki
Jump to navigation Jump to search
Line 68: Line 68:
 
   \stopsection
 
   \stopsection
 
\stoptext
 
\stoptext
</textcode>
+
</texcode>
  
 
== See Also ==
 
== See Also ==

Revision as of 19:30, 5 April 2020

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:

\definecounter[MyCounter][
  way=bytext,
  prefix=no
]

\setnumber[MyCounter][0]

\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

See Also

Source Code

View the source for more details:

https://source.contextgarden.net/tex/context/base/mkiv/strc-num.mkiv