在章节首字母后面放置一个方框来风格化

在章节首字母后面放置一个方框来风格化

我想复制此处看到的首字母样式,但不知道从哪里开始。本质上,我需要调整章节/部分中首字母的大小,并在其后面放置一个高度较小、宽度相等的框。这容易实现吗?

我对 LaTex 还很陌生,非常感谢大家花时间回复我。谢谢!

刻字示例

答案1

下面是一个如何使用的示例lettrine

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{libertine}
\usepackage{lettrine}

\usepackage[svgnames]{xcolor}
\setcounter{DefaultLines}{3}

\begin{document}

\lettrine[findent=3pt, nindent=0pt, ante=\rlap{\color{LightSalmon!50}\rule[-0.55\LettrineHeight]{\LettrineWidth}{0.65\LettrineHeight}} ]{I}{n} former days -- that is to say, once upon a time, there lived in the Land of Gramblamble, Seven Families. They lived by the side of the great Lake Pipple-popple (one of the Seven Families, indeed, lived in the Lake), and on the outskirts of the City of Tosh, which, excepting when it was quite dark, they could see plainly. The names of all these places you have probably heard of, and you have only not to look in your Geography books to find out all about them.

\end{document}

在此处输入图片描述

答案2

只是为了好玩,我尝试使用 tikz 和 hangindent(只有一个段落)。

\documentclass{article}
\usepackage{tikz}

\newcommand{\bigletter}[2]% #1=number lines, #2=letter
{\sbox1{\resizebox{!}{\dimexpr #1\baselineskip-0.4\baselineskip}{#2}}%
  \sbox0{%
    \begin{tikzpicture}
      \fill[red,opacity=.5] ({-0.5\wd1},{-0.3\ht1}) rectangle ({0.5\wd1},{.3\ht1});
      \node[inner sep=0pt] {\usebox1};
    \end{tikzpicture}}%
  \hangindent=\dimexpr \wd0+2pt\relax
  \hangafter=-#1
  \noindent\llap{%
    \raisebox{\dimexpr \baselineskip-#1\baselineskip}[0pt][0pt]{\usebox0}%
    \hspace{2pt}}%
\strut\ignorespaces}

\begin{document}
\bigletter{3}{L}orem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida
mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus
et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra
metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus
eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium
quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Cura-
bitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue
eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim
rutrum.

\end{document}

演示

相关内容