18

Consider the following example:

\newlength{\textsize}
\makeatletter
\setlength{\textsize}{\f@size pt}
\makeatother

\setlength{\parskip}{12pt plus 1pt} % WORKS
\setlength{\parskip}{\textsize plus 1pt} % FAIL

How to make the failing line work?

Which means: how to set a length to another length plus and/or minus other values?

2 Answers 2

14
\newlength{\textsize}
\makeatletter
\setlength{\textsize}{\f@size pt}
\makeatother

\setlength{\parskip}{12pt plus 1pt} % WORKS
\setlength{\parskip}{1\textsize plus 1pt} % FAIL

\showthe\parskip

LaTeX lengths are skip registers so \textsize is a complete glue specification and can not take a further plus component. 1\textwidth coerces this to a dimen, discarding any plus and minus components, so you can add a new plus component.

15

Two alternatives to David's answer:

  • e-TeX provides \glueexpr, which allows to add glue specifications:

    \newlength{\textsize}
    \makeatletter
    \setlength{\textsize}{\f@size pt}
    \makeatother
    
    \setlength{\parskip}{\glueexpr\textsize + 0pt plus 1pt\relax}
    
  • If \textsize is not intended to have stretch or shrink components, then a dimen instead of a skip register can be used. LaTeX's \newlength assigns a skip register, \newdimen a dimen register:

    \newdimen{\textsize}
    \makeatletter
    \setlength{\textsize}{\f@size pt}
    \makeatother
    
    \setlength{\parskip}{\textsize plus 1pt}
    

You must log in to answer this question.

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