在自制的 Lettrine 中向图像添加字母

在自制的 Lettrine 中向图像添加字母

考虑一下代码

\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} 

产生

在此处输入图片描述

问题:如何在框中添加一个大而粗的(白色)字母(例如)才能得到相当不错的自制莴苣?(我是在看了这篇文章后有了这个想法的带有图像的 letter但并未说明如何做到这一点。

谢谢。

答案1

在这里,我使用一个简单的\colorbox来包含versal,然后将其缩放到所需的大小。 编辑以处理降部,例如大写字母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} 

在此处输入图片描述

这种方法提供了充足的定制机会。例如,可以轻松调整颜色和通用字体(我还增加了\fboxsep0.5 pt,以包含突出的点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} 

在此处输入图片描述

或者,使用mathrsfs包,将颜色定义为red!50!black,将versal定义为$\mathscr{#1}$。此外,我将versal高度从7ex降低到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} 

在此处输入图片描述


芭芭拉·比顿的特别补充

Q为了解决我像上面那样处理下降线所带来的沮丧,我感到必须纠正这种情况。它仍然需要对 进行一些手动干预Q,既要将字母线从 2 延长到 3,也要将 的垂直范围Q从默认7ex高度增加到更大的高度(此处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} 

在此处输入图片描述

相关内容