我想要制作一个命令(主要用于 beamer 类),它\dbend
在左侧排版一个带有危险弯道标志的文本注释,两者相对于彼此垂直居中。
m
我使用了带有数组包提供的列的表格环境:
\documentclass{standalone}
\usepackage{manfnt}
\usepackage{array}
\newcommand{\dnote}[1]{\begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}\huge\dbend & {#1}\end{tabular}}
\begin{document}
\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks? Would a TeXduck chuck quacks if quacks could chuck TeXducks?}
\end{document}
但结果并非我所期望的,因为两者并不居中(并且对于独立类,弯曲甚至被剪裁):
我怎样才能解决这个问题?
答案1
令人惊讶的是,目前还没有人注意到该软件包确实提供了一个将“地面”提升到基线水平的命令manfnt
版本,即。因此,使用此命令代替 就足够了:\dbend
\textdbend
\dbend
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % not necessary here, but I prefer to use it
\usepackage{manfnt}
\usepackage{array}
\newcommand{\dnote}[1]{%
\noindent % I guess this is intended...
\begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}%
\huge\textdbend %
\end{tabular}%
\par % ... and this too.
}
\begin{document}
\dnote{One-line note.}
\bigskip
\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks?
Would a TeXduck chuck quacks if quacks could chuck TeXducks?}
\bigskip
\dnote{A longer note. How much quacks would a TeXduck chuck if a TeXduck could
chuck quacks? Would a TeXduck chuck quacks if quacks could chuck TeXducks? How
much quacks would a TeXduck chuck if a TeXduck could chuck quacks? Would a
TeXduck chuck quacks if quacks could chuck TeXducks?}
\bigskip
\dnote{And an even longer one; more precisely, one line longer than the previous
one. How much quacks would a TeXduck chuck if a TeXduck could chuck quacks?
Would a TeXduck chuck quacks if quacks could chuck TeXducks? How much quacks
would a TeXduck chuck if a TeXduck could chuck quacks? Would a TeXduck chuck
quacks if quacks could chuck TeXducks?}
\end{document}
你可以检查输出是否令人满意:
请允许我在这里稍微说一下题外话。众所周知,TeX 源代码TeXbook仅供教育目的公开。现在,值得一提的是TeXbook显示了第 vi 页显示中“垂直居中”危险弯曲符号的明显示例(第 v 页显示的符号也是垂直居中的,但这可能看起来不太明显);如果你看一下 TeX 源代码以了解这是如何实现的,你可以猜出表示信号卡住的“地面”的部分在基线以下 11 个点,这个事实可以通过一个小实验轻松证实。这适用于 10 点的字体大小,即 的设计manfnt
大小。在这个尺寸下,字符的高度\dbend
为 7.5pt(你可以直接在 TeX 中测量,也可以在将其转换为“属性列表”文件后,在 TFM 文件中查找,方法是给出命令
tftopl manfnt.tfm manfnt.pl
在 shell 提示符下)。因此,我们看到字符应该被提升的确切量是其高度的 11/7.5 = 22/15:这正是包所做manfnt
的。请注意 22/15 = 1.466666666…,非常接近 @egreg 猜测的 1.475,但与 Massimo 提出的猜测不太接近1.2\height
。
答案2
字形\dbend
没有深度,但它仍然延伸到基线以下很远的地方。请看下面示例中的第一行,其中用 进行了更正\raisebox
。
\documentclass{article}
\usepackage{manfnt}
\usepackage{array}
\newcommand{\dnote}[1]{%
\begin{tabular}{@{}m{0.13\textwidth}@{}m{0.87\textwidth}@{}}
\raisebox{1.475\height}{\huge\dbend} & #1
\end{tabular}%
}
\begin{document}
\fboxsep=0pt \fboxrule=0.1pt
X\fbox{\dbend}X\fbox{\raisebox{1.475\height}{\dbend}}X%
\bigskip\bigskip
\noindent
\dnote{How much quacks would a \TeX duck chuck if a \TeX duck could
chuck quacks? Would a \TeX duck chuck quacks if quacks could chuck \TeX ducks?}
\end{document}
m
没有垂直居中?这是列类型实现方式的固有限制。
答案3
将列类型改为p
而不是m
文本似乎可以解决这个问题。一些聪明的人可能会回答为什么。
\documentclass{standalone}
\usepackage{manfnt}
\usepackage{array}
\newcommand{\dnote}[1]{\begin{tabular}{@{}m{0.13\textwidth}@{}p{0.87\textwidth}@{}}\huge\dbend & {#1}\end{tabular}}
\begin{document}
\dnote{How much quacks would a TeXduck chuck if a TeXduck could chuck quacks? Would a TeXduck chuck quacks if quacks could chuck TeXducks?}
\end{document}