Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am defining macros for width and height to be used by several plots in my document, as follows:

\newcommand{\tikzwidth}{.4\columnwidth}
\newcommand{\tikzheight}{.8\tikzwidth}

I think pdflatex just replaces the whole sequence of commands for \tikzheight, resulting in .8.4\columnwidth.

Is there a way to tell pdflatex to process \tikzwidth before "shrinking" it again?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

If you use length or dimen registers, then you can use real numbers as factors:

\newdimen\tikzwidth
\setlength{\tikzwidth}{.4\columnwidth}
\newdimen\tikzheight
\setlength{\tikzheight}{.8\tikzwidth}

Or e-TeX's \dimexpr can be used:

\newcommand*{\tikzheight}{.8\dimexpr\tikzwidth\relax}
share|improve this answer
    
Maybe you mean \dimexpr.8\tikzwidth\relax? –  Leo Liu Aug 17 '12 at 0:32
    
That cannot be used if \tikzwidth is a macro. But a real number can be used as factor for \dimexpr. –  Heiko Oberdiek Aug 17 '12 at 6:51
    
@HeikoOberdiek the combination \newdimen and \setlength{}{} is exactly what I was looking for. Thanks! –  freitass Aug 17 '12 at 19:08

Your Answer

 
discard

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.