From the documentation of the graphicx package:

Most of the keyval keys used in the graphicx package may also be set using the command \setkeys provided by the keyval package.

For instance, suppose you wanted all the files to be included in the current document to be scaled to 75% of the width of the lines of text, then one could issue the following command:


Here ‘Gin’ is the name used for the keyval keys associated with ‘Graphics inclusion’. All following \includegraphics commands (within the same group or environment) will act as if [width=0.75\textwidth] had been specified, in addition to any other key settings actually given in the optional argument.

I am trying to use this to create an argument that accepts keys using the pgfkeys package and passes the ones it does not recognize on to an \includegraphics command. Here's a toy working example:



\mykeyset{graphic options/.code={}}
\mykeyset{set graphic option/.style={graphic options/.append code=#1}}

%Set up a handler for unknown keys
\mykeyset{.unknown/.code = %
        \mykeyset{set graphic option/.expand once = {\expandafter\setkeys\expandafter{\expandafter G\expandafter i\expandafter n\expandafter}\expandafter{\unknownkey=#1}}}%

    \mykeyset{graphic options}%

\myincludegraphics[width = 5cm, height = 8cm]{example-image}

with output

enter image description here

Note that this works for the width and height keys, but that not for the scale key. This is not a problem in itself--I have a method for handling the scale key separately--but I would like to know which other keys require special treatment. Hence, my question:

Which keys to the \includegraphics command cannot be set globally?


1 Answer 1


Brilliant documentation isn't it:-)

In general setting keys is more or less just making macro definitions, so the ones you can't set in advance are the ones that are initialised by \includegraphics before it processes the keys. Looking at the code (strangely more revealing than the documentation) the only relevant initialisation is


and the keys that use that boolean flag are just angle and scale.

The reason for the flag is that most graphics inclusion back ends can "natively" scale the image so if scale is used on its own it is passed on to the back end driver code, but if the image has already been rotated and then the rotated image is scaled, \includegraphics essentially inserts a \scalebox{}{\rotatebox{... around the basic image inclusion. Perhaps it could have been handled differently so your scale example works, but it was a long time ago:-)

For slightly different reasons clip should also be listed, see


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .