
這個問題是不久前提出的問題的延伸在 DIY 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
or \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}