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'd like to scale a line according to \figscale. Here it is said that the below syntax should work in general, but in this graphic it does not.

As the picture shows, the numbers are just concatenated to, e.g., -0.53cm instead of -0.5 * 3cm = 1.5cm, although I'd like to multiply them. Writing -0.5*\figscaleworks well.

Why is the solution provided in the link not applicable here?

\def \figscale{3cm}

        \draw (-1.0,2) -- (0,2) node[midway, anchor=south] {$A$};
        \draw (-0.5\figscale,1) -- (0,1) node[midway, anchor=south] {$B$};
        \draw (-1.0\figscale,0) -- (0,0) node[midway, anchor=south] {$C$};

enter image description here

share|improve this question
\def \figscale{3cm} defines a macro that is simply replaced by 3cm where used, it's not a length. Try \newlength\figscale \setlength\figscale{3cm}. – clemens Jun 25 '14 at 10:07
up vote 5 down vote accepted

In the answers to the linked question, \textwidth is used, which is a length parameter for TeX, so the syntax rules allow 4\textwidth (or any decimal number instead of 4).

When TeX is looking for a length, it expands tokens as it goes. Since it expects a length and it has seen -0.5 it expands the next token which might result in something that continues the decimal digits or something that begins with a length register. Your case is the former, because \figscale expands to 3cm and


is a perfect length specification for TeX. The situation is a bit more complicated because we're in the middle of a coordinate for TikZ and this explains why -0.5*\figscale works.

If you want a macro that behaves like a dimension, use


because TeX translates \dimexpr3cm\relax into a (nameless) internal length register. Nonetheless, you're probably best served with

share|improve this answer

Prefixing a "variable" with a number, for example, 4\textwidth only works if the variable is a TeX dimension or skip or box dimension. This is consistent with usual TeX behaviour.

As the latest PGF manual states (section 88.1 "Commands for Parsing Expressions")

The parser will recognize TEX registers and box dimensions, so \mydimen, 0.5\mydimen, \wd\mybox, 0.5\dp\mybox, \mycount\mydimen and so on can be parsed

The math parser expands every expression with \edef before parsing, so the MWE given above, -0.5\figscale becomes -0.53cm which is evaluated as -15.07993 (points) as opposed to the desired -42.67912.

share|improve this answer

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.