5

I find when I produce titles I get line spacing that depends on whether I have a hanging character ie qypg which dip below the usual base line vs wertuioasdfhklzxcvbnm which don't. This is particularly visible when I use lines or super large fonts i.e. on a main title page.

Is there a way to make a consistent spacing that doesn't add the specified spacing at the bottom of a character?

\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}
2
  • 1
    You should not be loading that mix of packages. If you are using Lua/XeTeX, then you should not be using textgreek or textcomp. If you are using (pdf)TeX, then you should not try to load mathspec.
    – cfr
    Commented Jul 12, 2015 at 1:33
  • 1
    @cfr Uh-oh. I think I will open a new question citing your comment here to give a better forum for a detailed answer. I use XeTeX but prefer to avoid inserting symbols and special characters as my text container can't save them, and these packages have been crucial to me and using non-math-mode greek text that doesn't show up in math mode type italics. The only problem I ever had was with \textgamma but I wasn't convinced this was a symptom of a larger problem.
    – EngBIRD
    Commented Jul 12, 2015 at 2:44

1 Answer 1

5

Use \strut:

enter image description here

The code:

\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}

If, on the other side, you'd like to have zero depth, you can place the tiles in a \smashed (with b option) \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}

The result:

enter image description here

Personally, I'd suggest you the first option, with some adjustment to the bottom rule, possibly.

Remarks

  1. A \strut is basically a zero width rule whose total height (height+depth) equals \baselineskip. The definitions in the kernel:

    \newbox\strutbox
    \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi}
    
    \setbox\strutbox\hbox{%
      \vrule\@height.7\baselineskip
      \@depth.3\baselineskip
      \@width\z@}
    

    so if you find that a standard \strut is not enough for your purposes, you could easily define your own variant of \strut.

  2. See cfr's comment regarding some of the packages loaded.

4
  • You beat me to the \strut answer by ten seconds! You want to add a sentence or two about how the OP might go about creating his/her own struts in case the vertical spacing provided by \strut isn't optimal for his/her purposes.
    – Mico
    Commented Jul 12, 2015 at 1:38
  • @Mico Good idea. I'll add some remark about this. Commented Jul 12, 2015 at 1:53
  • Could you perhaps comment why using packages setspace and parskip break the symmetry surrounding the strut in your solution? If necessary I can open up a new question or update this original question. I originally worked around this by using two different point sizes, but that's not the most elegant solution, so I would like to fix this properly, even if that means I shouldn't be using these packages.
    – EngBIRD
    Commented Oct 12, 2015 at 2:55
  • @EngBIRD I think the best approach here would be for you to open a new question. Commented Oct 12, 2015 at 3:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .