这个问题是之前在在自制的 Lettrine 中向图像添加字母
考虑 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}
输出
问题:如何在蓝色“自制”文字周围添加可调节厚度的彩色框架(或许是其他类型的装饰边框)?
谢谢。
答案1
您可以使用\fcolorbox
来\colorbox
添加彩色框架,并使用\fboxrule` 来设置该框架的粗细。
毫无疑问,我设置了 \lettrine
命令以避免使用 \scaleto
或\abovebaseline
:不确定它是否符合所需的格式,但我希望您能了解微调的想法。我还避免使用宏以使示例更简单,并添加一些虚拟文本以检查大写字母是否顺利匹配。
\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}