[Tex/LaTex] scale in graphicx don´t work when width set with setkeys

graphicstufte

I am editing a document using graphicx with width options set by setkey, as in

\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}

The problem is that when I want to specifically resize a picture with scale option, it does not work. Therefore

\includegraphics[scale=0.5]{anypic.png}

Has no effect at all. It seems to be overriden by the width.

There is any way to make graphicx forget the width for one specific figure?

Obs: resetting the width of the figure works, but I would like to avoid measuring figures.

Best Answer

You can use an exclamation to reset the width and height values:

\documentclass{article}
\usepackage{graphicx}

\setkeys{Gin}{width=\linewidth,totalheight=\textheight,keepaspectratio}

\begin{document}
\includegraphics[scale=0.5]{example-image-A}

\includegraphics[width=!,totalheight=!,scale=0.5]{example-image-A}
\end{document}

enter image description here

Related Question