summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-ren.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-ren.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-ren.mkiv174
1 files changed, 97 insertions, 77 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ren.mkiv b/Master/texmf-dist/tex/context/base/strc-ren.mkiv
index 3a60a34a380..73eb0ccd206 100644
--- a/Master/texmf-dist/tex/context/base/strc-ren.mkiv
+++ b/Master/texmf-dist/tex/context/base/strc-ren.mkiv
@@ -15,10 +15,8 @@
\unprotect
-\chardef\headtimingmode=0
+\newconstant\headtimingmode
-% \chardef\headtimingmode=1 % 0 also works ok now too
-%
% Martin Kolarik's problem:
%
% \setuphead[section][command=\doTitle]
@@ -32,7 +30,8 @@
\doif{\structureheadparameter\c!margintext}\v!yes\placemargincontent}
\unexpanded\def\setupheadcomponentfont#1#2%
- {\ifconditional\structureheadisdisplay
+ {\dontconvertfont
+ \ifconditional\structureheadisdisplay
\edef\askedstructureheadinterlinespace{\structureheadparameter\c!interlinespace}%
\ifx\askedstructureheadinterlinespace\empty
% here the interline space is only set when style sets no space
@@ -70,30 +69,25 @@
\ifconditional\fontattributeisset
\setupspacing
\fi
- \fi
- \dontconvertfont}
+ \fi}
-\def\doplaceheadtextcomponent#1#2%
+\def\doplaceheadtextcomponent#1%
{\begingroup
\setupheadcomponentfont\c!textstyle\c!textcolor
- % \ifcase\headtimingmode#1\fi % can introduce cr
\structureheadparameter\c!commandbefore
\placeheadmargintexts
+ \ifcsname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \expandafter\let\expandafter\deepstructuretitlecommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
- \structureheadparameter\c!textcommand% struts can be nilled with \setnostrut
- {\setstrut
- \begstrut
- \ifcase\headtimingmode\hbox{#1}\fi
- \executeifdefined{\??nh\currentstructurehead\c!deeptextcommand}\firstofoneargument{#2}%
- \endstrut}% \hbox prevents break
+ % struts can be nilled with \setnostrut
+ \structureheadparameter\c!textcommand{\setstrut\begstrut#1\endstrut}%
\xdef\localheadheight {\the\strutht}%
\xdef\localheaddepth {\the\strutdp}%
\xdef\localheadlineheight{\the\lineheight}%
% == \globallet\localheaddepth\strutdepth
\else
- \ifcase\headtimingmode#1\fi
- \structureheadparameter\c!textcommand
- {\executeifdefined{\??nh\currentstructurehead\c!deeptextcommand}\firstofoneargument{#2}}%
+ \structureheadparameter\c!textcommand{#1}%
\fi
\structureheadparameter\c!commandafter
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
@@ -101,21 +95,18 @@
\fi
\endgroup}
-\def\doplaceheadnumbercomponent#1#2%
+\def\doplaceheadnumbercomponent#1%
{\begingroup
\setupheadcomponentfont\c!numberstyle\c!numbercolor
- % \getvalue{\??ko\currentstructurehead\c!commandbefore}% strange, why here? moved 21/11/2005
\placeheadmargintexts
+ \ifcsname\??nh\currentstructurehead\c!deepnumbercommand\endcsname
+ \expandafter\let\expandafter\deepstructurenumbercommand\csname\??nh\currentstructurehead\c!deeptextcommand\endcsname
+ \fi
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
% can be nilled with \setnostrut
- \structureheadparameter\c!numbercommand
- {\setstrut
- \begstrut
- \executeifdefined{\??nh\currentstructurehead\c!deepnumbercommand}\firstofoneargument{#2}%
- \endstrut}%
+ \structureheadparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}%
\else
- \structureheadparameter\c!numbercommand
- {\executeifdefined{\??nh\currentstructurehead\c!deepnumbercommand}\firstofoneargument{#2}}%
+ \structureheadparameter\c!numbercommand{#1}%
\fi
\endgroup}
@@ -123,45 +114,76 @@
% \newif\ifemptyhead
% \newif\ifdisplaysectionhead
-\def\structureheadattribute{\iflocation attr \destinationattribute \currentstructureattribute\fi}
+\let\currentstructurereferenceattribute\attributeunsetvalue
+
+\def\structureheadreferenceattributes
+ {\iflocation
+ attr \destinationattribute \currentstructureattribute
+ attr \referenceattribute \currentstructurereferenceattribute
+ % attr \internalattribute \nextinternalreference
+ \fi}
-\def\doplacestructureheadtext#1#2#3% nodes, text, endstuff
+\def\setinlinestructureheadreferenceattributes
+ {\ifconditional\structureheadisdisplay \else \iflocation
+ \attribute\destinationattribute\currentstructureattribute
+ \attribute\referenceattribute \currentstructurereferenceattribute
+ % \attribute\internalattribute \nextinternalreference
+ \fi \fi}
+
+\def\docheckstructureheadreference
+ {\edef\currentstructureheadinteraction{\structureheadparameter\c!interaction}%
+ \ifx\currentstructureheadinteraction\v!list
+ % setuphead[<section>][interaction=list,...]
+ \dogetsimplepagereference{bck:\nextinternalreference}%
+ \let\currentstructurereferenceattribute\currentreferenceattribute
+ \else\ifx\currentstructureheadinteraction\v!reference
+ % setuphead[<section>][interaction=reference,...] start<section>[backreference=abc,...]
+ \edef\currentstructureheadbackreference{\structurevariable{references.backreference}}%
+ \ifx\currentstructureheadbackreference\empty \else
+ \dogetsimplepagereference\currentstructureheadbackreference
+ \let\currentstructurereferenceattribute\currentreferenceattribute
+ \fi
+ \else
+ % maybe auto: backreference when given, else list
+ \fi\fi}
+
+\unexpanded\def\placestructureheadtext
{\beginheadplacement
+ \setstructureheadmarking
\doresettructureheadnumbercontent
\ifconditional\structureheadleaveempty
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint {#1}%
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes to \zeropoint{}%
\makestrutofbox\sectionheadbox
\else
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute
- {\doresettructureheadnumbercontent
- \ifcase\headtimingmode\or#1\fi % outerside font determines distance
+ \docheckstructureheadreference
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes
+ {\dosetlocalgridsnapping{\structureheadparameter\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
- \structureheadparameter\c!command{}{\doplaceheadtextcomponent{#1}{#2}}}%
+ \setinlinestructureheadreferenceattributes
+ \structureheadparameter\c!command{}{\doplaceheadtextcomponent\getstructureheadtitle}}%
\fi
- \endheadplacement{#3}}
+ \endheadplacement{\getstructureheadsyncs}}
-\def\doplacestructureheadnumbertext#1#2#3#4% nodes number text nodes
+\unexpanded\def\placestructureheadnumbertext
{\beginheadplacement
- \doiftextelse{#2}\dosettructureheadnumbercontent\doresettructureheadnumbercontent
+ \setstructureheadmarking
+ \doiftextelse{\getstructureheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent
\ifconditional\structureheadleaveempty
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute to \zeropoint{#1}%
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes to \zeropoint{}%
\makestrutofbox\sectionheadbox
\else % = needed
- \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadattribute
- {\ifcase\headtimingmode\or#1\fi
+ \docheckstructureheadreference
+ \setbox\sectionheadbox\ifvertical\vbox\else\hbox\fi \structureheadreferenceattributes
+ {\dosetlocalgridsnapping{\structureheadparameter\c!internalgrid}%
\dosetfontattribute{\??nh\currentstructurehead}\c!style
- \structureheadparameter\c!command{\doplaceheadnumbercomponent{#1}{#2}}{\doplaceheadtextcomponent{#1}{#3}}}%
+ \setinlinestructureheadreferenceattributes
+ \structureheadparameter\c!command{\doplaceheadnumbercomponent\getstructureheadnumber}{\doplaceheadtextcomponent\getstructureheadtitle}}%
\fi
- \endheadplacement{#4}}
-
-\unexpanded\def\placestructureheadnumbertext
- {\doplacestructureheadnumbertext\empty\getstructureheadnumber\getstructureheadtitle\getstructureheadsyncs}
-
-\unexpanded\def\placestructureheadtext
- {\doplacestructureheadtext\empty\getstructureheadtitle\getstructureheadsyncs}
+ \endheadplacement{\getstructureheadsyncs}}
\unexpanded\def\placestructureheadempty
- {\hbox \structureheadattribute {\getstructureheadsyncs}}
+ {\hbox \structureheadreferenceattributes {\getstructureheadsyncs}}
%D \starttyping
%D \def\StretchedBox#1%
@@ -214,7 +236,7 @@
\iflocation
\ifconditional\structureheadisdisplay % \ifdisplaysectionhead
\else
- \noninterferingmarks
+ % obsolete: \noninterferingmarks
\fi
\fi
\resetinteractionparameter\c!style
@@ -353,11 +375,6 @@
\def\presetnumberheadalternative
{\doifelsevalue{\??ns:\numberheadalternative}\v!horizontal\setfalse\settrue\structureheadisdisplay}
-% \def\normalplacehead
-% {\executeifdefined
-% {\??ns::\numberheadalternative}
-% {\getvalue{\??ns::\v!normal}}}
-
\def\normalplacehead
{\csname\??ns::\ifcsname\??ns::\numberheadalternative\endcsname\numberheadalternative\else\v!normal\fi\endcsname}
@@ -370,23 +387,6 @@
\fi
#2}}
-% \defineheadplacement[\v!normal][\v!vertical]#1#2%
-% {\ifconditional\structureheadshownumber % \ifheadnumbercontent
-% \setbox0\hbox{{#1}\hskip\numberheaddistance}%
-% \vbox
-% {\localheadsetup
-% \hangindent 1\wd0
-% \hangafter 1
-% \noindent
-% \unhbox0 % don't use \strut's here!
-% #2}%
-% \else
-% \vbox
-% {\localheadsetup\noindent#2}%
-% \fi}
-%
-% enhanced version:
-
% \setuphead
% [chapter]
% [numberwidth=2cm,hang=line,after={\blank[3*line]}]
@@ -400,7 +400,7 @@
\edef\headwidth {\structureheadparameter\c!width }%
\edef\headnumberwidth{\structureheadparameter\c!numberwidth}%
\edef\headtextwidth {\structureheadparameter\c!textwidth }%
- \ifconditional\structureheadshownumber % \ifheadnumbercontent
+ \ifconditional\structureheadshownumber
\ifx\headwidth\empty
\else
\ifx\headnumberwidth\empty
@@ -444,8 +444,8 @@
{\localheadsetup
\begstrut % use one \strut here!
\dontleavehmode % in case there is no strut, else side effects with llap
- \ifconditional\structureheadshownumber % \ifheadnumbercontent
- \llap{\hbox to 5em{\hfill{#1}\hskip\localheadskip\hskip\leftmargindistance}}% introduces whitespace
+ \ifconditional\structureheadshownumber
+ \llap{\hbox{\hfill{#1}\hskip\localheadskip\hskip\leftmargindistance}}% introduces whitespace
% maybe better:
% \inleftmargin{\hbox{\hss{#1}\hskip\localheadskip}}%
\fi
@@ -460,7 +460,7 @@
\veryraggedcenter
\let\\\endgraf
\let\crlf\endgraf
- \ifconditional\structureheadshownumber % \ifheadnumbercontent
+ \ifconditional\structureheadshownumber
\strut#1\par
\fi
\begstrut#2}}
@@ -468,14 +468,14 @@
\defineheadplacement[\v!text][\v!horizontal]#1#2%
{\bgroup
\localheadsetup % no stretch in distance
- \ifconditional\structureheadshownumber % \ifheadnumbercontent
+ \ifconditional\structureheadshownumber
{#1}\kern\numberheaddistance
\fi
{\begstrut#2}%
\egroup}
\unexpanded\def\placeheadlohi#1#2#3%
- {\ifconditional\structureheadshownumber % \ifheadnumbercontent
+ {\ifconditional\structureheadshownumber
\setbox0\hbox{#2}
\setbox2=#1{\localheadsetup\advance\hsize-\wd0\relax#3}%
\hbox{\box0\hskip\numberheaddistance\box2}%
@@ -489,4 +489,24 @@
\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohi\vbox{#1}{#2}}
\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohi\vtop{#1}{#2}}
+% helpers
+
+% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em]
+%
+% \defineheadplacement[MyTest][horizontal]#1#2%
+% {\startlocalheadsetup
+% %\ChapterInMargin{\structureheadhbox{\strut#2}}% proper destination, ref okay
+% \ChapterInMargin{\strut#2}% zero destination, ref okay
+% \stoplocalheadsetup}
+%
+% \setuphead
+% [chapter]
+% [alternative=MyTest]
+
+\unexpanded\def\structureheadhbox{\hbox\structureheadreferenceattributes}
+\unexpanded\def\structureheadvbox{\vbox\structureheadreferenceattributes}
+
+\unexpanded\def\startlocalheadsetup{\bgroup\localheadsetup}
+\unexpanded\def\stoplocalheadsetup {\egroup}
+
\protect \endinput