TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to compute a bounding box in LaTeX and pass the value on to dvisvgm via DVI specials. The resulting code (which I copy-and-pasted together from all over the internet) looked as follows:

% ...
\special{dvisvgm:bbox a 0 0 \the\mywidth \the\myheight}

This resulted (predictably after the fact) in the following output in the DVI file:

dvisvgm:bbox a 0 0 147.00748pt26.3999pt

After considerable amounts of googling I came up with the following workaround:

\spacetoken={ }
\special{dvisvgm:bbox a 0 0 \the\mywidth\the\spacetoken\the\myheight}

However, that just looks horridly wrong to my eyes. Hence, my questions:

  1. How does \special work?
  2. Is there any better way to do this?
share|improve this question
up vote 7 down vote accepted

\special is like \write: it expands its argument until finding unexpandable tokens and then it writes the result to the DVI file.

Since in \the\mywidth \the\myheight there's no space (the apparent one is ignored during tokenization, as it follows a control sequence), the result is what you found out.

There's a simpler solution, though:


because the expansion of \space is exactly a space token.

As Joseph Wright remarks in a comment, TeX takes no responsibility in what's contained in the argument of \special: as long as it's "fully expandable" and balanced with respect to braces, it can be anything and it's a job for the printer/previewer driver to interpret it.

share|improve this answer
Thank you very much! :) – Viktor Kleen Mar 7 '13 at 0:59
@ViktorKleen Welcome to TeX.sx! – egreg Mar 7 '13 at 1:01
I think it might be worth adding that the whole point of \special is that TeX knows nothing about the 'internal' structure of the argument: it's entirely arbitrary. – Joseph Wright Mar 7 '13 at 8:47

Your Answer


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.