我正在尝试排版首字下沉,但在某些情况下,我需要将首字下沉置于段落中间。
我正在想象这样的事情:
/\ *一些多行文本 /==\ 从这里开始并继续 下面,最终结束 下面。现在,下一个 句子相关 带有标记“B”,但 位于同一段落 |`D) 图。*左边是, |,D) 第二个标记, 跌破了 这句话 开始了。
在这种情况下,它严格来说不是段落中单词首字母的首字下沉,而是我想要一些可靠而简单的方法来排版上述内容。
显然,该lettrine
软件包是我首先查看的地方,但是它总是强制一个段落,并且实际上不允许你将首字下沉与段落中的特定单词或句子联系起来。
在浏览了有关的许多问题之后lettrine
,我得出结论,这里有很多注意事项;例如,lettrine
似乎在分页符方面表现不佳。
我想我真正想要的只是某种方法,使矩形浮动与左边缘齐平,
- 与文本中的特定点相关(a la
todonotes
),总是从同一行开始; - 总是有一定数量的行深度(在我的例子中是2);
- 注意不要跨越页面边界;
- 自动给出正确的宽度(像 m 这样的字母或像 15 这样的数字比像 i 这样的字母或像 2 这样的数字占用更多的空间)。
答案1
这并没有达到应有的强大程度,特别是它无法阻止在首字下沉的行处分页。(它可能应该在构建 parshape 列表的同时构建一个 e-tex 惩罚列表)此外,它不能绝对保证将首字下沉放在它留下的空间中,如果周围的文本难以中断,它可能会超出一行或更多行,因此换行符不会落在宏估计试运行后它们会落下的位置。正如所写的那样,它假设首字下沉始终是两行,但这是一个小限制,它可以轻松地覆盖更多行。
\documentclass{article}
\makeatletter
\def\dc#1{%
\setbox0\hbox{\Huge #1}%
\leavevmode\vadjust{\vskip\wd0 \penalty123}\rlap{\smash{\copy0}}\vrule width2\wd0 height 1pt depth 0pt\relax}
\def\dcpar#1#2{{%
\parindent\z@
\emergencystretch.2\hsize
\@tempcnta\z@
\xdef\@pshape{\space}%
\setbox0\vbox{{\hsize#1\relax
#2%
\endgraf
\@tempdima=#1\relax
\loop
\@tempdima\hsize
\dimen@\z@
\ifnum\lastnodetype=11 \unskip\fi
\ifnum\lastnodetype=13
\count@\lastpenalty\unpenalty
\ifnum\count@=123
\dimen@\lastskip
\unskip
\advance\@tempdima-\dimen@
\xdef\@pshape{\the\dimen@\space \the\@tempdima\space\expandafter\eat@two\@pshape}%
\fi
\fi
\ifnum\lastnodetype=\@ne
\setbox\z@\lastbox
\advance\@tempcnta\@ne
\xdef\@pshape{\the\dimen@\space \the\@tempdima\space\@pshape}%
\fi
\ifnum\lastnodetype=\m@ne
\xdef\@pshape{\the\@tempcnta\space\@pshape}%
\else
\repeat
}}%
\parshape=\@pshape
% for babrara \def\dc##1{\leavevmode\vadjust{\rlap{\smash{\raise-\baselineskip\hbox{\Huge##1}}}}}%
\def\dc##1{\leavevmode\strut\vadjust{\rlap{\smash{\raise\dimexpr\dp\strutbox-\baselineskip\relax\hbox{\Huge##1}}}}}%
#2\par
}}
\def\eat@two#1 #2 {}
\makeatother
\begin{document}
\dcpar{.3\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually ending
up below. Now, the next
sentence is associated
with the marker 'B' but
lies in the same paragraph.
\dc{D}Left it is,
the second marker,
dropped below the line on
which this sentence had
began.}
\dcpar{.4\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually ending
up below. Now, the next
sentence is associated
with the marker 'B' but
lies in the same paragraph.
\dc{D}Left it is,
the second marker,
dropped below the line on
which this sentence had
began.}
\dcpar{.5\textwidth}{
\dc{A}Some multiline text
starts here and goes
below, eventually ending
up below. Now, the next
sentence is associated
with the marker 'B' but
lies in the same paragraph.
\dc{D}Left it is,
the second marker,
dropped below the line on
which this sentence had
began.}
\end{document}