[NTG-context] Grabbing first letter of a sentence

Mathieu Boespflug 0xbadcode at gmail.com
Mon Nov 15 17:38:54 CET 2010


Hi,

I'd like to get access to the first letter of a chapter for the
purpose of laying out the chapter heading, but I'm having difficulty
with expansion.

Here's my attempt:

\def\MyChapterTitle#1#2{%
  \def\doMyChapterTitle##1##2^{%
      {\tfb ##1}##2
  }
  #1 \doMyChapterTitle#2^
}

setuphead[chapter][command=\MyChapterTitle]

\starttext

\chapter{Foo}

bar

\stoptext

This doesn't work because the chapter title isn't expanded out before
passing it to \MyChapterTitle. I know there is deeptextcommand but I
need the chapter title during the layout of chapter number + title, so
I need to use command instead of deeptextcommand. I attempted to get
hold of the chapter title using the following

\def\MyChapterTitle#1#2{%
  \def\doMyChapterTitle##1##2^{%
      {\tfb ##1}##2
  }
  #1 \expandafter\doMyChapterTitle\expandafter{\fetchmark[chapter][first]}^
}

but that doesn't seem to work either. Any ideas?

Many thanks,

M


More information about the ntg-context mailing list