4

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?

2

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}
| improve this answer | |
2

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.

| 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.