diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-sec.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-sec.mkiv | 244 |
1 files changed, 167 insertions, 77 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-sec.mkiv b/Master/texmf-dist/tex/context/base/strc-sec.mkiv index ddc601eb831..35927d98a00 100644 --- a/Master/texmf-dist/tex/context/base/strc-sec.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-sec.mkiv @@ -41,12 +41,14 @@ % lua interface / names and interface might change -\def\setstructurelevel #1#2{\ctxlua{structure.sections.setlevel("#1","#2")}} % name, level|parent -\def\getstructurelevel #1{\ctxlua{structure.sections.getcurrentlevel("#1")}}% name -\def\setstructurenumber #1#2{\ctxlua{structure.sections.setnumber(#1,"#2")}} % level, number (+/-) -\def\getstructurenumber #1{\ctxlua{structure.sections.getnumber(#1)}} % level -\def\getfullstructurenumber #1{\ctxlua{structure.sections.fullnumber(#1)}} % level -\def\getspecificstructuretitle#1{\ctxlua{structure.sections.structuredata(#1,"titledata.title",nil,"\structureheadparameter\s!catcodes")}}% +\def\setstructurelevel #1#2{\ctxlua{structure.sections.setlevel("#1","#2")}} % name, level|parent +\def\getstructurelevel #1{\ctxlua{structure.sections.getcurrentlevel("#1")}}% name +\def\setstructurenumber #1#2{\ctxlua{structure.sections.setnumber(#1,"#2")}} % level, number (+/-) +\def\getstructurenumber #1{\ctxlua{structure.sections.getnumber(#1)}} % level +\def\getsomestructurenumber #1#2{\ctxlua{structure.sections.getnumber(#1,"#2")}} % level, what +\def\getfullstructurenumber #1{\ctxlua{structure.sections.fullnumber(#1)}} % level +\def\getsomefullstructurenumber#1#2{\ctxlua{structure.sections.fullnumber(#1,"#2")}} +\def\getspecificstructuretitle #1{\ctxlua{structure.sections.structuredata(#1,"titledata.title",nil,"\structureheadparameter\s!catcodes")}}% % interface @@ -59,6 +61,8 @@ \def\dostructureheadparentparameter #1#2{\ifx#1\relax\s!empty\else\dostructureheadparameter #1#2\fi} \def\dostructureheadparentparameterhash#1#2{\ifx#1\relax \else\dostructureheadparameterhash#1#2\fi} +\def\structureheadparameterstrict#1{\csname\ifcsname\??nh\currentstructurehead#1\endcsname\??nh\currentstructurehead#1\else\s!empty\fi\endcsname} + \def\dosetstructureheadattributes#1#2% style color {\edef\fontattributehash {\structureheadparameterhash#1}% \edef\colorattributehash{\structureheadparameterhash#2}% @@ -71,22 +75,30 @@ \let\laststructuresectionname\empty -\def\definestructuresection[#1]% +\unexpanded\def\definestructuresection[#1]% {\doifundefined{\??nh#1} {\global\advance\maxstructuredepth\plusone \setevalue{\??nh#1\c!level}{\the\maxstructuredepth}% \setstructurelevel{#1}{\the\maxstructuredepth}% -% \letvalue{\??nh#1\c!marking}\empty % ? +% \letvalue{\??nh#1\c!marking}\empty % ? %\writestatus{structure}{#1\ifx\laststructuresectionname\empty\else\space->\space\laststructuresectionname\fi}% \normalexpanded{\noexpand\getparameters[\??nh#1][\s!parent=\??nh\laststructuresectionname]}% + % this is a rather practical default that we don't want to be part of the parent chain + % lookup mechanism; it's also mkii compativle; this might become \everystructureheaddefine + \getparameters[\??nh#1] + [ \c!textstyle=\structureheadparameterstrict\c!style, + \c!textcolor=\structureheadparameterstrict\c!color, + \c!numberstyle=\structureheadparameterstrict\c!style, + \c!numbercolor=\structureheadparameterstrict\c!color]% + % so far for these default inheritances \definemarking[#1]% \ifnum\maxstructuredepth>\plusone -% \normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent +% \normalexpanded{\noexpand\couplemarking[#1][\laststructuresectionname]}% so, the child inherits settings from the parent \normalexpanded{\noexpand\relatemarking[#1][\laststructuresectionname]}% so, the parent will reset the child \fi \xdef\laststructuresectionname{#1}}} -\def\setupstructuresection +\unexpanded\def\setupstructuresection {\dotripleempty\dosetupstructuresection} \def\dosetupstructuresection[#1]% @@ -102,16 +114,18 @@ \fi} \def\structuresectionlevel#1% - {\executeifdefined{\??nh#1\c!level}0} + {\executeifdefined{\??nh#1\c!level}{-1}} + +\setvalue{\??nh block\c!level}{0} % -1 == manual % head -> structurehead \let\currentstructurehead\empty \newtoks\everystructureheadsetup -\def\setupstructureheads{\dosingleargument\dosetupstructureheads} -\def\setupstructurehead {\dodoubleempty\dosetupstructurehead} -\def\definestructurehead{\dodoubleempty\dodefinestructurehead} +\unexpanded\def\setupstructureheads{\dosingleargument\dosetupstructureheads} +\unexpanded\def\setupstructurehead {\dodoubleempty\dosetupstructurehead} +\unexpanded\def\definestructurehead{\dodoubleempty\dodefinestructurehead} \newif\ifsectionnumber % maybe conditional @@ -254,6 +268,7 @@ \newconditional\structureheaddoincrement \newconditional\structureheaddoplace \newconditional\structureheadleaveempty +\newconditional\structureheadhidden \newconditional\structureheadshownumber \newconditional\structureheadisdisplay @@ -302,11 +317,13 @@ \def\setstructureheadplacement {\settrue\structureheaddoplace \setfalse\structureheadleaveempty + \setfalse\structureheadhidden \processaction [\structureheadparameter\c!placehead] [ \v!yes=>, \v!empty=>\settrue\structureheadleaveempty, - \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace]} + \v!no=>\settrue\structureheadleaveempty\setfalse\structureheaddoplace, + \v!hidden=>\settrue\structureheadhidden\settrue\structureheadleaveempty\setfalse\structureheaddoplace]} \def\setstructureheaddisplay {\doifelsevalue{\??nh:\structureheadparameter\c!alternative}\v!horizontal @@ -332,16 +349,17 @@ \setfalse\structureheadshownumber \fi} -\def\thestructureheadsynchonization +\unexpanded\def\thestructureheadsynchonization {\pagetype[\currentstructureheadcoupling]% hm also number \normalexpanded{\noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}}% \currentstructuresynchronize} -\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo -\def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode! +\unexpanded\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo + +% \def\fullstructureheadtitle {\structurevariable{titledata.title}} % no catcode! +% \unexpanded\def\fullstructureheadtitle{\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}} -\unexpanded\def\fullstructureheadtitle - {\structureautocatcodedget{titledata.title}{\structureheadparameter\s!catcodes}} +\unexpanded\def\fullstructureheadtitle{\ctxlua{structure.sections.title()}} \let\currentstructurehead \empty \let\currentstructureheadcoupling\empty @@ -356,15 +374,18 @@ \c!saveinlist=\ifconditional\structureheadtolist\v!yes\else\v!no\fi, \c!level=\currentstructureheadlevel, \c!name=#1, - \c!number=\ifconditional\structureheadshownumber\v!yes\else\v!no\fi, + \c!number=\ifconditional\structureheaddoincrement\ifconditional\structureheadshownumber\v!yes\else\v!no\fi\else\v!no\fi, \c!bookmark=, \c!marking=, \c!list=, \c!expansion=\structureheadparameter\c!expansion, + \c!xmlsetup=\structureheadparameter\c!xmlsetup, + \s!catcodes=\structureheadparameter\s!catcodes, \c!sectionresetset=\structureheadparameter\c!sectionresetset, \c!sectionseparatorset=\structureheadparameter\c!sectionseparatorset, \c!sectionconversionset=\structureheadparameter\c!sectionconversionset, \c!sectionconversion=\structureheadparameter\c!conversion, % just for compatibility + \c!sectionstarter=\structureheadparameter\c!sectionstarter, \c!sectionstopper=\structureheadparameter\c!sectionstopper, \c!sectionset=\structureheadparameter\c!sectionset, \c!sectionsegments=\structureheadparameter\c!sectionsegments, @@ -378,14 +399,21 @@ \unexpanded\def\placeheadtext {\dosingleempty\doplaceheadtext } % use with care \unexpanded\def\placeheadnumber{\dosingleempty\doplaceheadnumber} % use with care +\ifdefined\setupheadcomponentfont \else + + \unexpanded\def\setupheadcomponentfont#1#2% + {\dosetstructureheadattributes\c!style\c!color + \dosetstructureheadattributes#1#2% + \dontconvertfont + \setupinterlinespace} + +\fi + \def\doplaceheadtext[#1]% {\dontleavehmode \begingroup \edef\currentstructurehead{#1}% - \dosetstructureheadattributes\c!style\c!color - \dosetstructureheadattributes\c!textstyle\c!textcolor - \dontconvertfont - \setupinterlinespace + \setupheadcomponentfont\c!textstyle\c!textcolor \relax \getspecificstructuretitle{\thenamedstructureheadlevel{#1}}% \endgraf @@ -395,15 +423,14 @@ {\dontleavehmode \begingroup \edef\currentstructurehead{#1}% - \dosetstructureheadattributes\c!style\c!color - \dosetstructureheadattributes\c!numberstyle\c!numbercolor - \dontconvertfont - \setupinterlinespace + \setupheadcomponentfont\c!numberstyle\c!numbercolor \relax \getfullstructurenumber{\thenamedstructureheadlevel{#1}}% \endgraf \endgroup} +\ifdefined \else \let\presetnumberheadalternative\relax \fi + \def\dohandlestructurehead#1#2#3% name data userdata {\xdef\currentstructurehead {#1}% \xdef\currentstructureheadcoupling{\structuresectionheadcoupling\currentstructurehead}% @@ -432,6 +459,7 @@ % \edef\numberheaddistance {\structureheadparameter\c!distance }% compatibility \edef\numberheadalternative{\structureheadparameter\c!alternative}% compatibility + \presetnumberheadalternative % \let\getstructureheadnumber\empty \let\getstructureheadtitle \empty @@ -449,13 +477,17 @@ \placestructureheadtext \fi \dostructureheadspacingafteryes + \else\ifconditional\structureheadhidden + \doregisterstructurehead{#1}{#2}{#3}% after optional \page + \let\getstructureheadsyncs\thestructureheadsynchonization + \placestructureheadhidden % only something when tracing \else \dostructureheadspacingbeforenop % toegevoegd ivm subpaginanr / tug sheets \doregisterstructurehead{#1}{#2}{#3}% after optional \page \let\getstructureheadsyncs\thestructureheadsynchonization - \placestructureheadnothing % just flush 'm + \placestructureheadempty % just flush 'm \dostructureheadspacingafternop - \fi + \fi\fi \else \ifconditional\structureheaddoplace \dostructureheadspacingbeforeyes @@ -464,14 +496,18 @@ \let\getstructureheadtitle\fullstructureheadtitle \placestructureheadtext \dostructureheadspacingafteryes + \else\ifconditional\structureheadhidden + \doregisterstructurehead{#1}{#2}{#3}% after optional \page + \let\getstructureheadsyncs\thestructureheadsynchonization + \placestructureheadhidden % only something when tracing \else % do nothing / should be vbox to 0pt \dostructureheadspacingbeforenop \doregisterstructurehead{#1}{#2}{#3}% after optional \page \let\getstructureheadsyncs\thestructureheadsynchonization - \placestructureheadnothing % just flush 'm + \placestructureheadempty % just flush 'm \dostructureheadspacingafternop - \fi + \fi\fi \fi \flushingcolumnfloatstrue \setfalse\ignorehandlepagebreak @@ -484,28 +520,54 @@ % typesetting -\def\placestructureheadnumbertext % dummy, will be overloaded +\unexpanded\def\placestructureheadnumbertext % dummy, will be overloaded {\getstructureheadnumber/\getstructureheadtitle \getstructureheadsyncs} -\def\placestructureheadtext % dummy, will be overloaded +\unexpanded\def\placestructureheadtext % dummy, will be overloaded {\getstructureheadtitle \getstructureheadsyncs} -\def\placestructureheadnothing % dummy, will be overloaded +\unexpanded\def\placestructureheadempty % dummy, will be overloaded {\getstructureheadsyncs} +\unexpanded\def\placestructureheadhidden + {\setxvalue{\currentstructurehead:sync}% + {\noexpand\pagetype[\currentstructureheadcoupling]% hm also number + \noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}% + \currentstructuresynchronize}} + +\def\synchronizestructurehead#1% + {\getvalue{#1:sync}} + +\unexpanded\def\placerawheaddata [#1]{\synchronizestructurehead {#1}} +\unexpanded\def\placerawheadtext [#1]{\getspecificstructuretitle{\thenamedstructureheadlevel{#1}}} +\unexpanded\def\placerawheadnumber[#1]{\getfullstructurenumber {\thenamedstructureheadlevel{#1}}} + +% \setuphead[chapter][placehead=hidden] +% \chapter {test} +% +% %(\synchronizestructurehead{chapter}) % \getstructureheadsyncs +% %(\getfullstructurenumber{\thenamedstructureheadlevel{chapter}}) +% %(\getspecificstructuretitle{\thenamedstructureheadlevel{chapter}}) +% +% (\placerawheaddata [chapter]) +% (\placerawheadnumber[chapter]) +% (\placerawheadtext [chapter]) + % pagebreaks \newcount\precedingstructurelevel \precedingstructurelevel\plusone \newconditional\ignorehandlepagebreak \def\dostructureheadspacingbeforeyes - {\docheckstructureheadbefore\dohandlestructureheadpagebreak + {\docheckstructureheadbefore + \dohandlestructureheadpagebreak \structureheadparameter\c!inbetween} \def\dostructureheadspacingbeforenop - {\docheckstructureheadbefore\docheckstructureheadlayout + {\docheckstructureheadbefore + \docheckstructureheadlayout \structureheadparameter\c!inbetween} % \def\emptystructureheadcorrection @@ -579,7 +641,7 @@ \setfalse\ignorehandlepagebreak \else \ifnum\lastpenalty>\zerocount - \global\pagebreakdisabledtrue +% \global\pagebreakdisabledtrue \fi % beware, these numbers are not yet know here \doifelse{\structureheadparameter\c!continue}\v!yes @@ -592,53 +654,70 @@ \doifnot{\structureheadparameter\c!aligntitle}\v!float\flushsidefloats \structureheadparameter\c!before \relax - \ifpagebreakdisabled - \global\pagebreakdisabledfalse - \else +% \ifpagebreakdisabled +% \global\pagebreakdisabledfalse +% \else \dopreventbreakafterstructureheadauto - \fi +% \fi \doif{\structureheadparameter\c!aligntitle}\v!float\indent \global\precedingstructurelevel\currentstructureheadlevel \fi} % the next one was: \somebreakmethod -\chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing +% \chardef\somestructureheadbreakmethod\plusone % 0=nothing, 1=weighted, 2=strict, 3=vspacing +\chardef\somestructureheadbreakmethod\plusthree + +% \def\dopreventbreakafterstructureheadauto % used after \c!before +% {\ifcase\somestructureheadbreakmethod +% % 0 = nothing +% \or +% % 1 = old weighted version +% \ifnum\currentstructureheadlevel>\precedingstructurelevel +% \dosomebreak{\penalty\numexpr20000+500*\currentstructureheadlevel\relax}% +% \else +% \dosomebreak\allowbreak % brr +% \fi +% \or +% % 2 = strict version +% \dosomebreak{\penalty\maxdimen}% +% \or +% % 3 = vspacing +% \vspacing[\v!samepage]% if preceded by ! then a loop +% \else +% % nothing +% \fi} +% +% \def\dopreventbreakafterstructureheadspec#1% see enumerations etc +% {\ifcase\somestructureheadbreakmethod +% % 0 = nothing +% \or +% % 1 = old weighted version +% \dosomebreak{\penalty\numexpr20000+500*(\currentstructureheadlevel+#1)\relax}% +% \or +% % 2 = strict version +% \dosomebreak{\penalty\maxdimen}% +% \or +% % 3 = vspacing +% \vspacing[\v!samepage]% +% \else +% % nothing +% \fi} +% +% todo: \vspacing[category:8] == keep_together \def\dopreventbreakafterstructureheadauto % used after \c!before {\ifcase\somestructureheadbreakmethod % 0 = nothing - \or - % 1 = old weighted version - \ifnum\currentstructureheadlevel>\precedingstructurelevel - \dosomebreak{\penalty\numexpr20000+500*\currentstructureheadlevel\relax}% - \else - \dosomebreak\allowbreak % brr - \fi - \or - % 2 = strict version - \dosomebreak{\penalty\maxdimen}% - \or - % 3 = vspacing - \vspacing[\v!samepage]% if preceded by ! then a loop \else - % nothing + \vspacing[\v!samepage-\currentstructureheadlevel]% \fi} \def\dopreventbreakafterstructureheadspec#1% see enumerations etc {\ifcase\somestructureheadbreakmethod % 0 = nothing - \or - % 1 = old weighted version - \dosomebreak{\penalty\numexpr20000+500*(\currentstructureheadlevel+#1)\relax}% - \or - % 2 = strict version - \dosomebreak{\penalty\maxdimen}% - \or - % 3 = vspacing - \vspacing[\v!samepage]% \else - % nothing + \vspacing[\v!samepage-\the\numexpr\currentstructureheadlevel+1\relax]% todo #1 \fi} \def\dohandlepagebreakX{\dopreventbreakafterstructureheadspec} % no \let so we can redefind @@ -649,13 +728,13 @@ % \chapter{some} \setupheadnumber[chapter][3] \chapter{more} % \setupheadnumber[section][8] \section{b} \section{c} \setupheadnumber[section][-1] \section{d} -\def\thecurrentstructureheadlevel#1% - {\getcurrentstructurelevel{#1}} +% \def\thecurrentstructureheadlevel#1% +% {\getcurrentstructurelevel{#1}} \def\thenamedstructureheadlevel#1% {\structuresectionlevel{\structuresectionheadsection{\structuresectionheadcoupling{#1}}}} -\def\setupheadnumber +\unexpanded\def\setupheadnumber {\dodoubleargument\dosetupheadnumber} \def\dosetupheadnumber[#1][#2]% todo: reset if at other level @@ -663,18 +742,29 @@ \def\currentstructureheadnumber{0} % ==> \currentheadnumber -\def\determineheadnumber[#1]% +\unexpanded\def\determineheadnumber[#1]% {\xdef\currentstructureheadnumber{\getstructurenumber{\thenamedstructureheadlevel{#1}}}} % The previous macro is been replaced by the expandable: -\def\namedheadnumber#1{\getstructurenumber{\thenamedstructureheadlevel{#1}}} +\def\namedheadnumber #1{\getstructurenumber {\thenamedstructureheadlevel{#1}}} +\def\somenamedheadnumber#1#2{\getsomestructurenumber{\thenamedstructureheadlevel{#1}}{#2}} + +\unexpanded\def\structureheadnumber + {\dodoubleempty\dostructureheadnumber} + +\def\dostructureheadnumber[#1][#2]% simple case is just a number + {\getsomefullstructurenumber{\iffirstargument\thenamedstructureheadlevel{#1}\fi}{#2}} -\def\structureheadnumber - {\dosingleempty\dostructureheadnumber} +\def\somestructureheadnumber + {\dodoubleempty\dosomestructureheadnumber} -\def\dostructureheadnumber[#1]% simple case is just a number - {\getfullstructurenumber{\iffirstargument\thecurrentstructureheadlevel{#1}\fi}} +\def\dosomestructureheadnumber[#1][#2]% + {\dontleavehmode + \begingroup + \edef\currentstructurehead{#1}% + \getsomefullstructurenumber{\thenamedstructureheadlevel{#1}}{#2}% + \endgroup} % compatibility code (after all, we might offer different structure handlers as well % but we might as well remove the 'structure' substring at some point (we needed it |