From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: conditional format of headings
Date: Wed, 6 Jun 2012 14:46:29 +0200 [thread overview]
Message-ID: <5A541836-3F3B-41AA-A467-64AEF5A423AA@googlemail.com> (raw)
In-Reply-To: <op.wfe8q1sdyxxkfz@pohanka-pc>
Am 05.06.2012 um 10:34 schrieb Jan Pohanka:
> Hello,
>
> is it possible to have some "conditional format"? I mean I'd like to have different vertical spacing for \section and \subsection when they follows immediately each other and when there is some text between them.
% SectionBlank
\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:}}}}
\let\LastSectionBlankSignal\zeropoint
\EveryPar{\let\LastSectionBlankSignal\zeropoint}
\def\SectionBlankSignal
{\setevalue{LastSectionBlankSignal}{\the\dimexpr\csname\CurrentSection Signal\endcsname\relax}}
% Heading
\newsignal\PartSignal
\DefineSectionBlank [Part] [before] {\blank[force,48pt]}
\DefineSectionBlank [Part] [after] {\blank[15pt]\SectionBlankSignal}
\setuphead
[Part]
[before=\SectionBlank{Part}{before},
after=\SectionBlank{Part}{after}]
\newsignal\ChapterSignal
\DefineSectionBlank [Chapter] [before] [\PartSignal] {\blank[\the\dimexpr 12pt*200/100-6pt\relax]}
\DefineSectionBlank [Chapter] [before] {\blank[\the\dimexpr 12pt*200/100\relax]}
\DefineSectionBlank [Chapter] [after] {\blank[\the\dimexpr 12pt*150/100\relax]\SectionBlankSignal}
\setuphead
[chapter]
[before=\SectionBlank{Chapter}{before},
after=\SectionBlank{Chapter}{after}]
\newsignal\SectionSignal
\DefineSectionBlank [Section] [before] [\PartSignal] {\blank[\the\dimexpr 12pt*175/100\relax]}
%\DefineSectionBlank [Section] [before] [\ChapterSignal] {\blank[\the\dimexpr 12pt*175/100-3pt\relax]}
\DefineSectionBlank [Section] [before] [\ChapterSignal] {\blank[\the\dimexpr 12pt*175/100+2cm\relax]}
\DefineSectionBlank [Section] [before] {\blank[\the\dimexpr 12pt*175/100\relax]}
\DefineSectionBlank [Section] [after] {\blank[\the\dimexpr 12pt*133/100\relax]\SectionBlankSignal}
\setuphead
[section]
[before=\SectionBlank{Section}{before},
after=\SectionBlank{Section}{after}]
\starttext
\chapter{Chapter 1}
\section{Section 1.1}
\chapter{Chapter 2}
text
\section{Section 2.1}
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2012-06-06 12:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-05 8:34 Jan Pohanka
2012-06-06 7:52 ` Hans Hagen
2012-06-06 11:12 ` Jan Pohanka
2012-06-06 12:46 ` Wolfgang Schuster [this message]
2012-06-08 9:22 ` Jan Pohanka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5A541836-3F3B-41AA-A467-64AEF5A423AA@googlemail.com \
--to=schuster.wolfgang@googlemail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).