# Placing text between horizontal lines generated by \rule: equispacing

How to fix the vertical spacing between the text and the lines? In the following MWE the vertical space between the text and the line below it is much greater than the vertical space between the text and the line over it. I want those two vertical spaces to be equal and I want to be able to give a value to this vertical space.

\documentclass[12pt]{report}

\begin{document}

\rule{6cm}{0.4pt}\par
\textbf{\large TITLE}\par
\rule{8cm}{0.4pt}

\end{document}

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – user11232 Apr 19 '15 at 1:04

The rule is drawn at the baseline of text. Hence the lower line is at the baseline of the next line of text.

So you have to lift the lower line by suitable amount. This may be done by \vspace or adding the depth to the \rule.

\documentclass[12pt]{report}

\begin{document}

\rule{6cm}{0.4pt}Some\par
\textbf{\large TITLE}\par%\vspace{-0.66\baselineskip}
\rule[0.66\baselineskip]{8cm}{0.4pt}Some

\end{document}


• So this gives equal spacing, right? And if I wanted a bigger spacing I could add some \vspace{} before and after the line of the text, right? – Guest Apr 19 '15 at 1:07
• @Guest you can. – user11232 Apr 19 '15 at 1:08

I have come to grips with this concept and have a solution that illustrates this pretty well:

# A Dynamic Approach (relative fontsize)

Realizing that after each new line the drawing of a line starts at the base of where a letter would be (the baseline of a glyph), you raise the line below the text. How much? user11232 uses 60% of the baseline skip. Another way would be to use the height of some upper case letter directly e.g. \fontcharht\font"004D will result in the height of an M in points. The \baselineskip is set by the class thru \@setfontsize, see Is \baselineskip automatically defined?.

If you're not happy with the optical results due to letters width depth for example, you could even make it 70% of the height of an upper case letter (just add .7 in front of \fontcharht).

# Initial Approach

Draw line above and below text and see what happens. The result is not optically pleasing.

# Full Code

\documentclass{article}
\usepackage{fontspec}% xelatex

% Note that you can remove all the \noindent occurrences
% with \setlength\parindent{0pt} which sets empty indent box
% to 0pt globally

\newcommand\linedatWRONG[1]{% comment out this line-ending
\leavevmode\par\noindent\rule{4cm}{0.4pt}gello\par\noindent%
#1\rule{1cm}{0.4pt}\par\noindent%
\rule{4cm}{0.4pt}gello\par%
}

\newcommand\linedatRIGHT[1]{% comment out this line-ending
\leavevmode\par\noindent\rule{4cm}{0.4pt}gello\par\noindent%
#1\rule{1cm}{0.4pt}\par\noindent%
\rule[\fontcharht\fontM]{4cm}{0.4pt}gello\par% raise line up by the height of M in the current font
}

\newdimen\Mheight % for demo only
\Mheight=\fontcharht\fontM% for demo only

\begin{document}
\noindent The \texttt{\textbackslash linedatWRONG} version does indeed have the correct
alignment according to TeX's rules of baseline skips. I used the word
{\char"201C}gello{\char"201D} to demonstrate that the lines are at the baselines.
\linedatWRONG{Hello gello}% purposely used glyph with depth "g"
\vspace{2\baselineskip}
\noindent In the \texttt{\textbackslash linedatRIGHT}, we raise the bottom line up by the height of an upper case {\char"201C}M{\char"201D}
in the current font, which happens to be \the\Mheight. Programming this dynamically ensures
that the value of M will be ajusted to the current scope's font.
\linedatRIGHT{Hello gello}% purposely used glyph with depth "g"
\end{document}


# Notes

• Caveat This works when the baseline skip is marginally larger than the depth+height of a character. If you have an especially large baseline skip, then raising the bottom line by the depth+height of a character might seem insignificant compared to the baseline skip.
• article class specifies that font size 10pt (\@xpt) has an associated 12pt (\@xiipt) baseline skip.
• another option is to use depth of the line