5

The following code mimics Steven B. Segletes' answer to the question posed in Adding a Letter to an Image in a Do-It-Yourself Lettrine:

\documentclass[12pt]{book}
\usepackage{yfonts,xcolor,scalerel,stackengine,lettrine}
\definecolor{Blood}{RGB}{142,0,28}
\definecolor{Gold}{RGB}{255,179,0}
\setlength{\textwidth}{5.5in}

\fboxsep=1pt \newcommand\mylettrine[2][2.75ex]{\scaleto{\colorbox{Blood}{% \initfamily\textcolor{Gold}{\abovebaseline[0pt]{#2}}}}{#1},}

\usepackage[sfdefault]{cabin} \begin{document} \thispagestyle{empty} \LARGE

\lettrine[lines=3,loversize=0.25,nindent=0.4em,findent=-0.6em]{\mylettrine{N}}{on} semper erat aestas.\[30pt] \lettrine[lines=3,loversize=0.25,nindent=0.4em,findent=-0.6em]{\mylettrine{W}}{}\[30pt] \lettrine[lines=3,loversize=0.25,nindent=0.4em,findent=-0.6em]{\mylettrine{R}}{} \end{document}

which produces the output

enter image description here

As you can see, the lettrines are not all of uniform size---and stackengine seems to accommodate the various letter sizes quite nicely; however, a little "tweaking" is in order, as the initfamily lettrine letter that I am trying to add a background color to also contains decorative florishes that extend beyond the given letter, and consequently, outside of the colored box I am trying to "stack" the letter on.

I have tried adjusting the \fboxsep command various ways, but have seemingly made matters a little worse.

QUESTION: Is there a way to, and if so, how, may I uniformly adjust the colored background so that all of these initfamily decorative lettrines may appear reasonably centered on the colored background with all the jumping flourishes nicely contained within the squarish colored box?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36
  • Do you mean setting \fboxsep=5pt, because it interacts with the scaling? What does "worse" mean (in or out?)? – Cicada Aug 24 '22 at 15:35
  • The centering is thrown off so that the decorative letter requires a greater vertical and horizontal, though not necessarily uniform, shift to be centered---if the colored box were big enough. – DDS Aug 24 '22 at 15:40
  • @Cicada The centering is thrown off so that the decorative letter requires a greater vertical and horizontal, though not necessarily uniform, shift to be centered---if the colored box were big enough. – DDS Aug 24 '22 at 19:18

1 Answers1

4

You can define a box command that uses a defined padding for each letter.

I just did these by eye.

enter image description here

\documentclass[12pt]{book}
\usepackage{yfonts,color,lettrine}
\definecolor{Blood}{RGB}{142,0,28}
\definecolor{Gold}{RGB}{255,179,0}
\setlength{\textwidth}{3in}

\begin{document}

\newcommand\qqq[1]{{% \setlength\fboxsep{0pt}% \colorbox{Blood}{% \sbox0{\color{Gold}\initfamily#1}% \ifcsname Left #1\endcsname\kern\csname Left #1\endcsname\fi \ifcsname Top #1\endcsname\ht0=\dimexpr\ht0+\csname Top #1\endcsname\relax\fi \ifcsname Bottom #1\endcsname\dp0=\dimexpr\dp0+\csname Bottom #1\endcsname\relax\fi \box0 % \ifcsname Right #1\endcsname\kern\csname Right #1\endcsname\fi }}}

\expandafter\def\csname Left A\endcsname{1pt} \expandafter\def\csname Left B\endcsname{3pt} \expandafter\def\csname Left D\endcsname{.5pt} \expandafter\def\csname Left E\endcsname{.1pt} \expandafter\def\csname Left I\endcsname{2pt} \expandafter\def\csname Left J\endcsname{2pt} \expandafter\def\csname Left M\endcsname{3pt} \expandafter\def\csname Left N\endcsname{2pt} \expandafter\def\csname Left O\endcsname{2pt} \expandafter\def\csname Left P\endcsname{.5pt} \expandafter\def\csname Left Q\endcsname{2pt} \expandafter\def\csname Left Y\endcsname{1pt}

\expandafter\def\csname Right C\endcsname{.5pt} \expandafter\def\csname Right G\endcsname{.5pt} \expandafter\def\csname Right H\endcsname{.1pt} \expandafter\def\csname Right L\endcsname{.1pt} \expandafter\def\csname Right P\endcsname{2pt}

\expandafter\def\csname Top A\endcsname{.5pt} \expandafter\def\csname Top B\endcsname{3pt} \expandafter\def\csname Top C\endcsname{3pt} \expandafter\def\csname Top D\endcsname{2pt} \expandafter\def\csname Top E\endcsname{1pt} \expandafter\def\csname Top F\endcsname{3.5pt} \expandafter\def\csname Top G\endcsname{3.5pt} \expandafter\def\csname Top H\endcsname{3pt} \expandafter\def\csname Top I\endcsname{2pt} \expandafter\def\csname Top J\endcsname{2pt} \expandafter\def\csname Top K\endcsname{3pt} \expandafter\def\csname Top L\endcsname{1pt} \expandafter\def\csname Top M\endcsname{1pt} \expandafter\def\csname Top N\endcsname{2pt} \expandafter\def\csname Top O\endcsname{2.5pt} \expandafter\def\csname Top P\endcsname{2.5pt} \expandafter\def\csname Top Q\endcsname{2pt} \expandafter\def\csname Top R\endcsname{2.5pt} \expandafter\def\csname Top S\endcsname{3pt} \expandafter\def\csname Top T\endcsname{3.5pt} \expandafter\def\csname Top U\endcsname{2pt} \expandafter\def\csname Top V\endcsname{2pt} \expandafter\def\csname Top W\endcsname{2pt} \expandafter\def\csname Top X\endcsname{3pt} \expandafter\def\csname Top Y\endcsname{4pt} \expandafter\def\csname Top Z\endcsname{3pt}

\expandafter\def\csname Bottom A\endcsname{1.5pt} \expandafter\def\csname Bottom B\endcsname{.1pt} \expandafter\def\csname Bottom K\endcsname{.1pt} \expandafter\def\csname Bottom M\endcsname{2pt} \expandafter\def\csname Bottom N\endcsname{.5pt} \expandafter\def\csname Bottom O\endcsname{.5pt} \expandafter\def\csname Bottom P\endcsname{1.5pt} \expandafter\def\csname Bottom Q\endcsname{.5pt} \expandafter\def\csname Bottom R\endcsname{1.5pt} \expandafter\def\csname Bottom U\endcsname{.1pt} \expandafter\def\csname Bottom X\endcsname{.1pt} \expandafter\def\csname Bottom Y\endcsname{.1pt}

% just for tests \def\doqqq#1{#1: \qqq{#1}\par\doqqq} \long\def\stopqqq#1\doqqq{}

\doqqq ABCDEFGHIJKLMNOPQRSTUVWXYZ\stopqqq

\end{document}

David Carlisle
  • 757,742