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

So I'm trying to set a variable using the value of another variable. Basically something like below:


But no matter what I do I can't seem to get the syntax right. I'm assuming it has something to do with expanding stuff, but can't figure out what is and isn't needing to be expanded. I can't find anything on this that makes sense. All the ones I've seen use the if/then to actually output things rather than set them as variables. Any thoughts?

share|improve this question
up vote 4 down vote accepted

\pgfmathifthenelse is the standalone version that writes the result to \pgfmathresult, setting macro needs the inline math function evaluated such as


or shorter

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.