Hi all, please have a look at the following example: \newsignal\SectionSignal \def\TestSpace% {\relax\ifdim\lastskip=\SectionSignal \blank[nowhite] \else \blank \fi} \setuphead[section] [after=\blank\vskip\SectionSignal] \setuphead[subsection][before=\TestSpace] \starttext \startcolumns \section{Section} \subsection{Subsection} \dorecurse{50}{some text, } \stopcolumns \stoptext If one removes the blank line after \section{Section} the output is correct, otherwise \TestSpace is ignored … I'm quite sure it worked a couple of weeks before. Best regards Andreas
On 14-3-2010 15:07, Andreas Harder wrote:
Hi all,
please have a look at the following example:
\newsignal\SectionSignal
\def\TestSpace% {\relax\ifdim\lastskip=\SectionSignal \blank[nowhite] \else \blank \fi}
\setuphead[section] [after=\blank\vskip\SectionSignal] \setuphead[subsection][before=\TestSpace]
\starttext \startcolumns \section{Section}
\subsection{Subsection}
\dorecurse{50}{some text, } \stopcolumns \stoptext
If one removes the blank line after \section{Section} the output is correct, otherwise \TestSpace is ignored …
I'm quite sure it worked a couple of weeks before.
in mkiv? probbably not ... for what do you need that kind of trickery? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 14.03.10 17:19, schrieb Hans Hagen:
I'm quite sure it worked a couple of weeks before. in mkiv? probbably not ... for what do you need that kind of trickery? It worked before you enabled the new spacing mechanism in MKIV.
The code was meant to change the distance between consecutive headers. Wolfgang
On 14-3-2010 17:27, Wolfgang Schuster wrote:
Am 14.03.10 17:19, schrieb Hans Hagen:
I'm quite sure it worked a couple of weeks before. in mkiv? probbably not ... for what do you need that kind of trickery? It worked before you enabled the new spacing mechanism in MKIV.
The code was meant to change the distance between consecutive headers.
using a kern instead of a vskip might work (an alternative is to look into skips with higher/lower priority) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
using a kern instead of a vskip might work
Am 14.03.10 17:45, schrieb Hans Hagen: the problem is not the skip of the section but the information whether the current header follows another header immediately or there is normal text before. In MKII lastskip result in 1pt after both vertical skips while in MKIV the first lastskip is the sum of the blank and the vskip. \starttext \the\lastskip \vskip1pt \the\lastskip \blank[small]\vskip1pt \the\lastskip \stoptext Since i have a solution for this which doesn't require lastskip i don't care about this difference but it would be interesting why this happens. \starttext \vskip1pt\vskip1pt \the\lastskip \stoptext MKII: 1.0pt MKIV: 2.0pt
(an alternative is to look into skips with higher/lower priority) I guess this requires Lua code.
Wolfgang
On 14-3-2010 18:00, Wolfgang Schuster wrote:
\starttext
\vskip1pt\vskip1pt
\the\lastskip
\stoptext
MKII: 1.0pt MKIV: 2.0pt
In mkii we only see the last skip, i.e. we get 1pt. In mkiv the skips are collapsed so we get 2pt reported.
(an alternative is to look into skips with higher/lower priority) I guess this requires Lua code.
\starttext test \blank[line] test \blank[4*line] \blank[1*line,strong] test \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 14.03.10 15:07, schrieb Andreas Harder:
If one removes the blank line after \section{Section} the output is correct, otherwise \TestSpace is ignored …
\def\DefineSectionBlank {\dotripleempty\doDefineSectionBlank} \def\doDefineSectionBlank[#1][#2][#3]#4% {\edef\CurrentSection{#1}% \setvalue{#1:#2:\ifthirdargument\the\dimexpr#3\relax\fi}{#4}} \def\SectionBlank#1#2% {\edef\CurrentSection{#1}% \executeifdefined{#1:#2:\LastSectionBlankSignal}{\executeifdefined{#1:#2:\the\dimexpr\zeropoint\relax}{\getvalue{#1:#2:}}}% \doif{#2}{after}{\SectionBlankSignal}} \let\LastSectionBlankSignal\zeropoint \EveryPar{\let\LastSectionBlankSignal\zeropoint} \def\SectionBlankSignal {\setevalue{LastSectionBlankSignal}{\the\dimexpr\csname\CurrentSection Signal\endcsname\relax}} % chapter \DefineSectionBlank [Chapter] [before] {\blank[force,48pt]} \DefineSectionBlank [Chapter] [after] {\blank[20pt]} \newsignal\ChapterSignal \setuphead [chapter] [before=\SectionBlank{Chapter}{before}, after=\SectionBlank{Chapter}{after}] % section \newsignal\SectionSignal \DefineSectionBlank [Section] [before] [\ChapterSignal] {\blank[18pt]} \DefineSectionBlank [Section] [before] {\blank[24pt]} \DefineSectionBlank [Section] [after] {\blank[18pt]} \setuphead [section] [before=\SectionBlank{Section}{before}, after=\SectionBlank{Section}{after}] \showgrid \starttext \chapter{Chapter} \section{Section} \chapter{Chapter}\edef\CurrentSection{Section}\SectionBlankSignal % tell \section the last header was \section too! \section{Section} \chapter{Chapter} text \section{Section} \stoptext Wolfgang
Am 16.03.2010 um 01:32 schrieb Wolfgang Schuster:
Am 14.03.10 15:07, schrieb Andreas Harder:
If one removes the blank line after \section{Section} the output is correct, otherwise \TestSpace is ignored …
\def\DefineSectionBlank {\dotripleempty\doDefineSectionBlank}
\def\doDefineSectionBlank[#1][#2][#3]#4% {\edef\CurrentSection{#1}% \setvalue{#1:#2:\ifthirdargument\the\dimexpr#3\relax\fi}{#4}}
\def\SectionBlank#1#2% {\edef\CurrentSection{#1}% \executeifdefined{#1:#2:\LastSectionBlankSignal}{\executeifdefined{#1:#2:\the\dimexpr\zeropoint\relax}{\getvalue{#1:#2:}}}% \doif{#2}{after}{\SectionBlankSignal}}
\let\LastSectionBlankSignal\zeropoint
\EveryPar{\let\LastSectionBlankSignal\zeropoint}
\def\SectionBlankSignal {\setevalue{LastSectionBlankSignal}{\the\dimexpr\csname\CurrentSection Signal\endcsname\relax}}
% chapter
\DefineSectionBlank [Chapter] [before] {\blank[force,48pt]} \DefineSectionBlank [Chapter] [after] {\blank[20pt]}
\newsignal\ChapterSignal
\setuphead [chapter] [before=\SectionBlank{Chapter}{before}, after=\SectionBlank{Chapter}{after}]
% section
\newsignal\SectionSignal
\DefineSectionBlank [Section] [before] [\ChapterSignal] {\blank[18pt]} \DefineSectionBlank [Section] [before] {\blank[24pt]} \DefineSectionBlank [Section] [after] {\blank[18pt]}
\setuphead [section] [before=\SectionBlank{Section}{before}, after=\SectionBlank{Section}{after}]
\showgrid
\starttext
\chapter{Chapter}
\section{Section}
\chapter{Chapter}\edef\CurrentSection{Section}\SectionBlankSignal % tell \section the last header was \section too!
\section{Section}
\chapter{Chapter}
text
\section{Section}
\stoptext
Hello Wolfgang, thank you for your elaborate example! In the meantime I played a little with weak/strong blanks, before I figured out that this already works out of the box. It seams that the blank before a head gets a higher priority and overrides the blank after the previous head, so that there is no need for signals at all …? Greeting Andreas
Am 16.03.2010 um 10:32 schrieb Andreas Harder:
Am 16.03.2010 um 01:32 schrieb Wolfgang Schuster:
Am 14.03.10 15:07, schrieb Andreas Harder:
If one removes the blank line after \section{Section} the output is correct, otherwise \TestSpace is ignored …
\def\DefineSectionBlank {\dotripleempty\doDefineSectionBlank}
\def\doDefineSectionBlank[#1][#2][#3]#4% {\edef\CurrentSection{#1}% \setvalue{#1:#2:\ifthirdargument\the\dimexpr#3\relax\fi}{#4}}
\def\SectionBlank#1#2% {\edef\CurrentSection{#1}% \executeifdefined{#1:#2:\LastSectionBlankSignal}{\executeifdefined{#1:#2:\the\dimexpr\zeropoint\relax}{\getvalue{#1:#2:}}}% \doif{#2}{after}{\SectionBlankSignal}}
\let\LastSectionBlankSignal\zeropoint
\EveryPar{\let\LastSectionBlankSignal\zeropoint}
\def\SectionBlankSignal {\setevalue{LastSectionBlankSignal}{\the\dimexpr\csname\CurrentSection Signal\endcsname\relax}}
% chapter
\DefineSectionBlank [Chapter] [before] {\blank[force,48pt]} \DefineSectionBlank [Chapter] [after] {\blank[20pt]}
\newsignal\ChapterSignal
\setuphead [chapter] [before=\SectionBlank{Chapter}{before}, after=\SectionBlank{Chapter}{after}]
% section
\newsignal\SectionSignal
\DefineSectionBlank [Section] [before] [\ChapterSignal] {\blank[18pt]} \DefineSectionBlank [Section] [before] {\blank[24pt]} \DefineSectionBlank [Section] [after] {\blank[18pt]}
\setuphead [section] [before=\SectionBlank{Section}{before}, after=\SectionBlank{Section}{after}]
\showgrid
\starttext
\chapter{Chapter}
\section{Section}
\chapter{Chapter}\edef\CurrentSection{Section}\SectionBlankSignal % tell \section the last header was \section too!
\section{Section}
\chapter{Chapter}
text
\section{Section}
\stoptext
Hello Wolfgang,
thank you for your elaborate example!
In the meantime I played a little with weak/strong blanks, before I figured out that this already works out of the box. It seams that the blank before a head gets a higher priority and overrides the blank after the previous head, so that there is no need for signals at all …?
In some projects it might look better if the space between two consecutive section heads is smaller than the regular space between section head and text. That's where signals are needed and where Wolfgang's code does a great job. Steffen
participants (4)
-
Andreas Harder
-
Hans Hagen
-
Steffen Wolfrum
-
Wolfgang Schuster