2

I've modified the code found here that uses rlap to write two lettrines, one atop the other. The font I want to use happens to allow for three colors, so I've nested another one on there. It works without a supplemental lettrine.cfg file. It works with such a file if the file doesn't itself reference an optfile.cfl file. However, if lettrine.cfg does point to optfile.cfl, it fails with "Missing \endcsname inserted." How can I get it to work in this last instance?

Here's an ugly, illustrative MWE with the standard font.

%\RequirePackage{filecontents}% uncomment to reproduce error - cfr
\begin{filecontents}{lettrine.cfg}
\setcounter{DefaultLines}{4}
\setlength{\DefaultFindent}{-0.1ex}
\setlength{\DefaultNindent}{0ex}
\renewcommand*{\DefaultLhang}{0.06}
\LettrineRealHeighttrue
\renewcommand{\DefaultOptionsFile}{optfile.cfl}
\endinput
\end{filecontents}

\begin{filecontents}{optfile.cfl}
\LettrineOptionsFor{X}{findent=6ex}
\LettrineOptionsFor{Y}{findent=5ex}
\endinput
\end{filecontents}

\documentclass{article}
\usepackage{lettrine}
\usepackage{xcolor}
\usepackage{lipsum}

\definecolor{Steel}{HTML}{66676A}
\definecolor{Mgold}{HTML}{D4AF37}
\definecolor{Offblack}{HTML}{1E1E1E}

\newcommand{\LettrineBackColor}{Mgold}
\newcommand{\LettrineDecoColor}{Steel}
\newcommand{\LettrineLetterColor}{Offblack}

\newcommand{\layerlettrine}[3][]{%
\lettrine[#1]{%
\rlap{\rlap{\color{\LettrineDecoColor} #2}%
     {\color{\LettrineBackColor} \em{#2}}}%
     {\color{\LettrineLetterColor}\lowercase{#2}}}{#3}%
}

\begin{document}

\lettrine{X}{omot} \lipsum[1]

\layerlettrine{Y}{olanda} \lipsum[2]

\end{document}

Fails at:

("C:\Program Files\MiKTeX 2.9\tex\latex\lipsum\lipsum.sty")
No file mwe_lettrine.aux.
(optfile.cfl) (optfile.cfl)
! Missing \endcsname inserted.
<to be read again> 
                   \hbox 
l.25 \layerlettrine{Y}{olanda}
                               \lipsum[2]
? 
cfr
  • 198,882
  • Welcome! \em doesn't take an argument. – cfr Sep 20 '17 at 02:58
  • I've edited your code so it is easier to see the error and reproduce it. You can, of course, roll-back if you don't like it. – cfr Sep 20 '17 at 03:22
  • I don't think the package is really prepared for this kind of thing. The combination is just throwing too much at it, given the way it handles the options from the cfl file. (I'm not really sure why it does things the way it does, but I don't think it is going to be able to handle the option setting plus the EB Garamond stuff.) However, I may be completely wrong. – cfr Sep 20 '17 at 03:52
  • Thank you for the corrections. I will add that the function does work if the desired options are added as \layerlettrine[findent=4em]{Y}{olanda} \lipsum[2], but that seems not to be the preferred way. I'll kludge if I must though. – Sue Dunham Sep 22 '17 at 02:57
  • If you don't get an answer, I suggest emailing the package author. – cfr Sep 22 '17 at 03:25

0 Answers0