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 | 868 |
1 files changed, 535 insertions, 333 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-ren.mkiv b/Master/texmf-dist/tex/context/base/strc-ren.mkiv index b7b4224cd0d..00c8c3cd4d5 100644 --- a/Master/texmf-dist/tex/context/base/strc-ren.mkiv +++ b/Master/texmf-dist/tex/context/base/strc-ren.mkiv @@ -15,7 +15,10 @@ \unprotect -\newconstant\headtimingmode +\newbox\b_strc_rendering_head + +\newdimen\d_strc_rendering_local_leftoffset +\newdimen\d_strc_rendering_local_rightoffset % Martin Kolarik's problem: % @@ -23,90 +26,57 @@ % \def\doTitle#1#2{\ruledvbox{\forgetall \hsize=4cm \ruledhbox{\ruledvtop{#1}\ruledvtop{#2}}}} % \section{test test test test test test test test test test test test test test test test test} -\newevery \everyheadstart \relax +\newtoks\everyheadstart -\unexpanded\def\setupheadcomponentfont#1#2% +\unexpanded\def\strc_rendering_initialize_style_and_color + {\ifconditional\headisdisplay + \expandafter\strc_rendering_initialize_style_and_color_display + \else + \expandafter\strc_rendering_initialize_style_and_color_inline + \fi} + +\unexpanded\def\strc_rendering_initialize_style_and_color_display#1#2% {\dontconvertfont - \ifconditional\headisdisplay - \edef\askedheadinterlinespace{\headparameter\c!interlinespace}% - \ifx\askedheadinterlinespace\empty - % here the interline space is only set when style sets no space - \setfalse\fontattributeisset % use the currentfontparameter state instead - \setfalse\interlinespaceisset - \useheadstyleandcolor\c!style\c!color - \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else - \setupinterlinespace - \fi \fi - \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 - \useheadstyleandcolor\c!style\c!color - \ifconditional\fontattributeisset - \dosetupcheckedinterlinespace\askedheadinterlinespace - \fi - \setfalse\fontattributeisset - \useheadstyleandcolor#1#2% - \ifconditional\fontattributeisset - \dosetupcheckedinterlinespace\askedheadinterlinespace - \fi - \fi + \edef\p_strc_rendering_interlinespace{\headparameter\c!interlinespace}% + \ifx\p_strc_rendering_interlinespace\empty + % here the interline space is only set when style sets no space + \setfalse\fontattributeisset % use the currentfontparameter state instead + \setfalse\interlinespaceisset + \useheadstyleandcolor\c!style\c!color\relax + \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else + \setupinterlinespace + \fi \fi + \setfalse\fontattributeisset + \useheadstyleandcolor#1#2\relax + \ifconditional\fontattributeisset \ifconditional\interlinespaceisset \else + \setupinterlinespace + \fi \fi \else + % here the set interline space overloads any other set space in the style \setfalse\fontattributeisset - \useheadstyleandcolor\c!style\c!color + \useheadstyleandcolor\c!style\c!color\relax \ifconditional\fontattributeisset - \setupspacing + \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace \fi \setfalse\fontattributeisset - \useheadstyleandcolor#1#2% + \useheadstyleandcolor#1#2\relax \ifconditional\fontattributeisset - \setupspacing + \dosetupcheckedinterlinespace\p_strc_rendering_interlinespace \fi \fi} -\def\doplaceheadtextcomponent#1% - {\begingroup - \setupheadcomponentfont\c!textstyle\c!textcolor - \headparameter\c!commandbefore - \ifcsname\currentheadhash\c!deeptextcommand\endcsname - \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname - \fi - \ifconditional\headisdisplay % \ifdisplaysectionhead - % struts can be nilled with \setnostrut - \headparameter\c!textcommand{\setstrut\begstrut#1\endstrut}% - \xdef\localheadheight {\the\strutht}% - \xdef\localheaddepth {\the\strutdp}% - \xdef\localheadlineheight{\the\lineheight}% - % == \globallet\localheaddepth\strutdepth - \else - \headparameter\c!textcommand{#1}% - \fi - \headparameter\c!commandafter - \ifconditional\headisdisplay % \ifdisplaysectionhead - \endgraf - \fi - \endgroup} - -\def\doplaceheadnumbercomponent#1% - {\begingroup - \setupheadcomponentfont\c!numberstyle\c!numbercolor - \ifcsname\currentheadhash\c!deepnumbercommand\endcsname - \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname - \fi - \ifconditional\headisdisplay % \ifdisplaysectionhead - % can be nilled with \setnostrut - \headparameter\c!numbercommand{\setstrut\begstrut#1\endstrut}% - \else - \headparameter\c!numbercommand{#1}% - \fi - \endgroup} - -% \newif\ifheadnumbercontent -% \newif\ifemptyhead -% \newif\ifdisplaysectionhead +\unexpanded\def\strc_rendering_initialize_style_and_color_inline#1#2% + {\dontconvertfont + \setfalse\fontattributeisset + \useheadstyleandcolor\c!style\c!color\relax + \ifconditional\fontattributeisset + \updateraggedskips % \setupspacing + \fi + \setfalse\fontattributeisset + \useheadstyleandcolor#1#2\relax + \ifconditional\fontattributeisset + \updateraggedskips % \setupspacing + \fi} \let\currentstructurereferenceattribute\attributeunsetvalue @@ -142,42 +112,45 @@ % maybe auto: backreference when given, else list \fi\fi} -\unexpanded\def\placecurrentheadtext - {\beginheadplacement +% a bit messy ... empty in place instead of self .. might change (or use special +% whatsig (invisible user one) + +\unexpanded\def\strc_rendering_place_head_text + {\strc_rendering_start_placement \setheadmarking \doresettructureheadnumbercontent - \ifconditional\headleaveempty - \setbox\sectionheadbox\hbox \headreferenceattributes to \zeropoint{}% - \makestrutofbox\sectionheadbox + \ifconditional\c_strc_sectioning_empty + \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{\strut}% \else \docheckheadreference - \setbox\sectionheadbox\hbox \headreferenceattributes + \setbox\b_strc_rendering_head\hbox \headreferenceattributes {\spac_grids_set_local_snapping{\headparameter\c!internalgrid}% \doresettructureheadnumbercontent \useheadstyleparameter\c!style \setinlineheadreferenceattributes - \headparameter\c!command{}{\doplaceheadtextcomponent\getheadtitle}}% + \strc_rendering_inject_text}% \fi - \endheadplacement{\getheadsyncs}} + \strc_rendering_stop_placement} -\unexpanded\def\placecurrentheadnumbertext - {\beginheadplacement +\unexpanded\def\strc_rendering_place_head_number_and_text + {\strc_rendering_start_placement \setheadmarking - \doiftextelse{\getheadnumber}\dosettructureheadnumbercontent\doresettructureheadnumbercontent - \ifconditional\headleaveempty - \setbox\sectionheadbox\hbox \headreferenceattributes to \zeropoint{}% - \makestrutofbox\sectionheadbox + \doiftextelse\getheadnumber + \dosettructureheadnumbercontent + \doresettructureheadnumbercontent + \ifconditional\c_strc_sectioning_empty + \setbox\b_strc_rendering_head\hbox \headreferenceattributes to \zeropoint{\strut}% \else % = needed \docheckheadreference - \setbox\sectionheadbox\hbox \headreferenceattributes + \setbox\b_strc_rendering_head\hbox \headreferenceattributes {\spac_grids_set_local_snapping{\headparameter\c!internalgrid}% \useheadstyleparameter\c!style \setinlineheadreferenceattributes - \headparameter\c!command{\doplaceheadnumbercomponent\getheadnumber}{\doplaceheadtextcomponent\getheadtitle}}% + \strc_rendering_inject_number_and_text}% \fi - \endheadplacement{\getheadsyncs}} + \strc_rendering_stop_placement} -\unexpanded\def\placecurrentheadempty +\unexpanded\def\strc_rendering_place_head_empty {\hbox \headreferenceattributes {\getheadsyncs}} %D \starttyping @@ -192,54 +165,96 @@ %D \MySubject{feeling stretched feeling stretched feeling stretched feeling stretched} %D \stoptyping -\let\headlastlinewidth\!!zeropoint +% helpers -\def\localheadheight {\strutht} -\def\localheaddepth {\strutdp} -\def\localheadlineheight{\lineheight} +% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em] +% +% \defineheadplacement[MyTest][horizontal]#1#2% +% {\startlocalheadsetup +% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay +% \ChapterInMargin{\strut#2}% zero destination, ref okay +% \stoplocalheadsetup} +% +% \setuphead +% [chapter] +% [alternative=MyTest] + +\unexpanded\def\headhbox{\hbox\headreferenceattributes} +\unexpanded\def\headvbox{\vbox\headreferenceattributes} -\def\dolocalheadsetup % koppeling met standaard kopcommando / engels - {\forgetall % traag dus ... - \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}} +\unexpanded\def\startlocalheadsetup{\bgroup\strc_rendering_initialize_spacing} +\unexpanded\def\stoplocalheadsetup {\egroup} + +\unexpanded\def\strc_rendering_initialize_spacing + {\forgetall % local ! + \edef\p_align{\headparameter\c!align}% + \ifx\p_align\empty \else + \setupalign[\p_align]% + \fi + \edef\p_tolerance{\headparameter\c!tolerance}% + \ifx\p_tolerance\empty \else + \setuptolerance[\p_tolerance]% + \fi + \edef\p_strut{\headparameter\c!strut}% + \ifx\p_strut\v!no + \setnostrut + \fi + \let\\\strc_rendering_shortcut_backslash} -\def\beginheadplacement +\unexpanded\def\strc_rendering_shortcut_backslash + {\crlf + \strut + \ignorespaces} + +\def\strc_rendering_start_placement {\bgroup \setsystemmode\currenthead - \xdef\localheadheight {\the\strutht}% - \xdef\localheaddepth {\the\strutdp}% - \xdef\localheadlineheight{\the\lineheight}% - % == \globallet\localheaddepth\strutdp - \everypar\emptytoks % needed indeed - \noindent % ipv \whitespace elders, na \forgetall ! + % + \strc_rendering_initialize_alternatives + \strc_rendering_initialize_dimensions + % + \strc_rendering_initialize_line_state + \reseteverypar % needed indeed + \noindent % ipv \whitespace elders, na \forgetall ! \bgroup - \doifinsetelse{\headparameter\c!aligntitle}{\v!yes,\v!float}% new - {\skip0 1\leftskip - \skip2 1\rightskip - \xdef\localheadskip{\the\skip0}% - \forgetall - \leftskip\skip0 - \rightskip\skip2 - \setlocalhsize\hsize\localhsize - \forgetbothskips} - {\globallet\localheadskip\!!zeropoint - \forgetall}% + \edef\p_aligntitle{\headparameter\c!aligntitle}% + \ifx\p_aligntitle\v!yes + \strc_rendering_initialize_hsize_local + \else\ifx\p_aligntitle\v!float + \strc_rendering_initialize_hsize_local + \else + \strc_rendering_initialize_hsize_global + \fi\fi \setfalse\inhibitmargindata % brrrr is set in forgetall \dontcomplain \postponenotes - \iflocation - \ifconditional\headisdisplay % \ifdisplaysectionhead - \else - % obsolete: \noninterferingmarks - \fi - \fi - \resetinteractionparameter\c!style + \strc_rendering_initialize_interaction + % delayed + \let\localheadsetup \strc_rendering_initialize_spacing % historic name + \let\headsetupspacing\strc_rendering_initialize_spacing} + +\def\strc_rendering_initialize_hsize_local + {\global\d_strc_rendering_local_leftoffset \leftskip + \global\d_strc_rendering_local_rightoffset\rightskip + % \forgetall + % \leftskip \d_strc_rendering_local_leftoffset % no stretch + % \rightskip\d_strc_rendering_local_rightoffset % no stretch + % \setlocalhsize + % \hsize\localhsize + % \forgetbothskips} + \scratchwidth\availablehsize + \forgetall + \hsize\scratchwidth} + +\def\strc_rendering_initialize_hsize_global + {\global\d_strc_rendering_local_leftoffset \zeropoint + \global\d_strc_rendering_local_rightoffset\zeropoint + \forgetall} + +\def\strc_rendering_initialize_interaction + {\resetinteractionparameter\c!style \resetinteractionparameter\c!color - \resetinteractionparameter\c!contrastcolor - %\strictouterreferencestrue % tzt instelling - \let\localheadsetup\dolocalheadsetup} + \resetinteractionparameter\c!contrastcolor} % \setuphead[chapter] [style=\bfd,after=,hang=line] % fit broad 2 % \setuphead[section] [style=\bfc,after=,hang=line] @@ -259,87 +274,105 @@ % \subsubsection {Test\\Test} \input tufte \page % \subsubsubsection{Test\\Test} \input tufte \page -\def\hangheadplacement - {\scratchdimen\localheadlineheight - \bgroup - \openlineheight\scratchdimen - \scratchdimen\htdp0% - \getnoflines\scratchdimen - \advance\noflines\minusone - \normalexpanded{\egroup\noflines\the\noflines}% brrr - \setbox0\hbox{\lower\noflines\scratchdimen\box0}% - \scratchdimen\dimexpr\htdp0-\localheadheight+\strutdp\relax - \ht0 \strutht - \dp0 \strutdp - \edef\localheaddepth{\the\strutdp}} - -\newconditional\continuoussectionhead % oeps, \newif\ifcontinuoushead got lost -\newbox\sectionheadbox - -\def\endheadplacement#1% - {\noflines\zerocount - \ifconditional\headisdisplay % \ifdisplaysectionhead - % new (todo tight == one following line up) - \processaction - [\headparameter\c!hang] - [ \v!line=>\hangheadplacement\noflines\zerocount, - \v!broad=>\hangheadplacement\getnoflines\scratchdimen, - \v!fit=>\hangheadplacement\getrawnoflines\scratchdimen, - \v!none=>\noflines\zerocount, - \v!default=>\noflines\zerocount, - \v!unknown=>\hangheadplacement\noflines\numexpr0\commalistelement-1\relax]% - % so far - \let\headlastlinewidth\!!zeropoint +\newdimen\d_strc_rendering_hang_height +\newcount\n_strc_rendering_hang_lines + +\newdimen\d_strc_rendering_local_height +\newdimen\d_strc_rendering_local_depth +\newdimen\d_strc_rendering_local_lineheight + +\def\strc_rendering_initialize_line_state + {\global\d_strc_rendering_local_height\strutht + \global\d_strc_rendering_local_depth\strutdp + \global\d_strc_rendering_local_lineheight\lineheight} + +\def\strc_rendering_check_hang + {\begingroup + \openlineheight\d_strc_rendering_local_lineheight + \d_strc_rendering_hang_height\htdp\b_strc_rendering_head + \getnoflines\d_strc_rendering_hang_height + \normalexpanded{\endgroup\n_strc_rendering_hang_lines\the\numexpr\noflines-\plusone\relax}% brrr + \setbox\b_strc_rendering_head\hbox{\lower\n_strc_rendering_hang_lines\d_strc_rendering_hang_height\box\b_strc_rendering_head}% + \d_strc_rendering_hang_height\dimexpr\htdp\b_strc_rendering_head-\d_strc_rendering_local_height+\strutdp\relax + \ht\b_strc_rendering_head\strutht + \dp\b_strc_rendering_head\strutdp + \d_strc_rendering_local_depth\strutdp} + +\installcorenamespace{headplacementcheckhang} + +\setvalue{\??headplacementcheckhang\v!line }{\strc_rendering_check_hang + \n_strc_rendering_hang_lines\zerocount} +\setvalue{\??headplacementcheckhang\v!broad }{\strc_rendering_check_hang + \getnoflines\d_strc_rendering_hang_height} +\setvalue{\??headplacementcheckhang\v!fit }{\strc_rendering_check_hang + \getrawnoflines\d_strc_rendering_hang_height} +\setvalue{\??headplacementcheckhang\v!none }{\n_strc_rendering_hang_lines\zerocount} +\setvalue{\??headplacementcheckhang }{\n_strc_rendering_hang_lines\zerocount} +\setvalue{\??headplacementcheckhang\s!unknown}{\strc_rendering_check_hang + \n_strc_rendering_hang_lines\numexpr\headparameter\c!hang-\plusone\relax} + +\def\strc_rendering_initialize_line_hang + {\ifconditional\headisdisplay + \expandnamespaceparameter\??headplacementcheckhang\headparameter\c!hang\s!unknown + \relax + \else + \n_strc_rendering_hang_lines \zerocount + \d_strc_rendering_hang_height\zeropoint + \fi} + +\def\strc_rendering_stop_placement + {\n_strc_rendering_hang_lines\zerocount + \ifconditional\headisdisplay + \strc_rendering_initialize_line_hang % kind of special, we want to snap heads also according to local specs local \ifgridsnapping \hbox\bgroup % extra hbox will trigger global snapper on top of local - \edef\currentheadgridsnapping{\headparameter\c!grid}% + \edef\p_grid{\headparameter\c!grid}% \ifconditional\headisdisplay - \ifx\currentheadgridsnapping\empty\else + \ifx\p_grid\empty\else \useheadstyleandcolor\c!style\c!color \setupinterlinespace \useheadstyleandcolor\c!textstyle\c!textcolor \setupinterlinespace \fi \fi - \snaptogrid[\currentheadgridsnapping]\hbox - {\hskip\localheadskip\hskip\headparameter\c!margin\box\sectionheadbox}% + \snaptogrid[\p_grid]\hbox + {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}% \egroup \else \hbox - {\hskip\localheadskip\hskip\headparameter\c!margin\box\sectionheadbox}% + {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}% \fi \flushnotes % new, not really needed \endgraf \ifvmode - \ifnum\noflines>\zerocount - \dorecurse\noflines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked + \ifnum\n_strc_rendering_hang_lines>\zerocount + \dorecurse\n_strc_rendering_hang_lines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked \fi \nointerlineskip \dosomebreak\nobreak \fi - #1% + \getheadsyncs \else \strut \flushnotes % new, here since we're in par mode - \unhbox\sectionheadbox - \globallet\headlastlinewidth\!!zeropoint - #1% - \hskip\numberheaddistance\!!plus\numberheaddistance\!!minus.25\dimexpr\numberheaddistance\relax - \hskip\continuousheadsignal\ignorespaces + \unhbox\b_strc_rendering_head + \getheadsyncs + \hskip\headnumberdistance\s!plus\headnumberdistance\s!minus.25\dimexpr\headnumberdistance\relax + \strc_sectioning_inject_continuous_signal \fi - \ifconditional\headisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay \ifvmode \ifgridsnapping % important, font related depth, see comment \prevdepth\strutdp \else - \prevdepth\localheaddepth + \prevdepth\d_strc_rendering_local_depth \fi \fi \fi \egroup \egroup - \ifconditional\headisdisplay % \ifdisplaysectionhead + \ifconditional\headisdisplay \useindentnextparameter\headparameter \else \nonoindentation % recently added, was a bug @@ -359,187 +392,356 @@ % \input tufte \par % \stopnarrower -\installcorenamespace{headplacementalternative} -\installcorenamespace{headplacementnature} - -\let\numberheadalternative\v!normal - -\unexpanded\def\defineheadplacement - {\dodoubleargument\dodefineheadplacement} - -% \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} +% \startsetups[\??headrenderings:\v!vertical:\v!sectiona] +% ... there will be a more public namespace +% \stopsetups -\def\dodefineheadplacementnop[#1][#2]% - {\setvalue{\??headplacementnature#1}{#2}% - \setvalue{\??headplacementalternative#1}} +\installcorenamespace{headplacementalternative} +\installcorenamespace{headrenderings} +\installcorenamespace{headalternative} -\def\dodefineheadplacement[#1][#2]% - {\doifnextbgroupelse - {\dodefineheadplacementyes[#1][#2]}% - {\dodefineheadplacementnop[#1][#2]}} +\installcommandhandler \??headalternative {headalternative} \??headalternative % or just \??head -\def\presetnumberheadalternative - {\doifelsevalue{\??headplacementnature\numberheadalternative}\v!horizontal\setfalse\settrue\headisdisplay} +\setupheadalternative + [%\c!width=\headparameter\c!width, + %\c!distance=\headparameter\c!distance, + \c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\currentheadalternative] -\def\normalplacehead - {\csname\??headplacementalternative\ifcsname\??headplacementalternative\numberheadalternative\endcsname\numberheadalternative\else\v!normal\fi\endcsname} +\let\currentheadalternative \v!normal +\let\currentheadrenderingsetup \empty +\let\currentheadrenderingalternative\v!vertical -\def\setheaddisplay % used in strc-sec - {\doifelsevalue{\??headplacementnature\headparameter\c!alternative}\v!horizontal - {\setfalse\headisdisplay} - {\settrue \headisdisplay}} +\unexpanded\def\defineheadplacement % old mechanism + {\dodoubleargument\strc_rendering_define_placement} -\defineheadplacement[\v!paragraph][\v!vertical]#1#2% - {\vbox - {\localheadsetup - \begstrut - \ifconditional\headshownumber % \ifheadnumbercontent - #1\hskip\numberheaddistance - \fi - #2}} +\def\strc_rendering_define_placement[#1][#2]% + {\doifnextbgroupelse + {\strc_rendering_define_placement_yes[#1][#2]}% + {\strc_rendering_define_placement_nop[#1][#2]}} -% \setuphead -% [chapter] -% [numberwidth=2cm,hang=line,after={\blank[3*line]}] +\def\strc_rendering_define_placement_yes[#1][#2]% + {\defineheadalternative[#1][\c!alternative=#2,\c!renderingsetup=\??headrenderings:\v!command]% + \setuvalue{\??headplacementalternative#1}##1##2} + +\def\strc_rendering_define_placement_nop[#1][#2]% + {\defineheadalternative[#1][\c!alternative=#2,\c!renderingsetup=\??headrenderings:\v!command]% + \setuvalue{\??headplacementalternative#1}} + +% these can be used in setups: % -% \chapter{Oeps oeps oeps} \input tufte \section{Oeps} -% \chapter{Oeps oeps oeps} \section{Oeps} \input tufte +% \headnumbercontent +% \headtextcontent +% +% \headwidth +% \headtextwidth +% \headnumberdistance +% \headnumberwidth +% \headsetupspacing +% +% \headshownumber +% \headisdisplay -\defineheadplacement[\v!normal][\v!vertical]#1#2% - {\vbox - {\localheadsetup - \edef\headwidth {\headparameter\c!width }% - \edef\headnumberwidth{\headparameter\c!numberwidth}% - \edef\headtextwidth {\headparameter\c!textwidth }% - \ifconditional\headshownumber - \ifx\headwidth\empty - \else - \ifx\headnumberwidth\empty - \ifx\headtextwidth\empty\else - \edef\headnumberwidth{\the\dimexpr\headwidth-\headtextwidth\relax}% - \fi - \else - \ifx\headtextwidth\empty - \edef\headtextwidth{\the\dimexpr\headwidth-\headnumberwidth\relax}% - \fi - \fi - \hsize\headwidth - \fi - \ifx\headnumberwidth\empty\else - \let\numberheaddistance\!!zeropoint - \fi - \setbox\scratchbox\hbox \ifx\headnumberwidth\empty\else to \headnumberwidth\fi{{#1}}% - \scratchdimen\dimexpr\wd\scratchbox+\numberheaddistance\relax - \ifx\headtextwidth\empty\else - \hsize\dimexpr\scratchdimen+\headparameter\c!textwidth\relax - \fi - \hangindent\scratchdimen - \hangafter \plusone - \noindent - \box\scratchbox\hskip\numberheaddistance - \else - \ifx\headtextwidth\empty - \ifx\headwidth\empty - \else - \hsize\headwidth - \fi - \else - \hsize\headtextwidth - \fi - \noindent - \fi - #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\headshownumber -% \llap{\hbox{\hfill{#1}\hskip\localheadskip\hskip\leftmargindistance}}% introduces whitespace -% % maybe better: -% % \inleftmargin{\hbox{\hss{#1}\hskip\localheadskip}}% -% \fi -% {#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\headshownumber - \llap{\hbox{\hfill{#1}\hskip\dimexpr\localheadskip+\doifoddpageelse\leftmargindistance\rightmargindistance\relax}}% introduces whitespace - \fi - {#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 - {\localheadsetup - \veryraggedcenter - \let\\\endgraf - \let\crlf\endgraf - \ifconditional\headshownumber - \strut#1\par - \fi - \begstrut#2}} - -\defineheadplacement[\v!text][\v!horizontal]#1#2% - {\bgroup - \localheadsetup % no stretch in distance - \ifconditional\headshownumber - {#1}\kern\numberheaddistance +\let\headnumbercontent\empty +\let\headtextcontent \empty + +\newdimen\headwidth +\newdimen\headtextwidth +\newdimen\headnumberdistance +\newdimen\headnumberwidth + +% \newconditional\headshownumber % defined already +% \newconditional\headisdisplay % defined already + +\unexpanded\def\strc_rendering_initialize_alternatives + {\edef\currentheadalternative{\headparameter\c!alternative}% + \ifcsname\currentheadalternativehash\s!parent\endcsname \else + \let\currentheadalternative\v!normal % cf. mkii + \fi + \edef\currentheadrenderingsetup{\headalternativeparameter\c!renderingsetup}% + \edef\currentheadrenderingalternative{\headalternativeparameter\c!alternative}% + \ifx\currentheadrenderingalternative\empty + \let\currentheadrenderingalternative\v!vertical \fi - {\begstrut#2}% - \egroup} - -\unexpanded\def\placeheadlohialternative#1#2#3% - {\ifconditional\headshownumber - \setbox0\hbox{#2} - \setbox2=#1{\localheadsetup\advance\hsize-\wd0\relax#3}% - \hbox{\box0\hskip\numberheaddistance\box2}% + \ifx\currentheadrenderingalternative\v!horizontal + \global\setfalse\headisdisplay % global \else - #1{\localheadsetup\noindent#3}% + \global\settrue\headisdisplay % global \fi} -% onder/boven lijnt het nummer op de onderste/bovenste regel -% uit van een meerregelige kop +\unexpanded\def\strc_rendering_initialize_dimensions + {\headwidth \headparameter\c!width \relax % \zeropoint == unset + \headnumberwidth \headparameter\c!numberwidth\relax % \zeropoint == unset + \headnumberdistance\headparameter\c!distance \relax + \headtextwidth \headparameter\c!textwidth \relax} % \zeropoint == unset -\defineheadplacement[\v!bottom][\v!vertical]#1#2{\placeheadlohialternative\vbox{#1}{#2}} -\defineheadplacement[\v!top] [\v!vertical]#1#2{\placeheadlohialternative\vtop{#1}{#2}} +\unexpanded\def\headtextcontent + {\begingroup + \strc_rendering_initialize_style_and_color\c!textstyle\c!textcolor + \headparameter\c!commandbefore\relax + \ifcsname\currentheadhash\c!deeptextcommand\endcsname + \expandafter\let\expandafter\deepstructuretitlecommand\csname\currentheadhash\c!deeptextcommand\endcsname + \fi + \ifconditional\headisdisplay + % struts can be nilled with \setnostrut + \headparameter\c!textcommand{\setstrut\begstrut\getheadtitle\endstrut}% + \global\d_strc_rendering_local_height\strutht + \global\d_strc_rendering_local_depth\strutdp + \global\d_strc_rendering_local_lineheight\lineheight + \headparameter\c!commandafter\relax + \endgraf + \else + \headparameter\c!textcommand{\getheadtitle}% + \headparameter\c!commandafter\relax + \fi + \endgroup} -% helpers +\unexpanded\def\headnumbercontent + {\begingroup + \strc_rendering_initialize_style_and_color\c!numberstyle\c!numbercolor + \ifcsname\currentheadhash\c!deepnumbercommand\endcsname + \expandafter\let\expandafter\deepstructurenumbercommand\csname\currentheadhash\c!deepnumbercommand\endcsname + \fi + \ifconditional\headisdisplay + % can be nilled with \setnostrut + \headparameter\c!numbercommand{\setstrut\begstrut\getheadnumber\endstrut}% + \else + \headparameter\c!numbercommand{\getheadnumber}% + \fi + \endgroup} -% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em] -% -% \defineheadplacement[MyTest][horizontal]#1#2% -% {\startlocalheadsetup -% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay -% \ChapterInMargin{\strut#2}% zero destination, ref okay -% \stoplocalheadsetup} +\unexpanded\def\strc_rendering_inject_number_and_text + {\edef\p_command{\headparameter\c!command}% assumes \unexpanded definition + \ifx\p_command\empty + \directsetup\currentheadrenderingsetup + \else + \p_command\headnumbercontent\headtextcontent + \fi} + +\unexpanded\def\strc_rendering_inject_text + {\edef\p_command{\headparameter\c!command}% assumes \unexpanded definition + \ifx\p_command\empty + \directsetup\currentheadrenderingsetup + \else + \p_command\empty\headtextcontent + \fi} + +\startsetups[\??headrenderings:\v!command] + \csname\??headplacementalternative\currentheadalternative\endcsname \headnumbercontent \headtextcontent +\stopsetups + +% obsolete % +% \def\normalplacehead % hooks into \c!command +% {\csname\??headplacementalternative\ifcsname\??headplacementalternative\currentheadalternative\endcsname\currentheadalternative\else\v!normal\fi\endcsname} + +\defineheadalternative + [\v!paragraph] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!paragraph] + +\startsetups[\??headrenderings:\v!paragraph] + \vbox { + \headsetupspacing + \begstrut + \ifconditional\headshownumber % \ifheadnumbercontent + \headnumbercontent + \hskip\headnumberdistance + \fi + \headtextcontent + } +\stopsetups + % \setuphead % [chapter] -% [alternative=MyTest] - -\unexpanded\def\headhbox{\hbox\headreferenceattributes} -\unexpanded\def\headvbox{\vbox\headreferenceattributes} +% [numberwidth=2cm,hang=line,after={\blank[3*line]}] +% +% \chapter{Oeps oeps oeps} \input tufte \section{Oeps} +% \chapter{Oeps oeps oeps} \section{Oeps} \input tufte -\unexpanded\def\startlocalheadsetup{\bgroup\localheadsetup} -\unexpanded\def\stoplocalheadsetup {\egroup} +\defineheadalternative + [\v!normal] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!normal] + +\startsetups[\??headrenderings:\v!normal] + \vbox { + \headsetupspacing + \ifconditional\headshownumber + \ifdim\headwidth=\zeropoint \else + \ifdim\headnumberwidth=\zeropoint + \ifdim\headtextwidth=\zeropoint \else + \headnumberwidth\dimexpr\headwidth-\headtextwidth\relax + \fi + \else + \ifdim\headtextwidth=\zeropoint + \headtextwidth\dimexpr\headwidth-\headnumberwidth\relax + \fi + \fi + \hsize\headwidth + \fi + \ifdim\headnumberwidth=\zeropoint\else + \headnumberdistance\zeropoint + \fi + \setbox\scratchbox\hbox \ifdim\headnumberwidth=\zeropoint\else to \headnumberwidth\fi{\headnumbercontent} + \scratchdimen\dimexpr\wd\scratchbox+\headnumberdistance\relax + \ifdim\headtextwidth=\zeropoint\else + \hsize\dimexpr\scratchdimen+\headtextwidth\relax + \fi + \hangindent\scratchdimen + \hangafter \plusone + \noindent + \box\scratchbox + \hskip\headnumberdistance + \else + \ifdim\headtextwidth=\zeropoint + \ifdim\headwidth=\zeropoint \else + \hsize\headwidth + \fi + \else + \hsize\headtextwidth + \fi + \noindent + \fi + \headtextcontent + } +\stopsetups + +\defineheadalternative + [\v!inmargin] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!inmargin] + +\startsetups[\??headrenderings:\v!inmargin] + \vbox { + \headsetupspacing + \begstrut % use one \strut here! + \dontleavehmode % in case there is no strut, else side effects with llap + \ifconditional\headshownumber + \llap { + \hbox { + \hfill + \headnumbercontent + \hskip\dimexpr\d_strc_rendering_local_leftoffset+\doifoddpageelse\leftmargindistance\rightmargindistance\relax + } + } + \fi + \headtextcontent + } +\stopsetups + +\defineheadalternative + [\v!margin] + [\v!inmargin] + +% \startsetups[\??headrenderings:\v!vertical:\v!margin] +% \directsetup{\??headrenderings:\v!vertical:\v!inmargin} +% \stopsetups + +\defineheadalternative + [\v!middle] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!middle] + +\startsetups[\??headrenderings:\v!middle] + \vbox { + \headsetupspacing + \veryraggedcenter + \let\\\endgraf + \let\crlf\endgraf + \ifconditional\headshownumber + \strut + \headnumbercontent + \par + \fi + \begstrut + \headtextcontent + \endstrut + } +\stopsetups + +\defineheadalternative + [\v!text] + [\c!alternative=\v!horizontal, + \c!renderingsetup=\??headrenderings:\v!text] + +\startsetups[\??headrenderings:\v!text] + \begingroup + \headsetupspacing % no stretch in distance + \ifconditional\headshownumber + \headnumbercontent + \kern\headnumberdistance + \fi + \begstrut + \headtextcontent + \endstrut + \endgroup +\stopsetups + +% onder/boven lijnt het nummer op de onderste/bovenste regel uit van een meerregelige kop + +\defineheadalternative + [\v!bottom] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!bottom] + +\startsetups[\??headrenderings:\v!bottom] + \ifconditional\headshownumber + \setbox0\hbox { + \headnumbercontent + } + \setbox2\vbox { + \headsetupspacing + \advance\hsize-\wd0\relax + \headtextcontent + } + \hbox { + \box0 + \hskip\headnumberdistance + \box2 + } + \else + \vbox { + \headsetupspacing + \noindent + \headtextcontent + } + \fi +\stopsetups + +\defineheadalternative + [\v!top] + [\c!alternative=\v!vertical, + \c!renderingsetup=\??headrenderings:\v!top] + +\startsetups[\??headrenderings:\v!top] + \ifconditional\headshownumber + \setbox0\hbox { + \headnumbercontent + } + \setbox2\vtop { + \headsetupspacing + \advance\hsize-\wd0\relax + \headtextcontent + } + \hbox { + \box0 + \hskip\headnumberdistance + \box2 + } + \else + \vtop{ + \headsetupspacing + \noindent + \headtextcontent + } + \fi +\stopsetups \protect \endinput |