20

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}
  • 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
26

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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