将 Initfamily 字母置于 Colorbox 的中心,并调整其大小以用作双色字母

将 Initfamily 字母置于 Colorbox 的中心,并调整其大小以用作双色字母

考虑一下代码

\documentclass{book}
\usepackage{lettrine}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{scalefnt}
\usepackage[tracking=true]{microtype}

\input GoudyIn.fd
\newcommand*\initfamily{\usefont{U}{GoudyIn}{xl}{n}}

\begin{document}
\thispagestyle{empty}
\large

1. {\Huge{\scalefont{4.75}{\setlength\fboxsep{12pt}\colorbox{black}{\color{yellow}{\initfamily{H}}}}}}

\vspace*{45pt}

2.
{\Huge{\scalefont{4.75}{\setlength\fboxsep{0pt}\colorbox{black}{\color{yellow}{\initfamily{H}}}}}}

\vspace*{45pt}

3.
\lettrine[lines=3,loversize=.25]{\color{yellow}{\initfamily{H}}}{ow} may I center the first "home-made" lettrine within the black square so that  the second lettrine (modified) displays no black border at all? (ii) Secondly, I would like to use the revised second lettrine in place of the standard one used in 3.
\end{document}

产生输出

在此处输入图片描述

图像已被放大以便于观看。

我不知道这些图像是否以最佳方式构建,但基本上,我希望能够做到以下几点:

(i)拍摄第一张图像,将黄色 initfamily 字母 H 完美地置于黑色背景的中心。(完成后,我可以使用 生成图像,\fboxsep{0pt}这应该(希望)产生一个双色的 Goudy Initialen 字母,然后我想用它替换(3)中显示的实际字母。)

(ii) 将双色图像的大小调整为 3. 中给出的字母的大小;然后用 3 中的自制字母替换给定的字母。

问:怎样才能实现这一点?

谢谢。

答案1

您需要考虑侧边距,这可以通过使用负字距(添加回findent)来实现:

\documentclass[foolscap]{octavo}% just to get a small image
\usepackage{lettrine,lmodern,xcolor}
\usepackage[tracking=true]{microtype}
\input GoudyIn.fd
\renewcommand{\LettrineFontHook}{\usefont{U}{GoudyIn}{xl}{n}}
\fboxsep=0pt% padding thickness
\fboxrule=0pt% border thickness
\begin{document}
\lettrine[lines=3,loversize=.25,findent=.04em,nindent=1pt]{\fcolorbox{yellow}{yellow}{H\kern-.04em}}{ow} 
may I center the first ``home-made'' lettrine within the black
square so that the second lettrine (modified) displays no
black border at all? (ii)~Secondly, I would like to use the 
revised second lettrine in place of the standard one used in 3.
\end{document}

输出

(使用 ems 作为字距意味着即使你将文档选项更改为11pt或,这也能正常工作12pt。)

如果您喜欢这些价值观并希望将它们贯穿在整个文档中,您可以将以下内容添加到序言中:

\setcounter{DefaultLines}{3}
\renewcommand*{\DefaultLoversize}{0.25}% I’d suggest a value like 0.06
\setlength{\DefaultFindent}{0.04em}
\setlength{\DefaultNindent}{1pt}

在这种情况下,输入单个字母就更简单了:\lettrine{\colorbox{yellow}{H\kern-.04em}}{ow}

答案2

去年秋天我曾为 TUGboat 撰写过这篇文章,但不知何故,始终未能发表。

以下是引用的问题:在自制的 Lettrine 中向图像添加字母

在这里,我介绍\clettrine如何帮助您在颜色框内实现居中通用操作。

\begin{filecontents*}[overwrite]{clettrine.bib}
@MISC{lettr,
  TITLE = "Typesetting dropped capitals with \LaTeX{}",
  AUTHOR = "Flipo, Daniel",
  HOWPUBLISHED = "\url{https://www.ctan.org/pkg/lettrine}",
  YEAR="2020",
}
@MISC{texse,
  TITLE = "Adding a Letter to an Image in a Do-It-Yourself Lettrine",
  AUTHOR = "mlchristians",
  HOWPUBLISHED = "\url{https://tex.stackexchange.com/questions/611290/adding-a-letter-to-an-image-in-a-do-it-yourself-lettrine/611292\#611292}",
  YEAR = "2021"
}
@MISC{acorn,
  TITLE = "Acorn Initials",
  AUTHOR = "{The \LaTeX{} Font Catalogue}",
  HOWPUBLISHED = "\url{https://www.tug.org/FontCatalogue/acorn/}",
  YEAR = "2018"
}
\end{filecontents*}

