[NTG-context] stretched title text
Hans Hagen
pragma at wxs.nl
Fri Jan 13 11:23:21 CET 2006
M.guravage wrote:
>Hi,
>
>Something has changed in the past couple months that causes my stretched
>title code to fail with the message:
>
> ! You can't use `\end' in internal vertical mode.
> <recently read> \normalend
>
>I've attatched a small example. Has anyone a suggestion how I can adapt my
>code accordingly?
>
>
in a coming release i will support a more transparent stretching
mechanism (using a font handling) so that such hacks are no longer needed
anyhow, the problem with your 'plug-in' is that it acts on a complex
stream of tokens, run this:
\def\CapStretchAmount
{0.3em}
\def\CapStretch
{\let\stretchedspaceamount\CapStretchAmount
\stretchednormalcase}
\def\stretchedbox#1%
{\framed
[frame=off,
offset=.5em,
align=middle,
width=broad]
{\showargument{#1}%
\sc\CapStretch{#1}}}
\setuphead [subject][rawtextcommand=\stretchedbox]
\starttext
\subject{feeling stretched feeling stretched feeling stretched
feeling stretched}
\processfile{tufte}
\subject{feeling stretched}
\processfile{tufte}
\stoptext
you will see that #1 is more than text, and i'm even surprised that it
worked in previous versions.
What you actually need is a deep hook:
\def\c!deeptextcommand {deeptextcommand}
\def\c!deepnumbercommand{deepnumbercommand}
\def\doplaceheadtext#1#2#3#4%
{\beginheadplacement{#1}%
\ifemptyhead % = needed
\setbox0=\ifvertical\vbox\else\hbox\fi to \zeropoint
{\headnumbercontentfalse
\resetsystemmode\v!sectionnumber
#2}%
\makestrutofbox0
\else % = needed
\setbox0=\ifvertical\vbox\else\hbox\fi % \vhbox
{\headnumbercontentfalse
\resetsystemmode\v!sectionnumber
% less interfering
\ifcase\headtimingmode\or#2\fi
% outerside font determines distance
\dosetfontattribute{\??ko#1}\c!style
% but we don't want color to influence user commands
% todo: get the if-else out of it
\getvalue{\??ko#1\c!command}
{} % no number
{\dostartattributes{\??ko#1}\c!style\c!color\empty
\dostartattributes{\??ko#1}\c!textstyle\c!textcolor\empty
\dontconvertfont
\ifdisplaysectionhead
\setupinterlinespace
\else
\setupspacing
\fi
% \ifcase\headtimingmode#2\fi % can introduce cr
\getvalue{\??ko#1\c!commandbefore}%
\placeheadmargintexts{#1}% binnen #3?
\ifdisplaysectionhead
\getvalue{\??ko#1\c!textcommand}% struts can be nilled
with \setnostrut
{\setstrut
\begstrut
\ifcase\headtimingmode\hbox{#2}\fi
\executeifdefined{\??ko#1\c!deeptextcommand}\firstofoneargument{#3}
\endstrut}% \hbox prevents break
\xdef\localheadheight {\the\strutht}%
\xdef\localheaddepth {\the\strutdp}%
\xdef\localheadlineheight{\the\lineheight}%
% == \globallet\localheaddepth\strutdepth
\else
\ifcase\headtimingmode#2\fi
\getvalue{\??ko#1\c!textcommand}%
{\executeifdefined{\??ko#1\c!deeptextcommand}\firstofoneargument{#3}}%
\fi
\getvalue{\??ko#1\c!commandafter}%
\ifdisplaysectionhead\endgraf\fi
\dostopattributes
\dostopattributes}}%
\fi
\endheadplacement{#1}{#4}}
\def\doplaceheadnumbertext#1#2#3#4#5% maybe move modes outside box
{\beginheadplacement{#1}%
\ifemptyhead % = needed
\setbox0=\ifvertical\vbox\else\hbox\fi to \zeropoint
{\doiftextelse{#3}
{\setsystemmode \v!sectionnumber\headnumbercontenttrue }
{\resetsystemmode\v!sectionnumber\headnumbercontentfalse}%
#2}%
\makestrutofbox0
\else % = needed
\setbox0=\ifvertical\vbox\else\hbox\fi % \vhbox
{\doiftextelse{#3}
{\setsystemmode \v!sectionnumber\headnumbercontenttrue }
{\resetsystemmode\v!sectionnumber\headnumbercontentfalse}%
% less interfering
\ifcase\headtimingmode\or#2\fi
% outerside font determines distance
\dosetfontattribute{\??ko#1}\c!style
% but we don't want color to influence user commands
\getvalue{\??ko#1\c!command}%
{\dostartattributes{\??ko#1}\c!style\c!color\empty
\dostartattributes{\??ko#1}\c!numberstyle\c!numbercolor\empty
% \getvalue{\??ko#1\c!commandbefore}% strange, why here?
moved 21/11/2005
\placeheadmargintexts{#1}% binnen #3?
\ifdisplaysectionhead
% can be nilled with \setnostrut
\getvalue{\??ko#1\c!numbercommand}%
{\setstrut
\begstrut
\executeifdefined{\??ko#1\c!deepnumbercommand}\firstofoneargument{#3}%
\endstrut}%
\else
\getvalue{\??ko#1\c!numbercommand}%
{\executeifdefined{\??ko#1\c!deepnumbercommand}\firstofoneargument{#3}}%
\fi
\dostopattributes
\dostopattributes}
{\dostartattributes{\??ko#1}\c!style\c!color\empty
\dostartattributes{\??ko#1}\c!textstyle\c!textcolor\empty
\dontconvertfont
\ifdisplaysectionhead
\setupinterlinespace
\else
\setupspacing
\fi
% \ifcase\headtimingmode#2\fi % can introduce cr
\getvalue{\??ko#1\c!commandbefore}% makes more sense here
\placeheadmargintexts{#1}% binnen #3?
\ifdisplaysectionhead
\getvalue{\??ko#1\c!textcommand}% struts can be nilled
with \setnostrut
{\setstrut
\begstrut
\ifcase\headtimingmode\hbox{#2}\fi
\executeifdefined{\??ko#1\c!deeptextcommand}\firstofoneargument{#4}%
\endstrut}% \hbox prevents break
\xdef\localheadheight {\the\strutht}%
\xdef\localheaddepth {\the\strutdp}%
\xdef\localheadlineheight{\the\lineheight}%
% == \globallet\localheaddepth\strutdepth
\else
\ifcase\headtimingmode#2\fi % inside textcommand ?
\getvalue{\??ko#1\c!textcommand}%
{\executeifdefined{\??ko#1\c!deeptextcommand}\firstofoneargument{#4}}%
\fi
\getvalue{\??ko#1\c!commandafter}%
\ifdisplaysectionhead\endgraf\fi
\dostopattributes
\dostopattributes}}%
\fi
\endheadplacement{#1}{#5}}
\protect
\def\CapStretchAmount
{0.3em}
\def\CapStretch
{\let\stretchedspaceamount\CapStretchAmount
\stretchednormalcase}
\def\stretchedbox#1%
{\framed
[frame=off,
offset=.5em,
align=middle,
width=broad]
{%\showargument{#1}%
\sc\CapStretch{#1}}}
\setuphead [subject][deeptextcommand=\stretchedbox]
\starttext
\subject{feeling stretched feeling stretched feeling stretched
feeling stretched}
\processfile{tufte}
\subject{feeling stretched}
\processfile{tufte}
\stoptext
More information about the ntg-context
mailing list