# meaning of ! in \includegraphics in graphicx

David Carlisle d.p.carlisle at gmail.com
Wed Jan 22 09:00:04 CET 2020

On Wed, 22 Jan 2020 at 03:56, Paulo Ney de Souza <pauloney at gmail.com> wrote:
>
> What is the (precise) meaning of ! in a command like
>
>    \includegraphics[width=.8\textwidth,height=!]{figure.eps}

this is trapped and converted to
\resizebox{.8\textwidth}{!}{\includegraphics{figure.eps}}

which, as you say scales the width to the specified width, and the
height by the same scale factor.

Or at least that's what is supposed to happen, there are a lot of
different code paths here depending on what driver option you are
using.

\def\Gin at eresize{\height}
\def\Gin at esetsize{%
\let\@tempa\Gin at exclamation
\if at tempswa
%    \end{macrocode}
%  External. Wrap the |\includegraphics| command in a call to the
%  internal form of |\scalebox| to handle the rotation.
%    \begin{macrocode}
\edef\@tempa{\toks@{\noexpand
\Gscale@@box\noexpand\Gin at eresize
{\Gin at ewidth}{\Gin at eheight}{\the\toks@}}}%
\@tempa
\else
%    \end{macrocode}
% Internal. Handle scaling with the |\includegraphics| command directly
% rather than calling |\scalebox|.

David

>
> I started by guessing that the graphics would be reslzed by the proportion defined on the other axis .. but after some further experimentation I an not really convinced ...
>
> The documentation is completely silent on it. The only mention of ! in in the context f \resizebox some text.
>
> Paulo Ney