5

Consider the code

\documentclass{book}
\usepackage{lettrine}
\usepackage{tikz}
\setlength{\textwidth}{5.25in}
\begin{document}
\thispagestyle{empty}
\LARGE
\lettrine[nindent = .4em]{\tikz\fill[black] (0,0) rectangle (5ex,7ex);\,}{} would like this box to be a lettered lettrine; more specifically, I would like it to contain a fitted-to-the-box, white, bold capital I. How may this be accomplished? Thank you.
\end{document} 

which produces

enter image description here

QUESTION: How may I add within the box a big, bold (white-colored) letter (such as I) in order to obtain a fairly respectable homemade lettrine? (I got this idea after looking at the post lettrine with image which does not show how to do this.)

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36

1 Answers1

7

Here, I use a simple \colorbox to contain the versal and then scale it to the desired size. EDITED to handle descenders, such as capital Q.

\documentclass{book}
\usepackage{lettrine}
\usepackage{xcolor,scalerel,stackengine}
\setlength{\textwidth}{5.25in}
\fboxsep=1pt
\newcommand\my[1]{\scaleto{\colorbox{black}{%
  \textcolor{white}{\abovebaseline[0pt]{#1}}}}{7ex}\,}
\begin{document}
\thispagestyle{empty}
\LARGE
\lettrine[nindent = .4em]{\my I}{} would like this box to be a
  lettered lettrine; more specifically, I would like it to contain 
  a fitted-to-the-box, white, bold capital I. How may this be 
  accomplished? Thank you.

\lettrine[nindent = .4em]{\my W}{ould} this work as I desire it? Who can say? Let us give it the old ``college try'' and see what results.

\lettrine[nindent = .4em]{\my Q}{uestions} remain on the proper method to handle descenders. In this case, I shift all letters up to sit fully upn the baseline, even if it means the ``Q'' gets diminished slightly in size. \end{document}

enter image description here

This approach provides ample opportunity for customization. For example, colors and versal font can easily be adjusted (I also increased \fboxsep by .5 pt, to contain the protruding points on W):

\documentclass{book}
\usepackage{lettrine}
\usepackage{xcolor,scalerel,stackengine}
\setlength{\textwidth}{5.25in}
\fboxsep=1.5pt
\newcommand\my[1]{\scaleto{\colorbox{black!70}{%
  \textcolor{white}{\abovebaseline[0pt]{$\mathcal{#1}$}}}}{7ex}\,}
\begin{document}
\thispagestyle{empty}
\LARGE
\lettrine[nindent = .4em]{\my I}{} would like this box to be a
  lettered lettrine; more specifically, I would like it to contain 
  a fitted-to-the-box, white, bold capital I. How may this be 
  accomplished? Thank you.

\lettrine[nindent = .4em]{\my W}{ould} this work as I desire it? Who can say? Let us give it the old ``college try'' and see what results.

\lettrine[nindent = .4em]{\my Q}{uestions} remain on the proper method to handle descenders. In this case, I shift all letters up to sit fully upn the baseline, even if it means the ``Q'' gets diminished slightly in size. \end{document}

enter image description here

Alternately, with the mathrsfs package, defining the color as red!50!black and the versal as $\mathscr{#1}$. Further, I reduce the versal height from 7ex to 6ex:

\documentclass{book}
\usepackage{lettrine}
\usepackage{xcolor,scalerel,stackengine,mathrsfs}
\setlength{\textwidth}{5.25in}
\fboxsep=1.5pt
\newcommand\my[1]{\scaleto{\colorbox{red!50!black}{%
  \textcolor{white}{\abovebaseline[0pt]{$\mathscr{#1}$}}}}{6ex}\,}
\begin{document}
\thispagestyle{empty}
\LARGE
\lettrine[nindent = .4em]{\my I}{} would like this box to be a
  lettered lettrine; more specifically, I would like it to contain 
  a fitted-to-the-box, white, bold capital I. How may this be 
  accomplished? Thank you.

\lettrine[nindent = .4em]{\my W}{ould} this work as I desire it? Who can say? Let us give it the old ``college try'' and see what results.

\lettrine[nindent = .4em]{\my Q}{uestions} remain on the proper method to handle descenders. In this case, I shift all letters up to sit fully upn the baseline, even if it means the ``Q'' gets diminished slightly in size. \end{document}

enter image description here


SPECIAL SUPPLEMENT FOR BARBARA BEETON

To address the dismay brought on by my handling of descenders like Q in the above approach, I felt compelled to remedy the situation. It still requires a little manual intervention with the Q, both to extend the lettrine lines from 2 to 3, as well as to grow the vertical extent of the Q from the default 7ex height to something larger (here 9ex).

\documentclass{book}
\usepackage{lettrine}
\usepackage{xcolor,scalerel,stackengine}
\setlength{\textwidth}{5.25in}
\fboxsep=1pt
\newcommand\my[2][7ex]{\scaleto{\colorbox{black}{%
  \textcolor{white}{\abovebaseline[0pt]{#2}}}}{#1}\,}
\begin{document}
\thispagestyle{empty}
\LARGE
\lettrine[nindent = .4em]{\my I}{} would like this box to be a
  lettered lettrine; more specifically, I would like it to contain 
  a fitted-to-the-box, white, bold capital I. How may this be 
  accomplished? Thank you.

\lettrine[nindent = .4em]{\my W}{ould} this work as I desire it? Who can say? Let us give it the old ``college try'' and see what results.

\lettrine[nindent = .4em, lines=3]{\my[9ex] Q}{uestions} remain on the proper method to handle descenders. In this case, I increase the number of lettrine lines from 2 to 3, and I have modified \textbackslash my to take an optional argument length, to revise the height of the encased letter. \end{document}

enter image description here

  • I was looking at those $s and thinking when suddenly "An edit has been made to this post" and then they were gone. – Don Hosek Aug 19 '21 at 14:03
  • @DonHosek Actually, not. Since scalerel works by default in math mode, I used the Stoopid convention of employing $ delimiters to force the argument into text mode (regret #3716). However, in this case, the \colorbox accomplishes text mode without the need for the $ delimiters, so the delimiters were not necessary. – Steven B. Segletes Aug 19 '21 at 14:15
  • @Steven B. Segletes Thank you for this most helpful answer. – DDS Aug 19 '21 at 14:31
  • @mlchristians You are welcome. I edited my answer to provide additional variants. – Steven B. Segletes Aug 19 '21 at 14:40
  • @Steven B. Segletes Thank you kindly for the additional examples which are useful to my purpose. – DDS Aug 19 '21 at 16:03
  • 1
    Very nice, both the mechanism and the well illustrated answer. – barbara beeton Aug 19 '21 at 16:45
  • Thank you @barbarabeeton. That means a lot coming from you, a noted expert and stickler for detail. – Steven B. Segletes Aug 19 '21 at 16:46
  • Would you consider writing it up as a short note for TUGboat, or contributing it to the "Duckboat"? I think other people would like it. – barbara beeton Aug 19 '21 at 16:48
  • @barbarabeeton I'd be happy to, though it is kind of self-explanatory. How should I format things (simple article class)? Length desired? BTW, I am in something of a hectic phase, as I will be retiring from federal service on 9/30. If communicating via email is preferable, my recent package entries provide personal email, my older packages my USG email. – Steven B. Segletes Aug 19 '21 at 16:52
  • @barbarabeeton I felt the pressure. I had to go back and address the issue of descenders like Q. – Steven B. Segletes Aug 19 '21 at 17:11
  • Hmmm. With the Roman, the Q would look better with a third line cut out of the main text, the baselines matched with the second line, and the tail hanging below. But I'm being mega-niggly here, and I'm afraid that would be a major project. But I really couldn't bring myself to ignore it. (As you quite fairly observed, I'm a fussbudget.) – barbara beeton Aug 19 '21 at 17:46
  • 2
    @barbarabeeton Please see the SUPPLEMENT to my answer, designed just for you. – Steven B. Segletes Aug 19 '21 at 19:12
  • Oh, that's great! now the height above the top text line is uniform, and all the initials are all the same size. (I'm ignoring the request to move this to chat.) – barbara beeton Aug 19 '21 at 20:22