%\documentclass{ltugboat}
\documentclass{article}
\textwidth=3.5in
\input Acorn.fd
\newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}}
\usepackage{lettrine,xcolor,scalerel,stackengine}
\usepackage{mathrsfs,graphicx}
\usepackage[hyphens]{url}
\setlength{\textwidth}{3in}

% USER PARAMETERS:
% LETTRINE SUPPLIED
\setcounter{DefaultLines}{2}
\setlength{\DefaultFindent}{2pt}
\setlength{\DefaultNindent}{.7ex}
% \clettrine SPECIFIC
\newcommand\clfgcolor{white!85!orange}
\newcommand\clbgcolor{black!60!blue}
\newcommand\cloffset{12pt}
\newcommand\clsep{2pt}
\newcommand\clvshift{0pt}
\newif\ifclsidesep
\clsidesepfalse
\newcommand\clformat[1]{#1}
% END USER PARAMETERS

\newlength\clbls
\newlength\cldpst
\newcommand\clettrine[1][0]{%
  \def\claddlines{#1}\clettrineaux}
\newcommand\clettrineaux[3][\clvshift]{%
  \edef\cltmp{\the\fboxsep}%
  \setlength\fboxsep{0pt}%
  \ifclsidesep\def\clsidekern{\kern\clsep}%
  \else\def\clsidekern{}\fi
  \setlength\clbls{\the\baselineskip}%
  \setlength\cldpst{\the\dp\strutbox}%
  \lettrine
    [lines=\the\numexpr\theDefaultLines
           +\claddlines]%
    {\clboxscale{#1}%
     {\the\dimexpr\cloffset
      +\value{DefaultLines}\clbls
      +\claddlines\clbls
      -\cldpst\relax}%
     {\clformat{\clsidekern#2\clsidekern}}}%
    {#3}%
  \setlength\fboxsep{\cltmp}}
\newcommand\clboxscale[3]{\raisebox{#1}{%
  \colorbox{\clbgcolor}{%
  \addstackgap[\clsep]{\scaleto{%
    \abovebaseline[0pt]{%
      \textcolor{\clfgcolor}{#3}}}%
    {\dimexpr#2-\clsep-#1}}}}}

% DID STUFF TO MAKE IT COMPILE
\newcommand\citeauthoryear[3]{\small #2, #3}
\newcommand\UseExtraLabel{}
\sloppy
% END "DID STUFF"

% DOCUMENT SHORTCUTS
\newcommand\Clettrine{\cmd{clettrine}}
\newcommand\cmd[1]{\texttt{\upshape\textbackslash #1}}
\begin{document}
\section*{\clettrine{C}{olorboxed} Versals for Use with Lettrine}

Steven B Segletes

\section*{Abstract}

The lettrine package\cite{lettr} provides the means to typeset
  dropped capitals, also known as decorative initials or
  ``versals'' at the beginning of paragraphs.
Here, the lettrine package is adapted to provide a convenient
  and consistent way to employ colorboxed letters (either
  conventional letters or decorative initials).

\centerline{------}%\section{Background}

\clettrine{O}{n} \texttt{tex.stackexchange.com}\cite{texse}, a question
  was asked about a ``do-it-yourself'' lettrine, in which
  a letter could be inserted into a specified black box that
  had been put in place by way of lettrine.
My answer to that question garnered the accepted answer and
  received additional notice that culminated in this article, which
  formalizes that answer for more general use.

%\section{The Approach}

\clettrine{T}{he} approach taken was to create
  a macro that we here call \Clettrine{}.
The macro employs lettrine, but takes into account an 
  additional set of parameters defined 
  specifically for \Clettrine{} configuration.
While the approach may be generalized at some point to take
  full advantage of lettrine options, this early implementation
  instead assumes certain features of the versal; thus, the
  normal lettrine optional key-word argument is \textit{not}
  made available to the user of \Clettrine.
The \Clettrine{} command uses the same two mandatory
  arguments that \cmd{lettrine} does.
In addition, \Clettrine{} has its own unique set of 
  \textit{optional} arguments that will be discussed 
  subsequently.

A good place to start might be to show the parameters that
  are used to configure \Clettrine, as seen in 
  Figure~\ref{fg:cldims}.
Some of the parameters, those listed in red, are parameters
  provided by the lettrine package.
The defaults for these may be changed by the user and
  \Clettrine{} will make use of the revised defaults.
Other lettrine parameters not listed in the figure should
  be left in their package-default state.

\begin{figure}[ht]
\hspace{-.15\linewidth}\includegraphics[width=1.15\linewidth]{clettrinedims}
\caption{Parameters employed by \Clettrine}
\label{fg:cldims}
\end{figure}

In addition to the lettrine parameters shown in red, there
  are several parameters defined in Figure~\ref{fg:cldims}
  that are shown in the color cyan.
These are definitions introduced by this implementation of 
  \Clettrine{} and are available for reconfiguration by the
  user.

%\section{User Definable Parameters}

\clettrine{L}{et} us now discuss parameter definitions and 
  values.
The parameters used to define the typeset of the versal 
  ``L'' at the start of this paragraph are given as follows:

{\footnotesize
\begin{verbatim}
% USER PARAMETERS:
% LETTRINE SUPPLIED
\setcounter{DefaultLines}{2}
\setlength{\DefaultFindent}{2pt}
\setlength{\DefaultNindent}{.7ex}
% \clettrine SPECIFIC
\newcommand\clfgcolor{white!85!orange}
\newcommand\clbgcolor{black!60!blue}
\newcommand\cloffset{12pt}
\newcommand\clsep{2pt}
\newcommand\clvshift{0pt}
\newif\ifclsidesep
\clsidesepfalse
\newcommand\clformat[1]{#1}
% END USER PARAMETERS
\end{verbatim}
\par}
To users of lettrine, the first three parameters should
  be familiar: the number of text lines encompassed by
  the versal (\texttt{DefaultLines}), the indent of the
  first line following the versal (\cmd{DefaultFindent}),
  and the indent of the next line(s) to the right of the 
  versal (\cmd{DefaultNindent}).

The next group of parameters are \Clettrine{} specific.
The foreground and background colors are defined as 
  \texttt{white!85!orange} (\cmd{clfgcolor}) and
  \texttt{black!60!blue} (\cmd{clbgcolor}),
  respectively.

The command \cmd{cloffset} is defined as 12pt. 
This parameter is the vertical length that the colorboxed
  versal extends above the \cmd{ht\textbackslash
  strutbox} of the top line of the paragraph.

The next parameter, \cmd{clsep} might be used for
  several reasons, but primarily to compensate for
  vertical protrusion of glyphs outside of their
  bounding box.
In the ``S'' of Figure~\ref{fg:cldims}, for example, we see 
  horizontal lines labelled ``lettertop'' and ``letterbottom''.
These denote the upper and lower extent of the bounding box
  for the Computer-Modern ``S'' glyph.
As can be seen, the glyph extends beyond the lines in what
  is commonly known as ``protrusion''.
Without the use of \cmd{clsep}, the ``S'' would extend
  vertically beyond the top and bottom of the colorbox.
Note, importantly, that \cmd{clsep} is not defined in terms
  of the original unscaled glyph, but in terms of the 
  versal-sized scaled glyph.

The next parameter, \cmd{clvshift}, denotes a vertical
  shift of the ``letterbottom'' placement.
When \cmd{clvshift} is set to 0pt, the letterbottom of the
  versal will be aligned with the baseline of text to its
  right.
I personally find the value of 0pt to be aesthetically
  pleasing---however there are two reasons why one might
  consider changing the value: (1) if the \cmd{clsep} is
  so large as to interfere with the text below the versal, or
  (2) to specially adjust descended versals, such as the
  letter ``Q'', where the letterbottom does not coincide 
  with the glyph's baseline.
More will be said on this latter point subsequently.

The parameter \cmd{ifclsidesep} is a T/F if-parameter.
When false, the colorbox extends horizontally only as far
  as the outer edge of the glyph's bounding box.
Sometimes, however, one might prefer that the colorbox 
  extend past the bounding box, for example, if the glyph 
  set experiences horizontal protrusion.
When \cmd{clsideseptrue}, the colorbox is likewise extended 
  horizontally on both sides, by the dimension \cmd{clsep}.
Another reason to set this condition true might be if 
  the glyph suffers no protrusions,
  either horizontally or vertically, but the user desires
  a uniform colorbox border around the glyph.

The final \Clettrine{} parameter is actually the command
  used to typeset the versal, given as \cmd{clformat}.
This command takes an argument, namely, the letter that
  is to be typeset.
The job of the command is to use the specified letter to 
  select the appropriate glyph.
To this point in the article, the glyph
  selected by this command is merely the letter in the 
  currently active font.
However, if the user wishes the versal to be selected from
  an alternate font family or even an alternate font, the
  \cmd{clformat} should be redefined to make the conversion.
Examples of this conversion will be shown subsequently.

%\section{Syntax}

\clettrine{S}{yntax} for the \Clettrine{} command is
  as follows:\\[4pt]\bgroup\itshape
  \verb|\clettrine[|extra-lines\verb|][|clvshift-value\verb|]%|\\
  \verb|  {|versal\verb|}{|rest-of-versal-word\verb|}|
\\[4pt]\egroup
The usage envisioned is that the optional argument(s) will 
  only be employed for versals that have descenders.
The use of these two options are sufficient to present the
  descended versal in a manner that preserves the original 
  baseline relative to their undescended counterparts.

Consider that our default \Clettrine{} parameters to this
  point (with zero \cmd{clvshift}) align the letterbottom
  of the versal with the baseline of the 2nd line of
  paragraph text.
Such is the case with the versal ``S'' that opens this
  section.
Let us examine what happens with a descended letter, as
  depicted in Figure~\ref{fg:descenders}.

\begin{figure}[ht]
\centering
\def\showbl{\makebox[0pt]{\color{cyan}\rule{60pt}{.5pt}}}
\begin{minipage}[t]{.31\linewidth}\raggedright
\clettrine{Q}{} without \showbl options. Q squeezed into 2-line
  box.\\ Option: N/A
\end{minipage}
\rule[-95pt]{1.5pt}{95pt}
\begin{minipage}[t]{.31\linewidth}\raggedright
\clettrine[1]{Q}{} with \showbl one line added. Q too large.\\
  Option: \texttt{[1]}
\end{minipage}
\rule[-95pt]{1.5pt}{95pt}
\begin{minipage}[t]{.31\linewidth}\raggedright
\clettrine[1][3.5pt]{Q}{} plus \showbl one line \& vshift.
  Base-\allowbreak line match!\\   Options: \texttt{[1][3.5pt]}
\end{minipage}

\hfil(a)\hfil\hfil\hfil(b)\hfil\hfil\hfil(c)\hfil\hfil
\caption{Treatment of Descenders}
\label{fg:descenders}
\end{figure}

In Figure~\ref{fg:descenders}(a), 
  \verb|\clettrine{Q}{}| typesets the descending ``Q'' 
  without any options.
The effect is to squeeze the versal-Q into the same vertical
  space as allocated for letters like ``S''.
Because Q descends, this makes the versal ``Q'' too small,
  forcing the Q's baseline much higher.

In Figure~\ref{fg:descenders}(b), 
  \verb|\clettrine[1]{Q}{}| allocates an extra line for the
  versal.
However, this is more space than needed, as we now see the
  baseline of the ``Q'' sinks below the baseline of the 
  2nd text line.

In Figure~\ref{fg:descenders}(c), 
  \verb|\clettrine[1][3.5pt]{Q}{}| allocates an extra line
  for the versal, but also shifts up the letterbottom by
  3.5pt.
In so doing, the baseline of the versal-Q can be seen to
  align with the baseline of the 2nd line of text, just
  as occurs with non-descending letters.
Mission accomplished!

%\section{A Few Examples}

\renewcommand\clsep{3pt}
\renewcommand\cloffset{8pt}
\renewcommand\clbgcolor{green!50!black}
\renewcommand\clfgcolor{yellow!30}
\renewcommand\clformat[1]{$\mathcal{#1}$}
\clettrine{W}{hat} more can be shown about the capabilities
  of \Clettrine?
A few examples could help elaborate.
The default versal style shown for the ``W'' has been changed
  according to the following redefinitions:

{\footnotesize
\begin{verbatim}
\renewcommand\clsep{3pt}
\renewcommand\cloffset{8pt}
\renewcommand\clbgcolor{green!50!black}
\renewcommand\clfgcolor{yellow!30}
\renewcommand\clformat[1]{$\mathcal{#1}$}
\end{verbatim}
\par}
Here, in addition to changes in the foreground
  and backgroup colors, the format was changed
  to present the versal in the \cmd{mathcal}
  font.
Because the \cmd{mathcal} font has larger protrusions,
  the \cmd{clsep} was increased from 2pt to 3pt.
The \cmd{cloffset} beyond \cmd{ht}\cmd{strutbox} was
  reduced from 12pt to 8pt.

%%%%

\setcounter{DefaultLines}{3}
\renewcommand\cloffset{0pt}
\renewcommand\clsep{2pt}
\renewcommand\clbgcolor{red!50!black}
\renewcommand\clformat[1]{$\mkern.5mu\mathscr{#1}$}
\vbox{%
\clettrine{R}{educing} the value of \cmd{cloffset} to
  0pt, brings the versal ``R'' of this paragraph in line 
  with the top of the paragraph's strutbox.
To compensate, the number of default versal lines has been
  increased to 3.
Revisions are as follows:}

{\footnotesize
\begin{verbatim}
\setcounter{DefaultLines}{3}
\renewcommand\cloffset{0pt}
\renewcommand\clsep{2pt}
\renewcommand\clbgcolor{red!50!black}
\renewcommand\clformat[1]{$\mkern.5mu\mathscr{#1}$}
\end{verbatim}
\par}
The font is changed to \cmd{mathscr}.
Unusually, the ``R'' has a leftward protrusion.
While \cmd{clsideseptrue} could be set to add 2pt
  separation to the sides of the colorbox, instead,
  we opt in the \cmd{clformat} to just add .5mu to the
  left of the formatted glyphs, to counteract the protrusion.


\clsideseptrue
\renewcommand\clbgcolor{red!80!green}
\renewcommand\clformat[1]{\initfamily#1}
\renewcommand\clsep{3pt}
\clettrine{N}{othing} in the \Clettrine{} approach 
prevents the use of actual initial fonts for the versals,
  such as the Acorn\allowbreak\cite{acorn} 
  decorative-initial ``N'' used  in this paragraph.
Because decorative-initial fonts are generally void of
  protrusions, they make a great candidate for 
  \cmd{clsideseptrue}, so that a uniform border of
  \cmd{clsep} may be added to all 4 sides of the glyph,
  as shown in the following configuration for this
  paragraph:

{\footnotesize
\begin{verbatim}
% PREAMBLE SETUP
\input Acorn.fd
\newcommand*\initfamily{\usefont{U}{Acorn}{xl}{n}}
% RECONFIGURATION
\clsideseptrue
\renewcommand\clbgcolor{red!80!green}
\renewcommand\clformat[1]{\initfamily#1}
\renewcommand\clsep{3pt}
\end{verbatim}
\par}

%\section{The Code}

% LETTRINE SUPPLIED
\setcounter{DefaultLines}{2}
% \clettrine SPECIFIC
\renewcommand\clfgcolor{white!85!orange}
\renewcommand\clbgcolor{black!60!blue}
\renewcommand\cloffset{12pt}
\renewcommand\clsep{2pt}
\clsidesepfalse
\renewcommand\clformat[1]{#1}
% END USER PARAMETERS

\clettrine{C}{ode} listing is the last
  topic to cover in this article.
In addition to lettrine, the other packages
  required of \Clettrine{} include xcolor,
  stackengine, and scalerel.
The stackengine package is used to add
  the \cmd{clsep} buffer above and below the 
  versal glyph and to shift the scaled glyph
  relative to the baseline.
The scalerel package is used to scale the versal
  glyph to the prescribed size, before placing it
  in a colorbox.
The relevant code is given below:

{\footnotesize
\begin{verbatim}
\newlength\clbls
\newlength\cldpst
\newcommand\clettrine[1][0]{%
  \def\claddlines{#1}\clettrineaux}
\newcommand\clettrineaux[3][\clvshift]{%
  \edef\cltmp{\the\fboxsep}%
  \setlength\fboxsep{0pt}%
  \ifclsidesep\def\clsidekern{\kern\clsep}%
  \else\def\clsidekern{}\fi
  \setlength\clbls{\the\baselineskip}%
  \setlength\cldpst{\the\dp\strutbox}%
  \lettrine
    [lines=\the\numexpr\theDefaultLines-
           +\claddlines]%
    {\clboxscale{#1}%
     {\the\dimexpr\cloffset
      +\value{DefaultLines}\clbls
      +\claddlines\clbls
      -\cldpst\relax}%
     {\clformat{\clsidekern#2\clsidekern}}}%
    {#3}%
  \setlength\fboxsep{\cltmp}}
\newcommand\clboxscale[3]{\raisebox{#1}{%
  \colorbox{\clbgcolor}{%
  \addstackgap[\clsep]{\scaleto{%
    \abovebaseline[0pt]{%
      \textcolor{\clfgcolor}{#3}}}%
    {\dimexpr#2-\clsep-#1}}}}}
\end{verbatim}
\par}
Much of the code is spent saving and restoring
  lengths as well as other parameters.
The real meat of the \Clettrine{} transformation
  occurs in the first mandatory argument to
  \cmd{lettrine}, as called in the \cmd{clettrineaux}
  macro.
There, the \cmd{clboxscale} macro is called and
  provided the required measurements needed to
  scale the glyph into an appropriately sized
  colorbox.

In the end, we find that for a relatively small
  overhead of code, the capability of lettrine
  can be extended to provide colorboxed versals that
  are highly configurable and set in a consistent 
  manner.

{\raggedright
\bibliographystyle{ltugbib.bst}
\bibliography{clettrine}}
\end{document} 

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

这是构成图 1 的文件 clettrinedims.pdf 的副本

在此处输入图片描述

这是从这个来源获得的:

\documentclass[border=5pt]{standalone}
\usepackage{lettrine,xcolor,scalerel,stackengine}

% USER PARAMETERS:
% LETTRINE SUPPLIED
\setcounter{DefaultLines}{2}
\setlength{\DefaultFindent}{2pt}
\setlength{\DefaultNindent}{.7ex}
% \clettrine SPECIFIC
\newcommand\clfgcolor{white!85!orange}
\newcommand\clbgcolor{black!60!blue}
\newcommand\cloffset{12pt}
\newcommand\clsep{2pt}
\newcommand\clvshift{0pt}
\newif\ifclsidesep
\clsidesepfalse
\newcommand\clformat[1]{#1}
% END USER PARAMETERS

\newlength\clbls
\newlength\cldpst
\newcommand\clettrine[1][0]{%
  \def\claddlines{#1}\clettrineaux}
\newcommand\clettrineaux[3][\clvshift]{%
  \edef\cltmp{\the\fboxsep}%
  \setlength\fboxsep{0pt}%
  \ifclsidesep\def\clsidekern{\kern\clsep}%
  \else\def\clsidekern{}\fi
  \setlength\clbls{\the\baselineskip}%
  \setlength\cldpst{\the\dp\strutbox}%
  \lettrine
    [lines=\the\numexpr\theDefaultLines
           +\claddlines]%
    {\clboxscale{#1}%
     {\the\dimexpr\cloffset
      +\value{DefaultLines}\clbls
      +\claddlines\clbls
      -\cldpst\relax}%
     {\clformat{\clsidekern#2\clsidekern}}}%
    {#3}%
  \setlength\fboxsep{\cltmp}}
\newcommand\clboxscale[3]{\raisebox{#1}{%
  \colorbox{\clbgcolor}{%
  \addstackgap[\clsep]{\scaleto{%
    \abovebaseline[0pt]{%
      \textcolor{\clfgcolor}{#3}}}%
    {\dimexpr#2-\clsep-#1}}}}}

%%% SHOW DIMENSIONS IN CYAN COLOR
\newcommand\denoter[1][0]{\bgroup\color{cyan}%
  \smash{\trlap[\ht\strutbox]{\scriptsize\upshape
  \stackon[-6.5pt]{\rule{.5pt}{\cloffset}}%
    {\makebox[0pt]{$\uparrow$}}%
    \Shortstack[l]{---\textbackslash cloffset 
  \textcolor{red}{$\mkern-1mu\leftarrow$\textbackslash 
    DefaultFindent}}}%
  \tllap[-\the\numexpr1+#1\relax\baselineskip+\clvshift]{%
    \stackunder[\clsep]{\stackon[0pt]{\rule{65pt}{.5pt}%
      \rlap{\rule{20pt}{.5pt}}}{\scriptsize$\downarrow$%
      \upshape letterbottom}}{\scriptsize\upshape
      \textbackslash clsep$\uparrow$}}%
  \trlap[-\the\numexpr1+#1\relax\baselineskip]{%
    \stackunder[0pt]{\rule{45pt}{.5pt}}{\scriptsize$\uparrow$%
      \upshape\textbackslash clvshift}}%
  \tllap[\dimexpr\ht\strutbox+\cloffset-\clsep]%
    {\stackunder[0pt]{\rule{63pt}{.5pt}}{\scriptsize\upshape
      $\uparrow$lettertop\kern11pt}\kern2pt}%
  \trlap[-.3\baselineskip]{\rule[-10pt]{.5pt}{18pt}\kern
    \DefaultNindent\kern-1pt\rule[-10pt]{.5pt}{18pt}\scriptsize
    \upshape\textcolor{red}%
      {$\mkern-1mu\leftarrow$\textbackslash DefaultNindent}}%
  \tllap[0pt]{\scriptsize\upshape\textbackslash clsidesepfalse%
  $\rightarrow$\kern50pt}%
  }%
  \egroup}
%%%%%%%%%%
\begin{document}

\kern55pt\parbox[b]{2.9in}{\Huge
  \setlength{\DefaultNindent}{.7ex}% PART OF LETTRINE
  \renewcommand\clfgcolor{black!60}
  \renewcommand\clbgcolor{black!90}
  \renewcommand\clsep{3pt}
  \renewcommand\cloffset{22pt}
  \renewcommand\clvshift{6pt}
  \clettrine{S}{\denoter etting} an S in two-line versal form.
    \color{cyan}{\kern30pt\scriptsize\upshape\raisebox{20pt}{%
    \textcolor{red}{DefaultLines (counter) = 2 $\uparrow$}}}}
\end{document} 

答案3

显然,Goudy Initials 字体中的字符是正方形的,但它们的边界框不是正方形的,并且在右侧略微延伸。

事实上,查看文件.tfm我们发现

(CHARACTER C A
   (CHARWD R 0.84)
   (CHARHT R 0.8)
   )

使用宽度和高度一样的盒子来修复它。

更改字体大小以适合您的喜好。

\documentclass{book}
\usepackage{lettrine}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage[tracking=true]{microtype}

\input{GoudyIn.fd}
\newcommand*\initfamily{\usefont{U}{GoudyIn}{xl}{n}}
\newlength{\goudycorr}
\newcommand{\mylettrine}[1]{%
  \begingroup
  \setlength{\fboxsep}{0pt}%
  \fontsize{80}{0}\initfamily
  \colorbox{black}{%
    \makebox[\height][l]{\color{yellow}#1}%
  }%
  \endgroup
}

\begin{document}

\mylettrine{H}\mylettrine{A}\mylettrine{U}

\end{document}

在此处输入图片描述

相关内容