1

This question is an extension of the one posed a while back in Adding a Letter to an Image in a Do-It-Yourself Lettrine

Consider the MWE

\documentclass{book}
\usepackage{lettrine}
\usepackage{xcolor}

\definecolor{imperialred}{RGB}{239, 38, 50} \definecolor{deepskyblue}{RGB}{34, 154, 202}

\usepackage{scalerel,stackengine} \setlength{\textwidth}{5.25in} \fboxsep=2.25pt \newcommand\my[2][7ex]{\scaleto{\colorbox{deepskyblue}{% \textcolor{imperialred}{\abovebaseline[0pt]{#2}}}}{#1},}

\begin{document} \thispagestyle{empty} \LARGE \lettrine[nindent=.4em]{\bfseries\my I}{} would like add a frame (or perhaps, some other kind of a decorative border) around this this box.

\lettrine[nindent=.4em]{\my T}{he} commands of tcolorbox do not seem to be applicable here. \end{document}

with the output

enter image description here

QUESTION: How may I add a colored frame of adjustable thickness (or perhaps, some other kind of decorative border) around the blue ``do-it-yourself'' lettrines?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • 1
    \fboxrule5pt\fcolorbox{imperialred}{deepskyblue}{ ... } – Fran May 12 '22 at 06:51
  • @Fran Thank you for the comment; but perhaps, you might expand this as an answer. I'm sorry, but I cannot figure out where it goes in the code. – DDS May 12 '22 at 13:42
  • It is just change your \colorbox{color1} by \fcolorbox{color2}{color1} (with "f" of "f"rame for color 2) and, optionally, you can add before \fboxrule to set the thickness of the frame to 5pt (or what you want). – Fran May 12 '22 at 16:23

1 Answers1

2

You can use \fcolorbox instead of \colorbox to add the a colored frame and \fboxrule` to set the thickness of this frame.

Out of the question, I set \lettrine command to avoid use of \scaleto or \abovebaseline: Not sure if it matches the desired format, but I hope that you can get the idea for a fine-tuning. I also avoided the macros to make the example simpler and add some more dummy text to check that drop capital fit smoothly.

mwe

\documentclass{book}
\usepackage{lettrine, lipsum}
\usepackage{xcolor}
\definecolor{imperialred}{RGB}{239, 38, 50}
\definecolor{deepskyblue}{RGB}{34, 154, 202}
\begin{document}
\LARGE

\lettrine[lines=3,loversize=.6,lraise=.1,nindent=.5em]{\fboxsep5pt\fboxrule5pt\fcolorbox{imperialred}{deepskyblue}{\color{imperialred}I}}{} would add a frame (or perhaps, some other kind of a decorative border around this this box. \lipsum[1][1-4]

\lettrine[lines=3,loversize=.6,lraise=.1,nindent=.5em]{\fboxsep5pt\fboxrule5pt\fcolorbox{imperialred}{deepskyblue}{\color{imperialred}T}}{he} commands of tcolorbox do not seem to be applicable here. \lipsum[1][1-4]

\end{document}

Fran
  • 80,769
  • Thank you for posting this answer. At first, I was not able to replicate your lettrine displays, as they were much smaller and fell below the first sentence. Perhaps because I compiled your code with lualatex had something to do with it. Nevertheless, when I invoked the package type1cm---most everything seemed to work well, with the minor exception that I would need to shift the blue portion of the lettrine ever so slightly to the left to center it within the red frame. Do you have any idea how I might invoke such a shift so that the blue portion is "perfectly" centered? Yours seems fine – DDS May 12 '22 at 19:25
  • @mlchristians In this MWE, as is, or in your document? I also compiled this with lualatex and type1cm do not change the output at all, but it fix the small lettrines obtained only with pdflatex (same output, as far I see). Maybe you are really using "pdflatex"? Otherwise, your document must have something else that change the output. – Fran May 13 '22 at 02:59
  • Thank you for taking the time to look into it. – DDS May 13 '22 at 19:38