确保行距与上升部、下降部和重音符一致

确保行距与上升部、下降部和重音符一致

这基本上是一个后续问题自定义标题中的一致行距

在我看来,这\strut只能在采用一行或两行(在输出中)参数的宏中起作用,所以我对更普遍的问题感兴趣。是什么机制导致线条根据其下行和上行调整其​​基线位置?是否可以操纵此机制以至少使文本和标题与网格对齐?我理解数学,表格和数字是一个新的复杂程度,所以现在让我们专注于文本。字体和字体大小有影响吗?

标题可能是一个不好的例子,因为它们最多只有一两行,但同样的一般问题也适用于其他环境,如引号。

在以下根据原始问题改编的例子中,重音符号会占用很多行空间,而另一方面,如果只使用小写(或小型大写)字母,我们就会失去一些空间。

\makeatletter
\documentclass{report}
\usepackage{lipsum}

\newbox\chapstrutbox
\def\chapstrut{\relax\ifmmode\copy\chapstrutbox\else\unhcopy\chapstrutbox\fi}
\setbox\chapstrutbox\hbox{%
    \vrule\@height3\baselineskip\@depth2\baselineskip\@width\z@}%
\def\offinterlineskip{\baselineskip-1000\p@%
    \lineskip\z@ \lineskiplimit\maxdimen}

\let\myskip\baselineskip
\def\@makechapterhead#1{{%
    \noindent\chapstrut\fontsize{\@xxpt pt}{2\myskip}\selectfont%
    #1\chapstrut\par\nobreak}}
\def\@makeschapterhead#1{{%
    \noindent\chapstrut\fontsize{\@xxpt pt}{2\myskip}\selectfont%
    #1\chapstrut\par\nobreak}}

\makeatother
\begin{document}
\chapter{\'{A}ccent\d{y}ated han\d{g}in\d{g} c\'{h}aracters and a \'{l}ot of
text to ma\d{g}e it \'{f}\'{l}ow over \d{j}nto several \'{l}\d{y}nes\d{,}
\d{y}ou ne\d{y}er \'{k}now when \d{y}ou mi\d{g}\'{h}\'{t} need a \'{t}itle
tha\'{t} is stu\d{p}idl\d{y} \'{l}on\d{g} (exce\d{p}t \d{y}ou do \'{b}ecause
\'{t}ha\d{y}t\'{'}s w\'{h}at s\d{y}bhea\'{d}in\d{g}s are \'{f}or)}
\lipsum[1-2]
\chapter{A title with a hanging character and a lot of text to make it flow
over into several lines, you never know when you might need a title that is
stupidly long (except you do because that's what subheadings are for)}
\lipsum[1-2]
\chapter{avv avove ovne coaraccers anz a woo os rexr co mave xc swow over enco
severar renes -- vou never cnow wwen vou meewc neez a cecre cwac es scuvezre
ronw -- excevc vou zo vecause cwac-s wwac suvweazenws are vor --}
\lipsum[1-8]
\end{document}

答案1

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

主要问题是文本大于指定的基线跳跃,因此\lineskip使用的间距永远不会提供均匀的间距,请参阅第 1 页上的日志。

如果想要均匀间距,正常的做法是增加基线跳跃,如第 2 页所示。

如果您希望段落内的间距均匀,但小写文本的间距更近(有点不寻常但......)那么您可以先在水平框中设置文本,然后测量其高度加上深度,然后设置\baselineskip为比这更大,如在第 3 页上一样。

\documentclass{report}

\showoutput\showboxdepth3
\begin{document}
\makeatletter

\def\testa{%
\'{A}ccent\d{y}ated han\d{g}in\d{g} c\'{h}aracters and a \'{l}ot of
text to ma\d{g}e it \'{f}\'{l}ow over \d{j}nto several \'{l}\d{y}nes\d{,}
\d{y}ou ne\d{y}er \'{k}now when \d{y}ou mi\d{g}\'{h}\'{t} need a \'{t}itle
tha\'{t} is stu\d{p}idl\d{y} \'{l}on\d{g} (exce\d{p}t \d{y}ou do \'{b}ecause
\'{t}ha\d{y}t\'{'}s w\'{h}at s\d{y}bhea\'{d}in\d{g}s are \'{f}or)}

\def\testb{%
A title with a hanging character and a lot of text to make it flow
over into several lines, you never know when you might need a title that is
stupidly long (except you do because that's what subheadings are for)}

\def\testc{%
avv avove ovne coaraccers anz a woo os rexr co mave xc swow over enco
severar renes -- vou never cnow wwen vou meewc neez a cecre cwac es scuvezre
ronw -- excevc vou zo vecause cwac-s wwac suvweazenws are vor --}

{\fontsize{\@xxpt pt}{2\baselineskip}\selectfont

\testa

\testb

\testc

}

\clearpage

{\fontsize{\@xxpt pt}{30pt}\selectfont

\testa

\testb

\testc

}

\clearpage

{\fontsize{\@xxpt pt}{30pt}\selectfont
\def\zz#1{{\sbox0{#1}\baselineskip 1.2\dimexpr\ht0+\dp0\relax \unhbox0 \par}}

\zz{\testa}

\zz{\testb}

\zz{\testc}

}

\end{document}

相关内容