0

Here is my MWE:

\documentclass[12pt,oneside,table,xcdraw]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table,xcdraw,svgnames,dvipsnames]{xcolor}
\usepackage{lettrine}
\definecolor{LettrineRed}{RGB}{137,0,34}

% The following command WORKS!
\renewcommand{\LettrineFontHook}{\color[gray]{0.5}}

% The following command does NOT Work!
% \renewcommand{\LettrineFontHook}{\textcolor{LettrineRed}}

\begin{document}
    \lettrine[lines=3]{T}{his is an example} of what happens when attempting to use LettrineFontHook to set the color of the first character to a color, in this case LettrineRed (defined as {RGB}{137,0,34})
\end{document}

What syntax do I need to specify the color of the Lettrine drop-cap character as LettrineRed (defined as {RGB}{137,0,34})?

I tried using \LettrineFontHook with \textcolor{LettrineRed} in lieu of \color[gray]{0.5}, but the error:

! Argument of \fontsize  has an extra }

appears when compiled.

Thanks.

3
  • tex.stackexchange.com/a/291865/142180 has an example in pdflatex. Try using a full font selection statement. Commented Feb 8, 2021 at 18:27
  • 1
    Why do you use \textcolor? Use \color, as in the working case.
    – campa
    Commented Feb 8, 2021 at 18:40
  • @campa: Is there a way to use a defined color, e.g. 'LettrineRed' (\definecolor{LettrineRed}{RGB}{137,0,34}) with \LettrineFontHook as a way to color the initial Lettrine character 'LettrineRed'? Using \color or \textcolor are both options if they work. The only example for code I've found uses \color[gray]{0.5} as shown in the MWE above, but provides NO guidance how to use a custom color with \color. I've tried many permutations, but I am not conversant enough in LaTeX to know how to code \renewcommand{\LettrineFontHook} using \color or \textcolor with the custom color 'LettrineRed'. Thanks! Commented Feb 9, 2021 at 6:36

1 Answer 1

1

It appears the correct syntax for using a custom color (in this case LettrineRed as defined in the above MWE) to change the color of the initial character when using the Lettrine package is as follows:

\renewcommand{\LettrineFontHook}{\color{LettrineRed}}

instead of the incorrect syntax that was mentioned in the MWE:

\renewcommand{\LettrineFontHook}{\textcolor{LettrineRed}}

The error occurred when attempting to substitute \textcolor for \color using the \color[gray]{0.5} syntax (with square brackets) as a template.

The syntax that worked is simply using the \color option with curly { } braces around the custom color as opposed to square [ ] brackets.

4
  • @Ingmar - Thank you ... Commented Feb 9, 2021 at 12:40
  • There's usually more than one way to do it, but glad you got it to work.:)
    – Ingmar
    Commented Feb 9, 2021 at 12:41
  • Your last sentence is incorrect. Both color and \textcolor can have an optional parameter in square brackets. The difference is that \color[...]{...} is a switch (=make text in given color from now on), while \textcolor[...]{...}{...} colors its second mandatory argument.
    – campa
    Commented Feb 9, 2021 at 12:54
  • @campa Thank you for the clarification. I've edited my answer in an attempt to clarify what I did to find a way to use LettrineFontHook with a custom color. Commented Feb 10, 2021 at 8:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .