Section heads in ConTeXt are hierarchical. The default hierarchy is section-1
, section-2
, ..., section-8
, defined in strc-def.mkiv
as:
\defineprefixset [\v!all] [section-1,section-2,section-3,section-4,section-5,section-6,section-7,section-8] []
% [...]
\definesection[\s!section-1] % part
\definesection[\s!section-2] % chapter
\definesection[\s!section-3] % section
\definesection[\s!section-4] % subsection
\definesection[\s!section-5] % subsubsection
\definesection[\s!section-6] % subsubsubsection
\definesection[\s!section-7] % subsubsubsubsection
These are internal structures. They are are mapped to user-facing section heads using the section
key of \definehead
:
\definehead
[\v!part]
[\c!section=\s!section-1]
\definehead
[\v!chapter]
[\c!section=\s!section-2]
\definehead
[\v!section]
[\c!section=\s!section-3]
\definehead
[\v!subsection]
[\c!section=\s!section-4,
\c!default=\v!section]
\definehead
[\v!subsubsection]
[\c!section=\s!section-5,
\c!default=\v!subsection]
\definehead
[\v!subsubsubsection]
[\c!section=\s!section-6,
\c!default=\v!subsubsection]
\definehead
[\v!subsubsubsubsection]
[\c!section=\s!section-7,
\c!default=\v!subsubsubsection]
Note that section
key can only be set as part of \definehead
and cannot be reset using \setuphead
. So when you do
\definehead[mysec][section]
The section
key is set to section-3
and that is the reason that they share the same counter. So, in principle you could first define your own section
and then set it as the section
key for your new head:
\definesection[mysection]
\definehead[mysec][section=mysection]
But this will not work. The reason is that the section numbers are expected to be a part of a hierarchy, but the section that we defined is not. So, let's pick one of the existing low-lying numbers, say section-8
(which is actually unused):
\definehead[mysec][section=section-8]
If you want both of them to have the same styling, you can simply set the styling together using setuphead
:
\setuphead[section, mysec][ ... ]
which (in a complete examples) gives

Oops, this does not work! What went wrong? Well, section-8
is below section-3
, so it gets reset with every new section
. So, let's create a reset set that does not reset any section:
\defineresetset[myreset][][0]
And set this as the resetset:
\definehead[mysec][section=section-8, sectionresetset=myreset]
Adding this to the above example gives:

Much better.
How to handle lists
Let's try a bigger example and see what happens with lists:
\placelist[section,mysec]

What's happening is that mysec
is at section level 8, so it is appearing as a subsubsub...subsection of section in the TOC. To pretend that it is a section, we have to ensure that other section levels do not show in the toc entry for mysec. This can be achieved using:
\setuplist[mysec][numbersegments=mysec]
which gives

How to handle references
By default, using \in[ref:mysec]
will give the section number followed by mysec number. To get rid of the section number from the reference, use:
\setupreferencestructureprefix[mysec] [default][prefixsegments=8:8]
Here is a complete example:
\defineresetset[myreset][][0]
\definehead[mysec][section=section-8, sectionresetset=myreset]
\setuplist[mysec][numbersegments=mysec]
\setupreferencestructureprefix[mysec] [default][prefixsegments=8:8]
\setuphead[section, mysec]
[
style=\tfa,
distance=.75\emwidth,
textdistance=\emwidth plus \emwidth minus .25\emwidth,
before={\blank[2*big]},
after=\blank,
]
\starttext
\placelist[section, mysec]
\startsection[title=Section, reference=section]
\stopsection
\startmysec[title=My Section]
Let's check references \in{Section}[section] and \in{My Section}[mysec]
and \in[mysec2]
\stopmysec
\startsection[title=Section]
\stopsection
\startmysec[title=My Section, reference=mysec]
\stopmysec
\startmysec[title=My Section, reference=mysec2]
\stopmysec
\startsection[title=Section]
\stopsection
\startsection[title=Section]
\stopsection
\startmysec[title=My Section]
\stopmysec
\startmysec[title=My Section]
\stopmysec
\stoptext
What's missing.
So far, I have assumed that there is only one section level. So, how do we handle the case when there is chapter level or a subsection level. The easiest solution will be to hijack section-4
level for mysec
and move all other sections one level below.
enumeration
formysec
?