diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ren.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/strc-ren.mkiv | 255 |
1 files changed, 139 insertions, 116 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ren.mkiv b/Master/texmf-dist/tex/context/base/strc-ren.mkiv index 73eb0ccd206..543c55fff67 100644 --- a/Master/texmf-dist/tex/context/base/strc-ren.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-ren.mkiv @@ -5,7 +5,7 @@ %D subtitle=Section Rendering, %D author=Hans Hagen, %D date=\currentdate, -%D copyright=PRAGMA-ADE / Hans Hagen] +%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 @@ -25,47 +25,43 @@ \newevery \everyheadstart \relax -\unexpanded\def\placeheadmargintexts - {\the\everyheadstart - \doif{\structureheadparameter\c!margintext}\v!yes\placemargincontent} - \unexpanded\def\setupheadcomponentfont#1#2% {\dontconvertfont - \ifconditional\structureheadisdisplay - \edef\askedstructureheadinterlinespace{\structureheadparameter\c!interlinespace}% - \ifx\askedstructureheadinterlinespace\empty + \ifconditional\headisdisplay + \edef\askedheadinterlinespace{\headparameter\c!interlinespace}% + \ifx\askedheadinterlinespace\empty % here the interline space is only set when style sets no space - \setfalse\fontattributeisset + \setfalse\fontattributeisset % use the currentfontparameter state instead \setfalse\interlinespaceisset - \dosetstructureheadattributes\c!style\c!color + \useheadstyleandcolor\c!style\c!color \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else \setupinterlinespace \fi \fi - \setfalse\fontattributeisset \dosetstructureheadattributes#1#2% + \setfalse\fontattributeisset \useheadstyleandcolor#1#2% \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else \setupinterlinespace \fi \fi \else % here the set interline space overloads any other set space in the style \setfalse\fontattributeisset - \dosetstructureheadattributes\c!style\c!color + \useheadstyleandcolor\c!style\c!color \ifconditional\fontattributeisset - \dosetupcheckedinterlinespace\askedstructureheadinterlinespace + \dosetupcheckedinterlinespace\askedheadinterlinespace \fi \setfalse\fontattributeisset - \dosetstructureheadattributes#1#2% + \useheadstyleandcolor#1#2% \ifconditional\fontattributeisset - \dosetupcheckedinterlinespace\askedstructureheadinterlinespace + \dosetupcheckedinterlinespace\askedheadinterlinespace \fi \fi \else \setfalse\fontattributeisset - \dosetstructureheadattributes\c!style\c!color + \useheadstyleandcolor\c!style\c!color \ifconditional\fontattributeisset \setupspacing \fi \setfalse\fontattributeisset - \dosetstructureheadattributes#1#2% + \useheadstyleandcolor#1#2% \ifconditional\fontattributeisset \setupspacing \fi @@ -74,23 +70,22 @@ \def\doplaceheadtextcomponent#1% {\begingroup \setupheadcomponentfont\c!textstyle\c!textcolor - \structureheadparameter\c!commandbefore - \placeheadmargintexts - \ifcsname\??nh\currentstructurehead\c!deeptextcommand\endcsname - \expandafter\let\expandafter\deepstructuretitlecommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname + \headparameter\c!commandbefore + \ifcsname\currentheadhash\c!deeptextcommand\endcsname + \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname \fi - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay % \ifdisplaysectionhead % struts can be nilled with \setnostrut - \structureheadparameter\c!textcommand{\setstrut\begstrut#1\endstrut}% + \headparameter\c!textcommand{\setstrut\begstrut#1\endstrut}% \xdef\localheadheight {\the\strutht}% \xdef\localheaddepth {\the\strutdp}% \xdef\localheadlineheight{\the\lineheight}% % == \globallet\localheaddepth\strutdepth \else - \structureheadparameter\c!textcommand{#1}% + \headparameter\c!textcommand{#1}% \fi - \structureheadparameter\c!commandafter - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \headparameter\c!commandafter + \ifconditional\headisdisplay % \ifdisplaysectionhead \endgraf \fi \endgroup} @@ -98,15 +93,14 @@ \def\doplaceheadnumbercomponent#1% {\begingroup \setupheadcomponentfont\c!numberstyle\c!numbercolor - \placeheadmargintexts - \ifcsname\??nh\currentstructurehead\c!deepnumbercommand\endcsname - \expandafter\let\expandafter\deepstructurenumbercommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname + \ifcsname\currentheadhash\c!deepnumbercommand\endcsname + \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname \fi - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay % \ifdisplaysectionhead % can be nilled with \setnostrut - \structureheadparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}% + \headparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}% \else - \structureheadparameter\c!numbercommand{#1}% + \headparameter\c!numbercommand{#1}% \fi \endgroup} @@ -116,74 +110,75 @@ \let\currentstructurereferenceattribute\attributeunsetvalue -\def\structureheadreferenceattributes +\def\headreferenceattributes {\iflocation + % \ctxlua{structures.lists.taglocation(\nextinternalreference)}% maybe ... tags entry as used attr \destinationattribute \currentstructureattribute attr \referenceattribute \currentstructurereferenceattribute % attr \internalattribute \nextinternalreference \fi} -\def\setinlinestructureheadreferenceattributes - {\ifconditional\structureheadisdisplay \else \iflocation +\def\setinlineheadreferenceattributes + {\ifconditional\headisdisplay \else \iflocation \attribute\destinationattribute\currentstructureattribute \attribute\referenceattribute \currentstructurereferenceattribute % \attribute\internalattribute \nextinternalreference \fi \fi} -\def\docheckstructureheadreference - {\edef\currentstructureheadinteraction{\structureheadparameter\c!interaction}% - \ifx\currentstructureheadinteraction\v!list +\def\docheckheadreference + {\edef\currentheadinteraction{\headparameter\c!interaction}% + \ifx\currentheadinteraction\v!list % setuphead[<section>][interaction=list,...] - \dogetsimplepagereference{bck:\nextinternalreference}% + \strc_references_get_simple_page_reference{bck:\nextinternalreference}% \let\currentstructurereferenceattribute\currentreferenceattribute - \else\ifx\currentstructureheadinteraction\v!reference + \else\ifx\currentheadinteraction\v!reference % setuphead[<section>][interaction=reference,...] start<section>[backreference=abc,...] - \edef\currentstructureheadbackreference{\structurevariable{references.backreference}}% - \ifx\currentstructureheadbackreference\empty \else - \dogetsimplepagereference\currentstructureheadbackreference + \edef\currentheadbackreference{\structurevariable\c!backreference}% weird, was references.backreference + \ifx\currentheadbackreference\empty \else + \strc_references_get_simple_page_reference\currentheadbackreference \let\currentstructurereferenceattribute\currentreferenceattribute \fi \else % maybe auto: backreference when given, else list \fi\fi} -\unexpanded\def\placestructureheadtext +\unexpanded\def\placecurrentheadtext {\beginheadplacement - \setstructureheadmarking + \setheadmarking \doresettructureheadnumbercontent - \ifconditional\structureheadleaveempty - \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes to \zeropoint{}% + \ifconditional\headleaveempty + \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes to \zeropoint{}% \makestrutofbox\sectionheadbox \else - \docheckstructureheadreference - \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes - {\dosetlocalgridsnapping{\structureheadparameter\c!internalgrid}% + \docheckheadreference + \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes + {\spac_grids_set_local_snapping{\headparameter\c!internalgrid}% \doresettructureheadnumbercontent - \dosetfontattribute{\??nh\currentstructurehead}\c!style % but we don't want color to influence user command, todo: get the if-else out of it - \setinlinestructureheadreferenceattributes - \structureheadparameter\c!command{}{\doplaceheadtextcomponent\getstructureheadtitle}}% + \useheadstyleparameter\c!style + \setinlineheadreferenceattributes + \headparameter\c!command{}{\doplaceheadtextcomponent\getheadtitle}}% \fi - \endheadplacement{\getstructureheadsyncs}} + \endheadplacement{\getheadsyncs}} -\unexpanded\def\placestructureheadnumbertext +\unexpanded\def\placecurrentheadnumbertext {\beginheadplacement - \setstructureheadmarking - \doiftextelse{\getstructureheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent - \ifconditional\structureheadleaveempty - \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes to \zeropoint{}% + \setheadmarking + \doiftextelse{\getheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent + \ifconditional\headleaveempty + \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes to \zeropoint{}% \makestrutofbox\sectionheadbox \else % = needed - \docheckstructureheadreference - \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes - {\dosetlocalgridsnapping{\structureheadparameter\c!internalgrid}% - \dosetfontattribute{\??nh\currentstructurehead}\c!style - \setinlinestructureheadreferenceattributes - \structureheadparameter\c!command{\doplaceheadnumbercomponent\getstructureheadnumber}{\doplaceheadtextcomponent\getstructureheadtitle}}% + \docheckheadreference + \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \headreferenceattributes + {\spac_grids_set_local_snapping{\headparameter\c!internalgrid}% + \useheadstyleparameter\c!style + \setinlineheadreferenceattributes + \headparameter\c!command{\doplaceheadnumbercomponent\getheadnumber}{\doplaceheadtextcomponent\getheadtitle}}% \fi - \endheadplacement{\getstructureheadsyncs}} + \endheadplacement{\getheadsyncs}} -\unexpanded\def\placestructureheadempty - {\hbox \structureheadreferenceattributes {\getstructureheadsyncs}} +\unexpanded\def\placecurrentheadempty + {\hbox \headreferenceattributes {\getheadsyncs}} %D \starttyping %D \def\StretchedBox#1% @@ -205,14 +200,14 @@ \def\dolocalheadsetup % koppeling met standaard kopcommando / engels {\forgetall % traag dus ... - \doifsomething{\structureheadparameter\c!align } {\normalexpanded{\noexpand\setupalign [\structureheadparameter\c!align ]}}% - \doifsomething{\structureheadparameter\c!tolerance} {\normalexpanded{\noexpand\setuptolerance[\structureheadparameter\c!tolerance]}}% - \doif {\structureheadparameter\c!strut }\v!no{\setnostrut}% new + \doifsomething{\headparameter\c!align } {\normalexpanded{\noexpand\setupalign [\headparameter\c!align ]}}% + \doifsomething{\headparameter\c!tolerance} {\normalexpanded{\noexpand\setuptolerance[\headparameter\c!tolerance]}}% + \doif {\headparameter\c!strut }\v!no{\setnostrut}% new \def\\{\crlf\strut\ignorespaces}} \def\beginheadplacement {\bgroup - \setsystemmode\currentstructurehead + \setsystemmode\currenthead \xdef\localheadheight {\the\strutht}% \xdef\localheaddepth {\the\strutdp}% \xdef\localheadlineheight{\the\lineheight}% @@ -220,7 +215,7 @@ \everypar\emptytoks % needed indeed \noindent % ipv \whitespace elders, na \forgetall ! \bgroup - \doifinsetelse{\structureheadparameter\c!aligntitle}{\v!yes,\v!float}% new + \doifinsetelse{\headparameter\c!aligntitle}{\v!yes,\v!float}% new {\skip0 1\leftskip \skip2 1\rightskip \xdef\localheadskip{\the\skip0}% @@ -231,10 +226,11 @@ \forgetbothskips} {\globallet\localheadskip\!!zeropoint \forgetall}% + \setfalse\inhibitmargindata % brrrr is set in forgetall \dontcomplain \postponenotes \iflocation - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay % \ifdisplaysectionhead \else % obsolete: \noninterferingmarks \fi @@ -282,10 +278,10 @@ \def\endheadplacement#1% {\noflines\zerocount - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay % \ifdisplaysectionhead % new (todo tight == one following line up) \processaction - [\structureheadparameter\c!hang] + [\headparameter\c!hang] [ \v!line=>\hangheadplacement\noflines\zerocount, \v!broad=>\hangheadplacement\getnoflines\scratchdimen, \v!fit=>\hangheadplacement\getrawnoflines\scratchdimen, @@ -296,22 +292,22 @@ \let\headlastlinewidth\!!zeropoint % kind of special, we want to snap heads also according to local specs local \ifgridsnapping - \begingroup - \edef\currentstructureheadgridsnapping{\structureheadparameter\c!grid}% - \ifconditional\structureheadisdisplay - \ifx\currentstructureheadgridsnapping\empty\else - \dosetstructureheadattributes\c!style\c!color - \setupinterlinespace - \dosetstructureheadattributes\c!textstyle\c!textcolor - \setupinterlinespace + \hbox\bgroup % extra hbox will trigger global snapper on top of local + \edef\currentheadgridsnapping{\headparameter\c!grid}% + \ifconditional\headisdisplay + \ifx\currentheadgridsnapping\empty\else + \useheadstyleandcolor\c!style\c!color + \setupinterlinespace + \useheadstyleandcolor\c!textstyle\c!textcolor + \setupinterlinespace + \fi \fi - \fi - \snaptogrid[\currentstructureheadgridsnapping]\hbox - {\hskip\localheadskip\hskip\structureheadparameter\c!margin\box\sectionheadbox}% - \endgroup + \snaptogrid[\currentheadgridsnapping]\hbox + {\hskip\localheadskip\hskip\headparameter\c!margin\box\sectionheadbox}% + \egroup \else \hbox - {\hskip\localheadskip\hskip\structureheadparameter\c!margin\box\sectionheadbox}% + {\hskip\localheadskip\hskip\headparameter\c!margin\box\sectionheadbox}% \fi \flushnotes % new, not really needed \endgraf @@ -330,9 +326,9 @@ \globallet\headlastlinewidth\!!zeropoint #1% \hskip\numberheaddistance\!!plus\numberheaddistance\!!minus.25\dimexpr\numberheaddistance\relax - \hskip\continuousstructureheadsignal\ignorespaces + \hskip\continuousheadsignal\ignorespaces \fi - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay % \ifdisplaysectionhead \ifvmode \ifgridsnapping % important, font related depth, see comment \prevdepth\strutdp @@ -343,8 +339,8 @@ \fi \egroup \egroup - \ifconditional\structureheadisdisplay % \ifdisplaysectionhead - \checknextindentation[\structureheadparameter\c!indentnext]% + \ifconditional\headisdisplay % \ifdisplaysectionhead + \useindentnextparameter\headparameter \else \nonoindentation % recently added, was a bug \fi} @@ -363,26 +359,53 @@ % \input tufte \par % \stopnarrower +\installcorenamespace{headplacementalternative} +\installcorenamespace{headplacementnature} + \let\numberheadalternative\v!normal \unexpanded\def\defineheadplacement {\dodoubleargument\dodefineheadplacement} -\def\dodefineheadplacement[#1][#2]% #3#4 - {\setvalue{\??ns:#1}{#2}% - \setvalue{\??ns::#1}} +% \def\dodefineheadplacement[#1][#2]% #3#4 +% {\setvalue{\??headplacementnature#1}{#2}% +% \setvalue{\??headplacementalternative#1}} + +% \dodefineheadplacement[sectiona][vertical]{#1->#2} +% \dodefineheadplacement[sectionb][vertical]#1#2{#1->#2} +% +% \setuphead[section][alternative=sectiona] +% \setuphead[subsection][alternative=sectionb] + +\def\dodefineheadplacementyes[#1][#2]%#3#4% + {\setvalue{\??headplacementnature#1}{#2}% + \setvalue{\??headplacementalternative#1}##1##2} + +\def\dodefineheadplacementnop[#1][#2]% + {\setvalue{\??headplacementnature#1}{#2}% + \setvalue{\??headplacementalternative#1}} + +\def\dodefineheadplacement[#1][#2]% + {\doifnextbgroupelse + {\dodefineheadplacementyes[#1][#2]}% + {\dodefineheadplacementnop[#1][#2]}} \def\presetnumberheadalternative - {\doifelsevalue{\??ns:\numberheadalternative}\v!horizontal\setfalse\settrue\structureheadisdisplay} + {\doifelsevalue{\??headplacementnature\numberheadalternative}\v!horizontal\setfalse\settrue\headisdisplay} \def\normalplacehead - {\csname\??ns::\ifcsname\??ns::\numberheadalternative\endcsname\numberheadalternative\else\v!normal\fi\endcsname} + {\csname\??headplacementalternative\ifcsname\??headplacementalternative\numberheadalternative\endcsname\numberheadalternative\else\v!normal\fi\endcsname} + +\def\setheaddisplay % used in strc-sec + {\doifelsevalue{\??headplacementnature\headparameter\c!alternative}\v!horizontal + {\setfalse\headisdisplay} + {\settrue \headisdisplay}} \defineheadplacement[\v!paragraph][\v!vertical]#1#2% {\vbox {\localheadsetup \begstrut - \ifconditional\structureheadshownumber % \ifheadnumbercontent + \ifconditional\headshownumber % \ifheadnumbercontent #1\hskip\numberheaddistance \fi #2}} @@ -397,10 +420,10 @@ \defineheadplacement[\v!normal][\v!vertical]#1#2% {\vbox {\localheadsetup - \edef\headwidth {\structureheadparameter\c!width }% - \edef\headnumberwidth{\structureheadparameter\c!numberwidth}% - \edef\headtextwidth {\structureheadparameter\c!textwidth }% - \ifconditional\structureheadshownumber + \edef\headwidth {\headparameter\c!width }% + \edef\headnumberwidth{\headparameter\c!numberwidth}% + \edef\headtextwidth {\headparameter\c!textwidth }% + \ifconditional\headshownumber \ifx\headwidth\empty \else \ifx\headnumberwidth\empty @@ -439,20 +462,20 @@ \fi #2}} -\unexpanded\def\placeheadmargin#1#2% +\unexpanded\def\placeheadmarginalternative#1#2% {\vbox {\localheadsetup \begstrut % use one \strut here! \dontleavehmode % in case there is no strut, else side effects with llap - \ifconditional\structureheadshownumber + \ifconditional\headshownumber \llap{\hbox{\hfill{#1}\hskip\localheadskip\hskip\leftmargindistance}}% introduces whitespace % maybe better: % \inleftmargin{\hbox{\hss{#1}\hskip\localheadskip}}% \fi {#2}}} -\defineheadplacement[\v!inmargin][\v!vertical]#1#2{\placeheadmargin{#1}{#2}} -\defineheadplacement[\v!margin] [\v!vertical]#1#2{\placeheadmargin{#1}{#2}} +\defineheadplacement[\v!inmargin][\v!vertical]#1#2{\placeheadmarginalternative{#1}{#2}} +\defineheadplacement[\v!margin] [\v!vertical]#1#2{\placeheadmarginalternative{#1}{#2}} \defineheadplacement[\v!middle][\v!vertical]#1#2% {\vbox @@ -460,7 +483,7 @@ \veryraggedcenter \let\\\endgraf \let\crlf\endgraf - \ifconditional\structureheadshownumber + \ifconditional\headshownumber \strut#1\par \fi \begstrut#2}} @@ -468,14 +491,14 @@ \defineheadplacement[\v!text][\v!horizontal]#1#2% {\bgroup \localheadsetup % no stretch in distance - \ifconditional\structureheadshownumber + \ifconditional\headshownumber {#1}\kern\numberheaddistance \fi {\begstrut#2}% \egroup} -\unexpanded\def\placeheadlohi#1#2#3% - {\ifconditional\structureheadshownumber +\unexpanded\def\placeheadlohialternative#1#2#3% + {\ifconditional\headshownumber \setbox0\hbox{#2} \setbox2=#1{\localheadsetup\advance\hsize-\wd0\relax#3}% \hbox{\box0\hskip\numberheaddistance\box2}% @@ -486,8 +509,8 @@ % onder/boven lijnt het nummer op de onderste/bovenste regel % uit van een meerregelige kop -\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohi\vbox{#1}{#2}} -\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohi\vtop{#1}{#2}} +\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohialternative\vbox{#1}{#2}} +\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohialternative\vtop{#1}{#2}} % helpers @@ -495,7 +518,7 @@ % % \defineheadplacement[MyTest][horizontal]#1#2% % {\startlocalheadsetup -% %\ChapterInMargin{\structureheadhbox{\strut#2}}% proper destination, ref okay +% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay % \ChapterInMargin{\strut#2}% zero destination, ref okay % \stoplocalheadsetup} % @@ -503,8 +526,8 @@ % [chapter] % [alternative=MyTest] -\unexpanded\def\structureheadhbox{\hbox\structureheadreferenceattributes} -\unexpanded\def\structureheadvbox{\vbox\structureheadreferenceattributes} +\unexpanded\def\headhbox{\hbox\headreferenceattributes} +\unexpanded\def\headvbox{\vbox\headreferenceattributes} \unexpanded\def\startlocalheadsetup{\bgroup\localheadsetup} \unexpanded\def\stoplocalheadsetup {\egroup} |