Lettrine + string manipulation + some fonts = errors and weird issues
I recommend, in a case like this, doing it with raw TeX, without parsing packages.
\documentclass{article}
\usepackage{times,lettrine,Eileen}
\def\firstaux#1#2\relax{{#1}{#2}}
\newcommand\flettrine[1]{\expandafter\lettrine\firstaux#1\relax}
\begin{document}
\flettrine{What} the duck?\bigskip
\renewcommand*{\LettrineFontHook}{\Eileenfamily}
\flettrine{What} the duck?
\end{document}
If you wanted to use stringstrings
for other reasons (more complex manipulations, for example), I would use \substring
to store the result in \thestring
, and then pass \thestring
on to \lettrine
, in this fashion:
\documentclass{article}
\usepackage{times,lettrine,Eileen,coolstr,stringstrings,xstring}
\newcommand*{\first}[1]{\substring[q]{#1}{1}{1}} %%% stringstrings version
\newcommand\flettrine[2]{\first{#1}\lettrine{\thestring}{#2}}
\begin{document}
\flettrine{Whaaat}{hat} the duck? %%% DOES NOT WORK AS INTENDED WITH EILEEN
\vspace{3em}
\renewcommand*{\LettrineFontHook}{\Eileenfamily} %%% Eileen fancy drop letter WTF?
\flettrine{What}{hat} the duck? %%% DOES NOT WORK AT ALL WITH EILEEN
\end{document}
With expl3
it's really easy:
\documentclass{article}
\usepackage{newtxtext,lettrine,Eileen,xparse}
\renewcommand*{\LettrineFontHook}{\Eileenfamily} %%% Eileen fancy drop letter WTF?
\ExplSyntaxOn
\NewDocumentCommand{\IiroLettrine}{O{}m}
{
\lettrine[#1]{\tl_range:nnn { #2 } { 1 } { 1 }}{\tl_range:nnn { #2 } { 2 } { -1 } }
}
\ExplSyntaxOff
\begin{document}
\IiroLettrine{What} the duck?
\end{document}
The problem with your code is that \StrLeft{#1}{1}
doesn't produce the first letter, but the set of instructions for printing it, but \lettrine
wants just a letter (after expansion).
The \tl_range:nnn
function is fully expandable, so it makes no problem to \lettrine
. With \tl_range:nnn { #1 } { 1 } { 1 }
the first item in the argument is delivered; with \tl_range:nnn { #1 } { 2 } { -1 }
the remaining items are produced (the negative second number means “up to the last item”).
Since small caps are needed, it's better to use newtxtext
that provides real small caps, instead of the faked ones you get with times
.
You can do it also with xstring
, using its trailing optional argument feature:
\documentclass{article}
\usepackage{newtxtext,lettrine,Eileen,xstring}
\renewcommand*{\LettrineFontHook}{\Eileenfamily} %%% Eileen fancy drop letter WTF?
\newcommand{\IiroLettrine}[2][]{%
\StrLeft{#2}{1}[\firstletter]%
\StrGobbleLeft{#2}{1}[\otherletters]%
\lettrine[#1]{\firstletter}{\otherletters}%
}
\begin{document}
\IiroLettrine{What} the duck?
\end{document}
In both cases I kept the optional argument to \lettrine
available in \IiroLettrine
.