Background
Looking to adjust the location of the first letter in a word based on its width.
Problem
The calculation resembles:
\define[1]\StyleChapterChar{%
\cldcontext{string.sub("#1",1,1)}%
}
% Use a nested frame to keep the overlain large letter together with
% the chapter title.
\define[1]\StyleChapter{%
\StyleChapterFramed{%
\framed[align=right, frame=off]{%
\startoverlay
\color[blue]{%
\StyleChapterChar{#1}%
}
\vskip-1.9em\hskip\dimexpr\averagecharwidth*33/10#1
\stopoverlay
}
}
}
Here, 3.3 * \averagecharwidth is used to offset the text. This causes the horizontal offset of the emphasized first character in the word to vary wildly between an A and an I. What I would like is to replace this calculation (3.3 * \averagecharwidth) with one that uses the character width (e.g., 3.3 * \charwidth{\StyleChapterChar})
Question
How do you get the width of a single character, when you don't know what that character is?
Ideas
I've tried a few things so far:
\define[1]\StyleChapterCharWidth{
\dimexpr\fontcharwd\font`#1
}
\define[1]\StyleChapterCharWidth{
\fontcharwd\font`#1
}
It seems like the back-tick (`) character indicates that the next character should be treated literally.
\setbox\scratchbox\hbox{C}\wd\scratchbox. – Aditya Sep 23 '13 at 02:41