Difference between revisions of "Command/somenamedheadnumber"
(new) |
(example) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
<cd:commandgroup name="somenamedheadnumber" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | <cd:commandgroup name="somenamedheadnumber" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | ||
<cd:shortdesc><!-- a short command summary goes here --> | <cd:shortdesc><!-- a short command summary goes here --> | ||
− | Use <tt>\somenamedheadnumber</tt> to access a section number. | + | Use <tt>\somenamedheadnumber</tt> to access a section number (expandable). |
</cd:shortdesc> | </cd:shortdesc> | ||
<cd:variants> | <cd:variants> | ||
Line 23: | Line 23: | ||
<cd:description><!-- the long description of the command goes here --> | <cd:description><!-- the long description of the command goes here --> | ||
</cd:description> | </cd:description> | ||
− | <cd:examples></cd:examples> | + | <cd:examples><cd:example title="chapter color"><context source="yes"> |
+ | \usemodule[visual] | ||
+ | |||
+ | \startsetups[MyChapterSetup] | ||
+ | \definecolor[MyChapterColor][h={\the\numexpr 360*\somenamedheadnumber{chapter}{current}/\somenamedheadnumber{chapter}{last}\relax},s=1,v=.75] | ||
+ | \definecolor[fakerulecolor][MyChapterColor] % for \fakewords | ||
+ | \setuphead[chapter][color=MyChapterColor] | ||
+ | \stopsetups | ||
+ | |||
+ | \unexpanded\def\MyChapter#1{ | ||
+ | \setup{MyChapterSetup} | ||
+ | \color[MyChapterColor]{#1} | ||
+ | } | ||
+ | |||
+ | \setuphead[chapter][page=no,textcommand=\MyChapter] | ||
+ | |||
+ | \starttext | ||
+ | |||
+ | \dorecurse{5}{ | ||
+ | \chapter{\fakewords{1}{5}} | ||
+ | \fakewords{10}{20} | ||
+ | } | ||
+ | |||
+ | \stoptext | ||
+ | </context></cd:example></cd:examples> | ||
<cd:notes></cd:notes> | <cd:notes></cd:notes> | ||
<cd:seealso> | <cd:seealso> | ||
<cd:source file="strc-sec.mkiv" originator="system"></cd:source> | <cd:source file="strc-sec.mkiv" originator="system"></cd:source> | ||
<cd:wikipage originator="system" page="Category:Structure"></cd:wikipage> | <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage> | ||
− | <cd:commandref name="someheadnumber"></cd:commandref></cd:seealso> | + | <cd:commandref name="someheadnumber">(not expandable)</cd:commandref></cd:seealso> |
</cd:commandgroup> | </cd:commandgroup> |
Latest revision as of 08:02, 20 July 2022
<cd:commandgroup name="somenamedheadnumber" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> <cd:shortdesc> Use \somenamedheadnumber to access a section number (expandable). </cd:shortdesc> <cd:variants> <cd:command category="structure" file="strc-sec.mkiv" interfacedate="2020-06-19T13:41" interfacefile="i-section.xml" level="system" name="somenamedheadnumber" variantnumber="1">
<cd:arguments> <cd:keywords delimiters="braces" ordinal="1"> <cd:keywordsdoc>name of the section level e.g. “chapter”</cd:keywordsdoc> <cd:constant type="cd:section"></cd:constant> </cd:keywords> <cd:keywords delimiters="braces" ordinal="2"> <cd:keywordsdoc></cd:keywordsdoc> <cd:constant type="previous"></cd:constant> <cd:constant type="current"></cd:constant> <cd:constant type="next"></cd:constant> <cd:constant type="first"></cd:constant> <cd:constant type="last"></cd:constant> </cd:keywords> </cd:arguments> </cd:command>
</cd:variants> <cd:description> </cd:description>
<cd:examples><cd:example title="chapter color">
\usemodule[visual] \startsetups[MyChapterSetup] \definecolor[MyChapterColor][h={\the\numexpr 360*\somenamedheadnumber{chapter}{current}/\somenamedheadnumber{chapter}{last}\relax},s=1,v=.75] \definecolor[fakerulecolor][MyChapterColor] % for \fakewords \setuphead[chapter][color=MyChapterColor] \stopsetups \unexpanded\def\MyChapter#1{ \setup{MyChapterSetup} \color[MyChapterColor]{#1} } \setuphead[chapter][page=no,textcommand=\MyChapter] \starttext \dorecurse{5}{ \chapter{\fakewords{1}{5}} \fakewords{10}{20} } \stoptext
</cd:example></cd:examples>
<cd:notes></cd:notes> <cd:seealso> <cd:source file="strc-sec.mkiv" originator="system"></cd:source> <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage> <cd:commandref name="someheadnumber">(not expandable)</cd:commandref></cd:seealso> </cd:commandgroup>