I am debugging a set of macros. The error seems to come from \vspace*{\dimexpr0.000000cm-\topskip plus 1fill}.

How can I log the value of the length?

I have tried \typeout{\dimexpr0.000000cm-\topskip plus 1fill} but it does not work.

  • 1
    \the\dimexpr... – David Carlisle Oct 13 '14 at 12:05
  • you can not use plus after a skip register, a skip register is a complete glue specification, conversely you can use plus after a dimen register as that is just the natural width – David Carlisle Oct 13 '14 at 12:06
  • \vspace*{\glueexpr 0pt plus 1fill - \topskip\relax} – egreg Oct 13 '14 at 12:11

\dimexpr accepts only rigid lengths; if you pass it a rubber length parameter, it is coerced to a rigid length by suppressing the stretch and shrink components; so you can say

\dimexpr 0pt - \topskip\relax

which is a complicated way to say -1\topskip. However, plus is illegal in \dimexpr. You want

\vspace*{\glueexpr 0pt plus 1fill - \topskip\relax}

Here is an interactive session, notice the error at plus:

> pdflatex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.

> 10.0pt.
<*> \showthe\topskip


*\showthe\dimexpr0.000000cm-\topskip plus 1fill\relax
> -10.0pt.
<to be read again> 
<*> \showthe\dimexpr0.000000cm-\topskip p
                                         lus 1fill\relax
? 11
<*> ...dimexpr0.000000cm-\topskip plus 1fill\relax


*\showthe\glueexpr0pt plus 1fill - \topskip\relax
> -10.0pt plus 1.0fill.
<*> ...the\glueexpr0pt plus 1fill - \topskip\relax


No pages of output.
Transcript written on texput.log.

If you want to debug such a \vspace non interactively, use something like

\typeout{***This vertical space will be \the\glueexpr0pt plus 1fill - \topskip\relax}

This will write the glue in the .log file.

  • OK, thanks. This goes far beyond my knowledge. – Colas Oct 13 '14 at 14:05
  • It seems that you corrected my code but did not answer my question... Can I "log" (in a way or in another) the value passed to vspace? Thanks! – Colas Oct 14 '14 at 8:29
  • @Colas You could redefine \vspace to write something to the log file. But so long as the syntax is correct, why bother? – egreg Oct 14 '14 at 8:35
  • I tried \typeout{\glueexpr 0pt plus 1fill - \topskip\relax} but it prints [...]*geometry* detected driver: pdftex \glueexpr 0pt plus 1fill - \topskip \relax [1{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}][...]. I bother because this code does not what it is supposed to do in some situations. – Colas Oct 14 '14 at 8:41
  • 1
    @Colas \typeout{\the\glueexpr...\relax}. I used \showthe that's the “non interactive” counterpart of \the. – egreg Oct 14 '14 at 9:33

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.