%D \module %D [ file=strc-num, %D version=2008.10.20, %D title=\CONTEXT\ Structure Macros, %D subtitle=Basic Numbering, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \writestatus{loading}{ConTeXt Structure Macros / Basic Numbering} \registerctxluafile{strc-num}{1.001} \unprotect % work in progress % to be checked: can we use the command handler code here? \installcorenamespace{counter} \unexpanded\def\setupstructurecounting{\dodoubleempty\getparameters[\??counter]} \setupstructurecounting [\c!way=\v!by\v!chapter, % \c!blockway=, % \c!prefixstarter=, % \c!prefixstopper=, \c!prefixconnector=., \c!prefixsegments=\autostructureprefixsegments\sharedcounterparameter, \c!start=0, \c!prefix=\v!yes, \c!state=\v!start] \def\strc_counters_the#1% we need a nicer name {\ifcsname\??counter#1\c!number\endcsname \expandafter\strc_counters_the\csname\??counter#1\c!number\endcsname \else #1% \fi} \def\autostructureprefixsegments#1% todo: \c!prefixsegments=\v!auto {2:\thenamedheadlevel{\ctxlua{structures.sections.way("#1\c!way")}}} \def\counterparameter#1#2% this will become \named.... {\csname \ifcsname\??counter#1#2\endcsname \??counter#1#2% \else\ifcsname\??counter\strc_counters_the{#1}#2\endcsname \??counter\strc_counters_the{#1}#2% \else\ifcsname\??counter#2\endcsname \??counter#2% \else \s!empty \fi\fi\fi \endcsname} \def\sharedcounterparameter#1% {\csname \ifcsname\??counter#1\endcsname \??counter#1% \else \s!empty \fi \endcsname} \unexpanded\def\definecounter {\dodoubleempty\strc_counters_define} \def\strc_counters_define[#1][#2]% {\doifassignmentelse{#2} {\strc_counters_define_yes[#1][#2]} {\doifelsenothing{#2} {\strc_counters_define_yes[#1][]} {\strc_counters_define_nop[#1][#2]}}} \def\strc_counters_define_yes[#1][#2]% {\getparameters[\??counter#1][\s!counter=,#2]% counter is for internal purposes \ctxcommand{definecounter { name = "#1", start = tonumber("\counterparameter{#1}\c!start") or 0, counter = "\counterparameter{#1}\s!counter", method = "\counterparameter{#1}\c!method", }}% \strc_counters_check_setup{#1}} \def\strc_counters_define_nop[#1][#2]% inherit {\getparameters[\??counter#1][\c!number=#2]% \strc_counters_check_setup{#1}} \unexpanded\def\setupcounter {\dodoubleargument\strc_counters_setup} \def\strc_counters_setup[#1][#2]% {\getparameters[\??counter#1][\c!start=,#2]% \strc_counters_check_setup{#1}} % % % % \def\strc_counters_way#1% slow, we need to store it at the tex end {\ctxlua{structures.sections.way("\counterparameter{#1}\c!way")}} % \def\thenamedcounterlevel#1% % {\thenamedheadlevel{\strc_counters_way{#1}}} \def\thenamedcounterlevel#1% {\xthenamedheadlevel{\strc_counters_way{#1}}} \def\xthenamedheadlevel#1% {\xsectionlevel{#1}{\sectionheadsection{\sectionheadcoupling{#1}}}} \def\xsectionlevel#1#2% direct indirect {\csname\??headlevel \ifcsname\??headlevel#1\endcsname #1% \else\ifcsname\??headlevel#2\endcsname #2% \else \v!none \fi\fi \endcsname} \def\strc_counters_check_setup#1% does it have to happen here? {% this can be done at the lua end / a bit messy here ... todo ... \ifcsname\??counter#1\c!number\endcsname \doifelsevalue {\??counter#1\c!number}{#1} {\letbeundefined{\??counter#1\c!number}}% {\doifvaluenothing{\??counter#1\c!number} {\letbeundefined{\??counter#1\c!number}}}% \fi \ifcsname\??counter#1\c!number\endcsname % it's a clone \else \edef\currentcounterlevel{\thenamedcounterlevel{#1}}% \ctxcommand{checkcountersetup("#1",\currentcounterlevel,"\counterparameter{#1}\c!start","\counterparameter{#1}\c!state")}% \fi} \unexpanded\def\doifcounterelse #1{\ctxcommand{doifelsecounter("\strc_counters_the{#1}")}} \unexpanded\def\doifcounter #1{\ctxcommand{doifcounter ("\strc_counters_the{#1}")}} \unexpanded\def\doifnotcounter #1{\ctxcommand{doifnotcounter ("\strc_counters_the{#1}")}} \unexpanded\def\setcounter {\dotripleempty \strc_counters_set_interfaced} \unexpanded\def\setcounterown {\dotripleempty \strc_counters_setown_interfaced} \unexpanded\def\restartcounter {\dotripleempty \strc_counters_restart_interfaced} \unexpanded\def\resetcounter {\dodoubleempty \strc_counters_reset_interfaced} \unexpanded\def\incrementcounter {\dodoubleempty \strc_counters_increment_interfaced} \unexpanded\def\decrementcounter {\dodoubleempty \strc_counters_decrement_interfaced} \unexpanded\def\rawcounter {\dodoubleargument\strc_counters_raw_interfaced} \unexpanded\def\lastcounter {\dodoubleargument\strc_counters_last_interfaced} \unexpanded\def\firstcounter {\dodoubleargument\strc_counters_first_interfaced} \unexpanded\def\nextcounter {\dodoubleargument\strc_counters_next_interfaced} \unexpanded\def\prevcounter {\dodoubleargument\strc_counters_prev_interfaced} \unexpanded\def\countersubs {\dodoubleargument\strc_counters_subs_interfaced} \unexpanded\def\savecounter {\dodoubleempty \strc_counters_save_interfaced} \unexpanded\def\restorecounter {\dodoubleempty \strc_counters_restore_interfaced} \def\strc_counters_set_interfaced {\ifthirdargument \singleexpandafter\strc_counters_set_two \else\ifsecondargument \doubleexpandafter\strc_counters_set_one \else \doubleexpandafter\gobblethreeoptionals \fi\fi} \def\strc_counters_setown_interfaced {\ifthirdargument \singleexpandafter\strc_counters_setown_two \else\ifsecondargument \doubleexpandafter\strc_counters_setown_one \else \doubleexpandafter\gobblethreeoptionals \fi\fi} \def\strc_counters_restart_interfaced {\ifthirdargument \singleexpandafter\strc_counters_restart_two \else\ifsecondargument \doubleexpandafter\strc_counters_restart_one \else \doubleexpandafter\gobblethreeoptionals \fi\fi} \def\strc_counters_reset_interfaced {\ifsecondargument \singleexpandafter\strc_counters_reset_two \else\iffirstargument \doubleexpandafter\strc_counters_reset_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_increment_interfaced {\ifsecondargument \singleexpandafter\strc_counters_increment_two \else\iffirstargument \doubleexpandafter\strc_counters_increment_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_decrement_interfaced {\ifsecondargument \singleexpandafter\strc_counters_decrement_two \else\iffirstargument \doubleexpandafter\strc_counters_decrement_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_raw_interfaced {\ifsecondargument \singleexpandafter\strc_counters_raw_two \else\iffirstargument \doubleexpandafter\strc_counters_raw_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_last_interfaced {\ifsecondargument \singleexpandafter\strc_counters_last_two \else\iffirstargument \doubleexpandafter\strc_counters_last_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_first_interfaced {\ifsecondargument \singleexpandafter\strc_counters_first_two \else\iffirstargument \doubleexpandafter\strc_counters_first_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_prev_interfaced {\ifsecondargument \singleexpandafter\strc_counters_prev_two \else\iffirstargument \doubleexpandafter\strc_counters_prev_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_next_interfaced {\ifsecondargument \singleexpandafter\strc_counters_next_two \else\iffirstargument \doubleexpandafter\strc_counters_next_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_subs_interfaced {\ifsecondargument \singleexpandafter\strc_counters_subs_two \else\iffirstargument \doubleexpandafter\strc_counters_subs_one \else \doubleexpandafter\gobbletwooptionals \fi\fi} \def\strc_counters_save_interfaced {\iffirstargument \expandafter\strc_counters_save_one \else \expandafter\gobbleoneoptional \fi} \def\strc_counters_restore_interfaced {\iffirstargument \expandafter\strc_counters_restore_one \else \expandafter\gobbleoneoptional \fi} \def\strc_counters_set_two [#1][#2][#3]{\strc_counters_set_sub {#1}{#2}{#3}} \def\strc_counters_setown_two [#1][#2][#3]{\strc_counters_setown_sub {#1}{#2}{#3}} \def\strc_counters_restart_two [#1][#2][#3]{\strc_counters_restart_sub {#1}{#2}{#3}} \def\strc_counters_reset_two [#1][#2]{\strc_counters_reset_sub {#1}{#2}} \def\strc_counters_increment_two [#1][#2]{\strc_counters_increment_sub{#1}{#2}} \def\strc_counters_decrement_two [#1][#2]{\strc_counters_decrement_sub{#1}{#2}} \def\strc_counters_raw_two [#1][#2]{\strc_counters_raw_sub {#1}{#2}} \def\strc_counters_last_two [#1][#2]{\strc_counters_last_sub {#1}{#2}} \def\strc_counters_first_two [#1][#2]{\strc_counters_first_sub {#1}{#2}} \def\strc_counters_next_two [#1][#2]{\strc_counters_next_sub {#1}{#2}} \def\strc_counters_prev_two [#1][#2]{\strc_counters_prev_sub {#1}{#2}} \def\strc_counters_subs_two [#1][#2]{\strc_counters_subs_sub {#1}{#2}} \def\strc_counters_set_one [#1][#2][#3]{\strc_counters_set_sub {#1}\plusone{#2}} \def\strc_counters_setown_one [#1][#2][#3]{\strc_counters_setown_sub {#1}\plusone{#2}} \def\strc_counters_restart_one [#1][#2][#3]{\strc_counters_restart_sub {#1}\plusone{#2}} \def\strc_counters_reset_one [#1][#2]{\strc_counters_reset_sub {#1}\plusone} \def\strc_counters_increment_one [#1][#2]{\strc_counters_increment_sub{#1}\plusone} \def\strc_counters_decrement_one [#1][#2]{\strc_counters_decrement_sub{#1}\plusone} \def\strc_counters_raw_one [#1][#2]{\strc_counters_raw_sub {#1}\plusone} \def\strc_counters_last_one [#1][#2]{\strc_counters_last_sub {#1}\plusone} \def\strc_counters_first_one [#1][#2]{\strc_counters_first_sub {#1}\plusone} \def\strc_counters_next_one [#1][#2]{\strc_counters_next_sub {#1}\plusone} \def\strc_counters_prev_one [#1][#2]{\strc_counters_prev_sub {#1}\plusone} \def\strc_counters_subs_one [#1][#2]{\strc_counters_subs_sub {#1}\plusone} \def\strc_counters_save_one [#1]{\strc_counters_save {#1}} \def\strc_counters_restore_one [#1]{\strc_counters_restore {#1}} \unexpanded\def\strc_counters_set #1#2{\strc_counters_set_sub {#1}\plusone{#2}} \unexpanded\def\strc_counters_setown #1#2{\strc_counters_setown_sub {#1}\plusone{#2}} \unexpanded\def\strc_counters_restart #1#2{\strc_counters_restart_sub {#1}\plusone{#2}} \unexpanded\def\strc_counters_reset #1{\strc_counters_reset_sub {#1}\plusone} \unexpanded\def\strc_counters_increment #1{\strc_counters_increment_sub{#1}\plusone} \unexpanded\def\strc_counters_decrement #1{\strc_counters_decrement_sub{#1}\plusone} \def\strc_counters_raw #1{\strc_counters_raw_sub {#1}\plusone} \def\strc_counters_last #1{\strc_counters_last_sub {#1}\plusone} \def\strc_counters_first #1{\strc_counters_first_sub {#1}\plusone} \def\strc_counters_next #1{\strc_counters_next_sub {#1}\plusone} \def\strc_counters_prev #1{\strc_counters_prev_sub {#1}\plusone} \def\strc_counters_subs #1{\strc_counters_subs_sub {#1}\plusone} \unexpanded\def\strc_counters_set_sub #1#2#3{\ctxcommand{setcounter ("\strc_counters_the{#1}",\number#2,\number#3)}} \unexpanded\def\strc_counters_setown_sub #1#2#3{\ctxcommand{setowncounter ("\strc_counters_the{#1}",\number#2,"#3")}} \unexpanded\def\strc_counters_restart_sub #1#2#3{\ctxcommand{restartcounter("\strc_counters_the{#1}",\number#2,\number#3)}} \unexpanded\def\strc_counters_reset_sub #1#2{\ctxcommand{resetcounter ("\strc_counters_the{#1}",\number#2)}} \unexpanded\def\strc_counters_increment_sub #1#2{\ctxcommand{addcounter ("\strc_counters_the{#1}",\number#2,1)}} \unexpanded\def\strc_counters_decrement_sub #1#2{\ctxcommand{addcounter ("\strc_counters_the{#1}",\number#2,-1)}} \def\strc_counters_raw_sub #1#2{\ctxcommand{countervalue ("\strc_counters_the{#1}",\number#2)}} % maybe raw \def\strc_counters_last_sub #1#2{\ctxcommand{lastcountervalue ("\strc_counters_the{#1}",\number#2)}} \def\strc_counters_first_sub #1#2{\ctxcommand{firstcountervalue ("\strc_counters_the{#1}",\number#2)}} \def\strc_counters_next_sub #1#2{\ctxcommand{nextcountervalue ("\strc_counters_the{#1}",\number#2)}} \def\strc_counters_prev_sub #1#2{\ctxcommand{previouscountervalue("\strc_counters_the{#1}",\number#2)}} \def\strc_counters_subs_sub #1#2{\ctxcommand{subcountervalues ("\strc_counters_the{#1}",\number#2)}} \unexpanded\def\strc_counters_save #1{\ctxcommand{savecounter ("\strc_counters_the{#1}")}} \unexpanded\def\strc_counters_restore #1{\ctxcommand{restorecounter("\strc_counters_the{#1}")}} \unexpanded\def\strc_counters_incremented #1{\ctxcommand{incrementedcounter("\strc_counters_the{#1}",1, 1)}} \unexpanded\def\strc_counters_decremented #1{\ctxcommand{incrementedcounter("\strc_counters_the{#1}",1,-1)}} \unexpanded\def\showcounter [#1]{\ctxcommand{tracecounter("\strc_counters_the{#1}")}} \unexpanded\def\incrementedcounter [#1]{\strc_counters_incremented{#1}} % expandable, no \dosingleargument \unexpanded\def\decrementedcounter [#1]{\strc_counters_decremented{#1}} % expandable, no \dosingleargument % public variants ... beware, for old cases, from now on the value variants are the % ones that are expandable \def\rawcountervalue [#1]{\strc_counters_raw_sub {#1}\plusone} \def\lastcountervalue [#1]{\strc_counters_last_sub {#1}\plusone} \def\firstcountervalue[#1]{\strc_counters_first_sub{#1}\plusone} \def\nextcountervalue [#1]{\strc_counters_next_sub {#1}\plusone} \def\prevcountervalue [#1]{\strc_counters_prev_sub {#1}\plusone} \let\rawsubcountervalue \strc_counters_raw_two \let\lastsubcountervalue \strc_counters_last_two \let\firstsubcountervalue\strc_counters_first_two \let\nextsubcountervalue \strc_counters_next_two \let\prevsubcountervalue \strc_counters_prev_two % The bypage check needs a multipass reference and therefore we only check for it when we increment % and know that some content will be placed. We could also check for spreads. \unexpanded\def\strc_counters_increment_sub#1#2% {% this will be combined into one lua call \edef\m_strc_counters_way{\strc_counters_way{#1}}% \ifx\m_strc_counters_way\v!page \checkpagechange{#1}% \ifpagechanged \strc_counters_reset{#1}% \fi \fi \ctxcommand{addcounter("\strc_counters_the{#1}",\number#2,1)}} \unexpanded\def\convertedcounter {\dodoubleempty\strc_counters_converted} \def\strc_counters_converted[#1][#2]% {\begingroup \ifsecondargument\getparameters[\??counter#1][#2]\fi \ctxlua{structures.sections.prefixedconverted( "\strc_counters_the{#1}", { prefix = "\counterparameter{#1}\c!prefix", separatorset = "\counterparameter{#1}\c!prefixseparatorset", conversion = "\counterparameter{#1}\c!prefixconversion", conversionset = "\counterparameter{#1}\c!prefixconversionset", starter = \!!bs\counterparameter{#1}\c!prefixstarter\!!es, stopper = \!!bs\counterparameter{#1}\c!prefixstopper\!!es, set = "\counterparameter{#1}\c!prefixset", segments = "\counterparameter{#1}\c!prefixsegments", connector = \!!bs\counterparameter{#1}\c!prefixconnector\!!es, }, { order = "\counterparameter{#1}\c!numberorder", separatorset = "\counterparameter{#1}\c!numberseparatorset", conversion = \!!bs\counterparameter{#1}\c!numberconversion\!!es, conversionset = "\counterparameter{#1}\c!numberconversionset", starter = \!!bs\counterparameter{#1}\c!numberstarter\!!es, stopper = \!!bs\counterparameter{#1}\c!numberstopper\!!es, segments = "\counterparameter{#1}\c!numbersegments", type = "\counterparameter{#1}\c!type", criterium = "\counterparameter{#1}\c!criterium", % might change if we also want this with sectioning } )}% \endgroup} \def\directconvertedcounter#1#2% name, type {\ctxlua{structures.sections.prefixedconverted( "\strc_counters_the{#1}", { prefix = "\counterparameter{#1}\c!prefix", separatorset = "\counterparameter{#1}\c!prefixseparatorset", conversion = "\counterparameter{#1}\c!prefixconversion", conversionset = "\counterparameter{#1}\c!prefixconversionset", % starter = \!!bs\counterparameter{#1}\c!prefixstarter\!!es, % stopper = \!!bs\counterparameter{#1}\c!prefixstopper\!!es, set = "\counterparameter{#1}\c!prefixset", segments = "\counterparameter{#1}\c!prefixsegments", connector = \!!bs\counterparameter{#1}\c!prefixconnector\!!es, }, { order = "\counterparameter{#1}\c!numberorder", separatorset = "\counterparameter{#1}\c!numberseparatorset", conversion = \!!bs\counterparameter{#1}\c!numberconversion\!!es, conversionset = "\counterparameter{#1}\c!numberconversionset", starter = \!!bs\counterparameter{#1}\c!numberstarter\!!es, stopper = \!!bs\counterparameter{#1}\c!numberstopper\!!es, segments = "\counterparameter{#1}\c!numbersegments", type = "#2", } )}} \unexpanded\def\convertedsubcounter {\dotripleempty\strc_counters_converted_sub} \def\strc_counters_converted_sub[#1][#2][#3]% #2 can be n or n:m {\ifsecondargument \strc_counters_converted[#1][\c!numbersegments=#2,#3]% \else \secondargumentfalse\strc_counters_converted[#1][]% \fi} \unexpanded\def\doifdefinedcounter#1% {\ifcsname\s!number#1\c!number\endcsname \expandafter\firstofoneargument \else \expandafter\gobbleoneargument \fi} \unexpanded\def\doifundefinedcounter#1% {\ifcsname\s!number#1\c!number\endcsname \expandafter\gobbleoneargument \else \expandafter\firstofoneargument \fi} \unexpanded\def\doifdefinedcounterelse#1% {\ifcsname\s!number#1\c!number\endcsname \expandafter\firstoftwoarguments \else \expandafter\secondoftwoarguments \fi} %D What follows is a compatibility layer. \let \numberparameter \counterparameter % {name}\c!key \let \definenumber \definecounter % [name] \let \setupnumber \setupcounter % [name][setups] \let \setnumber \setcounter % [name]{value} \let \resetnumber \resetcounter % [name] \let \savenumber \savecounter % [name] \let \restorenumber \restorecounter % [name] \let \incrementnumber \incrementcounter % [name] \let \decrementnumber \decrementcounter % [name] \let \rawnumber \rawcounter % [name] \let \getnumber \convertedcounter % [name] \let \convertednumber \convertedcounter % [name] \let \doifdefinednumber \doifdefinedcounter % {number}{true} \let \doifundefinednumber \doifnotdefinedcounter % {number}{true} \let \doifdefinednumberelse \doifdefinedcounterelse % {number}{true}{false} \let \setupnumbering \setupstructurecounting %D Helpers: % call: % % \strc_counters_register_component % \currentfloat % \getfloatparameters \floatparameter \detokenizedfloatparameter % \hascaption \hastitle \hasnumber % [settings][userdata] % % sets: % % \m_strc_counters_last_registered_index % \m_strc_counters_last_registered_attribute % \m_strc_counters_last_registered_synchronize \newconditional\hascountercaption \newconditional\hascountertitle \newconditional\hascounternumber \unexpanded\def\strc_counters_register_component#1#2#3#4#5#6#7[#8][#9]% maybe also nolist {\begingroup % #2[\s!haslevel=1,#8]% \edef\hascounterlevel {#3\s!haslevel}% \edef\hascountercaption{#3\s!hascaption}% \edef\hascountertitle {#3\s!hastitle}% \edef\hascounternumber {#3\s!hasnumber}% % \edef\askedprefixsegments{#3\c!prefixsegments}% \ifx\askedprefixsegments\v!auto \edef\askedprefixsegments{\autostructureprefixsegments#3}% \fi % \edef\currentname{#3\c!name}% \ifx\currentname\empty \edef\currentname{#1}% \fi \edef\currentcounter{#3\s!counter}% \ifx\currentcounter\empty \let\currentcounter\currentname \fi % \ifx\hascountercaption\v!yes \xdef\currentstructurecomponentname {#3\c!name}% \xdef\currentstructurecomponentlevel {#3\c!level}% \edef\currentstructurecomponentexpansion {#3\c!expansion}% \xdef\currentstructurecomponentxmlsetup {#3\c!xmlsetup}% \xdef\currentstructurecomponentcatcodes {#3\s!catcodes}% \xdef\currentstructurecomponentlabel {#3\c!label}% \xdef\currentstructurecomponentreference {#3\c!reference}% \xdef\currentstructurecomponentreferenceprefix{#3\c!referenceprefix}% \ifx\currentstructurecomponentexpansion\s!xml \xmlstartraw \xdef\currentstructurecomponenttitle {#3\c!title}% \xdef\currentstructurecomponentbookmark{#3\c!bookmark}% \xdef\currentstructurecomponentmarking {#3\c!marking}% \xdef\currentstructurecomponentlist {#3\c!list}% \xmlstopraw \ifx\currentstructurecomponentlist\empty \globallet\currentstructurecomponentlist\currentstructurecomponenttitle \fi \globallet\currentstructurecomponentcoding\s!xml \else \ifx\currentstructurecomponentexpansion\v!yes \xdef\currentstructurecomponenttitle {#3\c!title}% \xdef\currentstructurecomponentbookmark{#3\c!bookmark}% \xdef\currentstructurecomponentmarking {#3\c!marking}% \xdef\currentstructurecomponentlist {#3\c!list}% \else \xdef\currentstructurecomponenttitle {#4\c!title}% \xdef\currentstructurecomponentbookmark{#4\c!bookmark}% \xdef\currentstructurecomponentmarking {#4\c!marking}% \xdef\currentstructurecomponentlist {#4\c!list}% \iflocation \ifx\currentstructurecomponentbookmark\empty \begingroup \simplifycommands \xdef\currentstructurecomponentbookmark{\detokenize\expandafter{\normalexpanded{#3\c!title}}}% \endgroup \fi \fi \fi \ifx\currentstructurecomponentlist\empty \globallet\currentstructurecomponentlist\currentstructurecomponenttitle \fi \globallet\currentstructurecomponentcoding\s!tex \fi % \setnextinternalreference \xdef\m_strc_counters_last_registered_index{\ctxcommand{addtolist{ metadata = { kind = "#1", name = "\currentname", level = structures.sections.currentlevel(), catcodes = \the\ifx\currentstructurecomponentcatcodes\empty\catcodetable\else\csname\currentstructurecomponentcatcodes\endcsname\fi, coding = "\currentstructurecomponentcoding", \ifx\currentstructurecomponentcoding\s!xml xmlroot = "\xmldocument", \fi \ifx\currentstructurecomponentxmlsetup\empty \else xmlsetup = "\currentstructurexmlsetup", \fi }, references = { internal = \nextinternalreference, block = "\currentsectionblock", reference = "\currentstructurecomponentreference", referenceprefix = "\currentstructurecomponentreferenceprefix", section = structures.sections.currentid(), }, titledata = { label = \!!bs\detokenize\expandafter{\currentstructurecomponentlabel }\!!es, title = \!!bs\detokenize\expandafter{\currentstructurecomponenttitle }\!!es, \ifx\currentstructurecomponentbookmark\currentstructurecomponenttitle \else bookmark = \!!bs\detokenize\expandafter{\currentstructurecomponentbookmark }\!!es, \fi \ifx\currentstructurecomponentmarking\currentstructurecomponenttitle \else marking = \!!bs\detokenize\expandafter{\currentstructurecomponentmarking }\!!es, \fi \ifx\currentstructurecomponentlist\currentstructurecomponenttitle \else list = \!!bs\detokenize\expandafter{\currentstructurecomponentlist}\!!es, \fi }, \ifx\hascounternumber\v!yes prefixdata = { prefix = "#3\c!prefix", separatorset = "#3\c!prefixseparatorset", conversion = \!!bs#3\c!prefixconversion\!!es, conversionset = "#3\c!prefixconversionset", set = "#3\c!prefixset", % segments = "#3\c!prefixsegments", segments = "\askedprefixsegments", connector = \!!bs#3\c!prefixconnector\!!es, }, numberdata = { numbers = structures.counters.compact("\currentcounter",nil,true), separatorset = "#3\c!numberseparatorset", conversion = \!!bs#3\c!numberconversion\!!es, conversionset = "#3\c!numberconversionset", starter = \!!bs#3\c!numberstarter\!!es, stopper = \!!bs#3\c!numberstopper\!!es, segments = "#3\c!numbersegments", }, \fi userdata = \!!bs\detokenize{#9}\!!es % will be converted to table at the lua end } }}% \xdef\m_strc_counters_last_registered_attribute {\ctxlua {tex.write(structures.references.setinternalreference(nil,nil,\nextinternalreference))}}% \xdef\m_strc_counters_last_registered_synchronize{\ctxlatecommand{enhancelist(\m_strc_counters_last_registered_index)}}% \else \glet\m_strc_counters_last_registered_index \relax \glet\m_strc_counters_last_registered_attribute \attributeunsetvalue \glet\m_strc_counters_last_registered_synchronize\relax \fi \endgroup} \let\m_strc_counters_last_registered_index \relax \let\m_strc_counters_last_registered_attribute \relax \let\m_strc_counters_last_registered_synchronize\relax \def\strc_counter_setup_using_parameter#1#2% name \someparameter {\setupcounter [#1] [ \c!start=#2\c!start, \c!state=#2\c!state, % beware, "" == start \c!way=#2\c!way, % \c!prefix=#2\c!prefix, \c!prefixseparatorset=#2\c!prefixseparatorset, \c!prefixconversion=#2\c!prefixconversion, \c!prefixconversionset=#2\c!prefixconversionset, \c!prefixstarter=#2\c!prefixstarter, \c!prefixstopper=#2\c!prefixstopper, \c!prefixset=#2\c!prefixset, \c!prefixsegments=#2\c!prefixsegments, \c!prefixset=#2\c!prefixset, \c!prefixconnector=#2\c!prefixconnector, % \c!numberseparatorset=#2\c!numberseparatorset, \c!numberconversion=#2\c!numberconversion, \c!numberconversionset=#2\c!numberconversionset, \c!numberstarter=#2\c!numberstarter, \c!numberstopper=#2\c!numberstopper, \c!numbersegments=#2\c!numbersegments]} \def\strc_counter_preset_using_parameter#1#2% \setupcommand \someparameter {#1% [\c!way =#2\c!way, \c!prefix =#2\c!prefix, \c!prefixseparatorset =#2\c!prefixseparatorset, \c!prefixconversion =#2\c!prefixconversion, \c!prefixconversionset=#2\c!prefixconversionset, \c!prefixstarter =#2\c!prefixstarter, \c!prefixstopper =#2\c!prefixstopper, \c!prefixsegments =#2\c!prefixsegments, \c!prefixset =#2\c!prefixset, \c!prefixconnector =#2\c!prefixconnector, \c!numberseparatorset =#2\c!numberseparatorset, \c!numberconversion =#2\c!numberconversion, \c!numberconversionset=#2\c!numberconversionset, \c!numberstarter =#2\c!numberstarter, \c!numberstopper =#2\c!numberstopper, \c!numbersegments =#2\c!numbersegments]} \protect \endinput