Problem
Trying to get the first letter of a word for a chapter heading. The chapter style is being applied as follows:
\setuphead[chapter][
command=\StyleChapter,
% Hide the header's chapter name.
header=empty,
% Hide the footer's page number.
footer=empty,
]
To emphasize the first character of the word (e.g., "Bread"), I've written:
\define[2]\StyleChapter{%
\framed[
frame=off,
width=local,
align={flushright,low,nothyphenated,verytolerant},
width=\dimexpr\textwidth+\rightmargindistance,
height=\dimexpr\textheight-\footerheight,
]{\substring{#2}{1}{1}}{#2}
}
As well as:
]{\substring{#2}{1}{1}{#2}}
And:
]{{#2}{\substring{#2}{1}{1}}}
And:
\defineframed[StyleChapterFramed][
frame=off,
width=local,
align={flushright,low,nothyphenated,verytolerant},
width=\dimexpr\textwidth+\rightmargindistance,
height=\dimexpr\textheight-\footerheight,
]
\define[2]\StyleChapter{%
\StyleChapterFramed{%
{\getfirstcharacter{#2}\firstcharacter #2}
}
}
And variations thereof. It seems \substring
is not a macro available in ConTeXT? The effect I'm trying to produce:
The effect I've achieved so far:
Using the following yields the letter H, but I'm trying to use the chapter title, which is parameter #2
:
{\getfirstcharacter{Hello}\firstcharacter #2}
Any ideas how to obtain a substring in ConTeXt?
\defineframed[ChapterFramed][....]
and then directly use\ChapterFramed{...}
instead of overloading\framed[....]
.\substring
is a macro in thestringstrings
package for one, though I'm not sure if that is the reference to which your source referred. Based on your syntax, it could be that reference.