You can access the first, present, and final values of section counters
for the currently active structure component by their name using the command \somenamedheadnumber
.
\somenamedheadnumber
takes two mandatory arguments:
- the name of a structure element, e.~g. section, chapter, and
- one of the identifiers first, current, last that determine the
value to be retrieved.
Examples:
%% the initial value of the chapter counter
\somenamedheadnumber{chapter}{first}
%% the number of the final section in the current chapter
\somenamedheadnumber{section}{last}
%% the number of the currently active subsubsection;
%% in the page header this will retrieve the number of the
%% structural last active on the current page
\somenamedheadnumber{subsubsection}{current}
As a shorthand, \namedheadnumber{<name>}
is equivalent to
\somenamedheadnumber{<name>}{current}
.
A more extensive example showing the various getters for structure
counters in action:
\setuppagenumbering [location=footer,alternative=doublesided]
\startsetups header.outer
Chapter
\space
\namedheadnumber{chapter}
\space of \space
\somenamedheadnumber{chapter}{last}
\space --- \space
{\cap\getmarking[chapter]}
\stopsetups
\startsetups header.inner
Section
\space
\namedheadnumber{section}
\space of \space
\somenamedheadnumber{section}{last}
\space --- \space
{\italic\getmarking[section]}
\stopsetups
\setupheadertexts
[\setups{header.outer}]
[\setups{header.inner}]
\starttext
\getrandomnumber\i25
\completecontent\page
\dorecurse{\i}{
\getrandomnumber\j27
\startchapter[title=foo]
\input knuth
\dorecurse{\j}{
\startsection[title=bar]
\input ward\par\input dawkins
\stopsection
}
\stopchapter
}
\stoptext