我发现当我制作标题时,行距取决于是否有悬挂字符(即qypg
低于通常的基线或wertuioasdfhklzxcvbnm
不低于基线)。当我使用线条或超大字体(例如在主标题页上)时,这种情况尤其明显。
有没有办法制作一致的间距,而不会在字符底部添加指定的间距?
\documentclass{report}
\usepackage{siunitx}
\usepackage{microtype,textcomp,textgreek,mathspec}
\usepackage{xpatch} % can exclude etoolbox. xpatch loads it anyway, since egreg (xpatch author) extends etoolbox
\makeatletter
%http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill\quad
\@chapapp{} \thechapter
\quad \thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large \bfseries #1\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large \bfseries #1\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\makeatother
\begin{document}
\chapter{A title with a hanging character}
Please note and compare to the next chapter, the relative line spacing between the Chapter title and the lower hline placement.
\chapter{All above line characters}
This line doesn't have enough space after it, I believe this is because of the characters that dip below the regular virtual alignment line
\end{document}
答案1
使用\strut
:
代码:
\documentclass{report}
\usepackage{siunitx}
\usepackage{microtype,textcomp,textgreek,mathspec}
\usepackage{xpatch} % can exclude etoolbox. xpatch loads it anyway, since egreg (xpatch author) extends etoolbox
\makeatletter
%http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill\quad
\@chapapp{} \thechapter
\quad \thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large \bfseries \strut#1\strut\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large \bfseries \strut#1\strut\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\makeatother
\begin{document}
\chapter{A title with a hanging character}
Please note and compare to the next chapter, the relative line spacing between the Chapter title and the lower hline placement.
\chapter{All above line characters}
This line doesn't have enough space after it, I believe this is because of the characters that dip below the regular virtual alignment line
\end{document}
另一方面,如果您希望深度为零,则可以将瓷砖放置在\smash
ed 中(带b
选项)\parbox
:
\documentclass{report}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{microtype,textcomp,textgreek,mathspec}
\usepackage{xpatch} % can exclude etoolbox. xpatch loads it anyway, since egreg (xpatch author) extends etoolbox
\makeatletter
%http://zoonek.free.fr/LaTeX/LaTeX_samples_chapter/0.html
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill\quad
\@chapapp{} \thechapter
\quad \thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large\bfseries\smash[b]{\parbox{\textwidth}{\centering#1}}\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\def\@makeschapterhead#1{%
{\parindent \z@ \centering \reset@font
\thickhrulefill
\par\nobreak
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vspace*{6\p@}%
\Large\bfseries\smash[b]{\parbox{\textwidth}{\centering#1}}\par\nobreak
\par
\vspace*{6\p@}%
\interlinepenalty\@M
\hrule
\vskip 20\p@
}}
\makeatother
\begin{document}
\chapter{A title with a hanging character}
Please note and compare to the next chapter, the relative line spacing between the Chapter title and the lower hline placement.
\chapter{All above line characters}
This line doesn't have enough space after it, I believe this is because of the characters that dip below the regular virtual alignment line
\end{document}
结果:
就我个人而言,我建议您选择第一个选项,并可能对底部规则进行一些调整。
评论
A
\strut
基本上是一个零宽度规则,其总高度(高度+深度)等于\baselineskip
。内核中的定义:\newbox\strutbox \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} \setbox\strutbox\hbox{% \vrule\@height.7\baselineskip \@depth.3\baselineskip \@width\z@}
因此,如果您发现一个标准
\strut
不足以满足您的目的,您可以轻松地定义自己的变体\strut
。看
cfr's comment
关于一些已加载的包。