# Numerical variables to use as a scale parameter in figures

I have a text with several figures, and I want to change their size in order to see the effect (position, for example) in the text. To define its size, I am using the scale parameter in the \includegraphics. As I have a lot of figures I would no like to change each one in each test.

So I was wondering if there is a way to set a variable, for example figureSize = 0.8, and use it as a parameter to scale in the \includegraphics. This way, I could only change the value in the variable and all the figures would have its size changed.

Or, is there a way better than that to do so?

You can define your variable via:

\def\myFigureScale{0.2}


and use it via:

\includegraphics[scale=\myFigureScale]{example-image-a}


Here is an example:

\documentclass{article}
\usepackage{graphicx}

\def\myFigureScale{0.2}
\begin{document}
\includegraphics[scale=\myFigureScale]{example-image-a}\par
{
\def\mymyFigureScale{0.5}
\includegraphics[scale=\myFigureScale]{example-image-b}\par
\includegraphics[scale=\myFigureScale]{example-image-c}\par
}
\includegraphics[scale=\myFigureScale]{example-image-b}
\end{document}


Some of the key-values used in \includegraphics can be set using globally

\setkeys{Gin}{<key>=<value>}


However, for scale (because it's special...) you can do the following:

\usepackage{graphicx,letltxmacro}
\LetLtxMacro\oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[2][]{\oldincludegraphics[#1,scale=.2]{#2}}


The above code redifines \includegraphics to always the option scale=.2 to all images, so you don't have to worry about including it. Of course, you can add other defaults too.

Note that since scale is handled differently to some other key-values, multiple uses of scales (as in \includegraphics[.., scale=X, .., scale=Y, ..]{..}) is actually compounded. That is, scale=.2, scale=.5 is similar to scale=.1.