Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

If a \rule is placed below a line of text, some space is inserted between the line and the rule. Usually, the amount of space appears to precisely add the difference to the height of the current font size, regardless of whether text is actually inserted (cf. figure, right column, row 1/2) or not (left column). However, if the rule's height surpasses the font height, there is some additional space between the lines (row 3).

Of what amount is this space?

enter image description here

(The purpose of the last row is to quickly demonstrate that the identical results in spacing in the two columns in rows 1-3 are independently achieved.)

\documentclass{article}
\usepackage{calc}
\usepackage{array}
\usepackage{xparse}
\renewcommand{\arraystretch}{3.5}

\newlength{\mydepth}
\newlength{\myheight}
\newlength{\mywidth}
\newlength{\colwidth}

\newsavebox{\mybox}
\sbox{\mybox}{\Huge ipsum}
\settodepth{\mydepth}{\Huge ipsum}
\settowidth{\mywidth}{\Huge ipsum}

\setlength{\colwidth}{\mywidth+2em}


%typeset \mybox underlined with a rule of mandatory height #3,
%and place an optional text #2 either right or left of the rule,
%as indicated by a star (#1).
\DeclareDocumentCommand{\placebox}{s o m}{
    \begin{minipage}[b]{\mywidth+2em}%
    \IfBooleanTF{#1}{%
        \rule[-\mydepth]{2em}{\mydepth}%
        \usebox{\mybox}\\%
        \IfValueTF{#2}{#2}{}%
        \rule{\mywidth+1em}{#3}%
    }{%else invert left/right placement
        \usebox{\mybox}%
        \rule[-\mydepth]{2em}{\mydepth}\\%
        \rule{\mywidth+1em}{#3}%
        \IfValueTF{#2}{#2}{}%
    }%fi
    \end{minipage}%
}%

\begin{document}
\begin{tabular}{b{\colwidth}b{\colwidth}}
\placebox{1mm} & \placebox*[\Huge A]{1mm}\\[2em]
\placebox{1mm} & \placebox*[A]{1mm}\\
\placebox{2mm} & \placebox*[A]{2mm}\\
\placebox{4mm} & \placebox*[A]{4mm}\\
\end{tabular}
\end{document}
share|improve this question
    
I think you mean nointerlineskip. –  Marco Daniel Jun 4 '12 at 18:09
    
@MarcoDaniel Almost -- I was looking for the amount of space. But \lineskip was indeed what I was looking for. Thanks. –  dgs Jun 4 '12 at 20:23
add comment

1 Answer

up vote 8 down vote accepted

To understand the behaviour it is instructive to go to the TeX primitive rules. These are defined using three dimensions height, width and depth:

\vrule height1pt width 1pt depth0pt fjord\par
\hrule height1pt width 100pt depth0pt fjord

LaTeX defines the \rule using these primitives disguised as follows:

\def\rule{\@ifnextchar[\@rule{\@rule[\z@]}} width height raised
\def\@rule[#1]#2#3{%
 \leavevmode
 \hbox{%
 \setlength\@tempdima{#1}%
 \setlength\@tempdimb{#2}%
 \setlength\@tempdimc{#3}%
 \advance\@tempdimc\@tempdima
 \vrule\@width\@tempdimb\@height\@tempdimc\@depth-\@tempdima}}

If we construct an example using first the TeX primitives,

 \vrule height1pt width 1pt depth0pt fjord
 \hrule height1pt width 100pt depth0pt fjord

we get

enter image description here

We get a different behaviour with LaTeX rules as they are typeset in horizontal mode and TeX adds a normal parskip as required..

\rule{1pt}{1pt}fjord fjord fjord fjord\par
\rule{30pt}{1pt}fjord fjord fjord fjord

enter image description here

Full minimal

\documentclass{article}
\parindent0pt
\parskip0pt
\begin{document}
\vrule height0.4pt width 1pt depth0pt fjord\par
\hrule height0.4pt width 30pt depth0pt fjord

\rule{1pt}{1pt}fjord fjord fjord fjord\par
\rule{30pt}{1pt}fjord fjord fjord fjord
\end{document}

The amount of space left is normally lineskip for LaTeX plus \parskip in the examples. vary the parskip value to see how the lines get moved. Note that both start the rule at the baseline of the letters.

share|improve this answer
    
\lineskip is what I was looking for -- thanks. Had you not mentioned \parskip, I might have also missed its rubber length. Strangely though, increasing \lineskip immediatley after begin{minipage} in my code seems to only affect the third row (while it is always correctly changed, as checked with \the). Do you have any idea why this could be the case? –  dgs Jun 4 '12 at 20:18
    
This question is of course directly related to the fact that even though \the\lineskip prints 1pt (without rubber lengths), no such space is inserted in rows 1 and 2 of the figure given in the OP. Since all boxes are printed by the same command, this is somewhat surprising. –  dgs Jun 4 '12 at 20:45
    
\lineskip is inserted between two lines only when b-(h+d) < s, where b is the baselineskip, h is the height of the line below, d is the depth of the line above and s is a dimen parameter called \lineskiplimit. Otherwise the skip inserted is just b-(h+d) in order to keep the two baselines b apart. –  egreg Jun 4 '12 at 20:48
    
The default value of \lineskiplimit is 0pt. See also tex.stackexchange.com/a/51395/4427 –  egreg Jun 4 '12 at 21:00
    
@egreg I see. Assuming s >= 0, that translates to "if the baselines are separated by more than b-s anyway, make them even further apart", which at first sight seems peculiar. What's the reason for that? –  dgs Jun 4 '12 at 21:21
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.