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.

Is it possible to use \baselineskip with some extra glue inside of \vspace?

\documentclass{scrartcl}

\begin{document}
Text

\vspace{\baselineskip}
Works

\vspace{12pt plus 10pt minus 5pt}
Works

\vspace{\baselineskip plus 10pt minus 5pt}
Fails \dots
\end{document}
share|improve this question
    
On last line try \vspace{\the\baselineskip plus 10pt minus 5pt} –  Yiannis Lazarides Jan 2 '12 at 19:00
    
@YiannisLazarides This won't work if \baselineskip has a non zero stretch or shrink component. Usually \baselineskip hasn't, but other glue parameter could. –  egreg Jan 2 '12 at 20:42
    
@egreg Thanks. I guess is better to be conservative and use dimexpr, although most classes fix it in order to set \textheight to be a multiple of \baseline. –  Yiannis Lazarides Jan 2 '12 at 20:48
    
@YiannisLazarides It's \glueexpr, anyway. –  egreg Jan 2 '12 at 20:50

2 Answers 2

up vote 18 down vote accepted

Since \vspace wants a "glue" as its argument and \baselineskip is a glue parameter, \vspace{\baselineskip plus 10pt minus 5pt} is incorrect; the easiest way is to say

\vspace{1\baselineskip plus 10pt minus 5pt}

as 1\baselineskip will make it into a simple dimension, discarding its possible plus and minus components.

Usually \baselineskip has zero stretching and shrinking components. If one wants to be on the safe side and add 10pt to the stretch and 5pt to the shrink components whatever they are, the "correct" way is

\vspace{\glueexpr\baselineskip + 0pt plus 10pt minus 5pt\relax}

Note: \vspace{\dimexpr\baselineskip plus 10pt minus 5pt\relax} works because when TeX scans for the \dimexpr it arrives to the p that cannot be part of a dimension expression and stops the scanning, having already converted \baselineskip to a dimension discarding the stretch and shrink components. So the final \relax is not the delimiter of \dimexpr and will go into the input stream (where it probably does no harm).

share|improve this answer
    
Thanks for the \glueexpr.;) –  Yiannis Lazarides Jan 2 '12 at 20:53
    
Thank’s for your detailed answer! –  Tobi Jan 2 '12 at 20:55

use dimexpr for adding the skips

\vspace{\dimexpr\baselineskip plus 10pt minus 5pt\relax}
share|improve this answer
    
Thank you! Works fine :-) –  Tobi Jan 2 '12 at 19:15
2  
The \relax terminating \dimexpr should go after \baselineskip, but then 1\baselineskip is easier. –  egreg Jan 2 '12 at 20:44

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.