ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Chapter heading with rules
@ 2020-08-21  1:53 jbf
  2020-08-21  8:29 ` Otared Kavian
  0 siblings, 1 reply; 2+ messages in thread
From: jbf @ 2020-08-21  1:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Have achieved a Chapter title with rules either side (see below - not an 
original invention!) but I want the chapter number to be part of 'My 
Chapter Title'; instead, the following MWE means it comes before the 
ChapterLeftRule. I know I can do it by actually putting the number 
before My Chapter title (e.g. 1 My Chapter Title), since the proper 
numbered version still appears in the TOC, but my preference would be to 
include a command in the \setuphead, if possible (so long as it still 
allows the numbered chapter to appear in the TOC of course). Possible?

\definefiller
   [ChapterRule]
   [alternative=rule,
    color=gray,
    height=0.8ex,
    depth=-0.6ex]

\definefiller
   [ChapterLeftRule]
   [ChapterRule]
   [left=\zerowidthnobreakspace,
    right=\quad]

\definefiller
   [ChapterRightRule]
   [ChapterRule]
   [left=\quad,
    right=\zerowidthnobreakspace]

\setuphead
   [chapter]
   [%align=middle,
    textstyle={\setcharactercasing[WORD]\ssa},
textcommand=\groupedcommand{\filler[ChapterLeftRule]}{\filler[ChapterRightRule]}]

\starttext

\chapter{My Chapter Title}

\stoptext

Julian

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Chapter heading with rules
  2020-08-21  1:53 Chapter heading with rules jbf
@ 2020-08-21  8:29 ` Otared Kavian
  0 siblings, 0 replies; 2+ messages in thread
From: Otared Kavian @ 2020-08-21  8:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Julian,

Indeed you can acchieve what you want, but it is better to define a command which takes care of the number and the title of the chapter at the same time (as in \ myChapterCommand below).

%% begin example.tex
\definefiller[ChapterRule]
	[alternative=rule,
	color=gray,
	height=0.8ex,
	depth=-0.6ex]

\definefiller[ChapterLeftRule]
	[ChapterRule]
	[left=\zerowidthnobreakspace,
	right=\quad]

\definefiller[ChapterRightRule]
	[ChapterRule]
	[left=\quad,
	right=\zerowidthnobreakspace]
	
\define[2]\myChapterCommand{%
	\midaligned{{\filler[ChapterLeftRule]}#1.~#2{\filler[ChapterRightRule]}}
	}

\setuphead[chapter]
	[textstyle={\setcharactercasing[WORD]\ssa},
	command=\myChapterCommand]

\starttext

\startchapter[title={My Chapter Title}]
\input knuth.tex
\stopchapter

\stoptext

%% end example.tex

Best regards: Otared K.

> On 21 Aug 2020, at 03:53, jbf <roma83537@gmail.com> wrote:
> 
> Have achieved a Chapter title with rules either side (see below - not an original invention!) but I want the chapter number to be part of 'My Chapter Title'; instead, the following MWE means it comes before the ChapterLeftRule. I know I can do it by actually putting the number before My Chapter title (e.g. 1 My Chapter Title), since the proper numbered version still appears in the TOC, but my preference would be to include a command in the \setuphead, if possible (so long as it still allows the numbered chapter to appear in the TOC of course). Possible?
> 
> \definefiller
>   [ChapterRule]
>   [alternative=rule,
>    color=gray,
>    height=0.8ex,
>    depth=-0.6ex]
> 
> \definefiller
>   [ChapterLeftRule]
>   [ChapterRule]
>   [left=\zerowidthnobreakspace,
>    right=\quad]
> 
> \definefiller
>   [ChapterRightRule]
>   [ChapterRule]
>   [left=\quad,
>    right=\zerowidthnobreakspace]
> 
> \setuphead
>   [chapter]
>   [%align=middle,
>    textstyle={\setcharactercasing[WORD]\ssa},
> textcommand=\groupedcommand{\filler[ChapterLeftRule]}{\filler[ChapterRightRule]}]
> 
> \starttext
> 
> \chapter{My Chapter Title}
> 
> \stoptext
> 
> Julian
> 
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-21  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-21  1:53 Chapter heading with rules jbf
2020-08-21  8:29 ` Otared Kavian

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).