5

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.

Colas
  • 6,772
  • 4
  • 46
  • 96

1 Answers1

7

\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.
**\relax
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.

*\showthe\topskip
> 10.0pt.
<*> \showthe\topskip

? 

*\showthe\dimexpr0.000000cm-\topskip plus 1fill\relax
> -10.0pt.
<to be read again> 
                   p
<*> \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

? 

*\stop
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.

egreg
  • 1,121,712
  • 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 08: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 08: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 08:41
  • 1
    @Colas \typeout{\the\glueexpr...\relax}. I used \showthe that's the “non interactive” counterpart of \the. – egreg Oct 14 '14 at 09:33
  • OK, thanks. It prints -0.00002pt plus 1.0fill. My problem is that it fills to much space I think. – Colas Oct 14 '14 at 09:46
  • How does one launch the interactive mode? – Colas Oct 14 '14 at 09:47