I'd like to have a number variable in Latex to be used for the scale parameter in an includegraphics command (for example, to let all finite state machine pictures be scaled to the same size). This works if I just use a makro like this:


But sometime a figure might be a little to large (or so), and I might want to do something like this:


But this only works for lengths, and lengths have units (pt, mm etc.) that do not work as a scale.

This is a minimal non-working example of what I'd like to do:



Is there a way to do that or something similar?

  • I think your plan is scratched. You want to give a universal rule (scale), but want to be able to change single instances. Do all scales by hand. – Johannes_B Jul 16 '16 at 8:49
  • That might be true - but I'm at the end of a quite big project... This might not be the nicest way to do this in general, but it's certainly the easiest way without changing too much of the given stuff. (I don't want to set single values by hand as I still want to be able to scale them altogether. Also, the additional correction is supposed to be minimal, like 0.97 or so.) – lukas.coenig Jul 16 '16 at 8:56
  • Also, there certainly are other applications for my problem. – lukas.coenig Jul 16 '16 at 9:19
  • 4
    if you want them all the same size better to use height= than scale=, but you can do the arithmetic you suggest by [scale=\mylenth,scale=0.9] – David Carlisle Jul 16 '16 at 9:40
  • That's actually working!! Thank you so much - didn't know that. If you post an answer, I'll definitely accept it. – lukas.coenig Jul 16 '16 at 9:56

You can't unfortunatly calculate the product of two non-integer factors and get a factor using (La)TeX, at least not directly. One must be a dimension and the result will be a dimension. However, LaTeX has an internal macro \rem@pt to remove the trailing pt from dimensional values to turn them to factors. The multiplication can be done using eTeX \dimexpr:


    \csname rem@pt\expandafter\endcsname\the\dimexpr #1\dimexpr\myfactor pt\relax\relax



If \myfactor is a LaTeX length register you can change \dimexpr\myfactor pt\relax to simply \myfactor.

| improve this answer | |

If you want them all the same size better to use height= than scale=, but you can do the arithmetic you suggest by

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.