with the 'graphicx' package the width and height of an image can be
given using the 'width' and 'height' (as well as \totalheight) option
of the \includegraphics.
However, there seems to be no (easy) way to allow both height and
width to be set relative to its original value, e.g. scale the width
by 2 and the height by 3, etc.
It would be nice to be allowed to use the usual box related dimensions
\width, \height and \totalheight as values
for the options with the same name. Together with the 'calc' package
or e-TeX's \dimexpr some arithmetic can then be added based on this
values.
Example: (with 'calc' package loaded)
\includegraphics[width=2\width,height=3\height - 10pt]{example}
This can already be achieved by using the internal dimensions
\Gin@nat@width and \Gin@nat@height, which hold the natural image width
and height. So all what is necessary to make it user friendly is to
define this macros to \width and \height at the correct place and
scope.
I would suggest the begin of the \Gin@esetsize macro, because the
final size is calculated there for which
the 'width' and 'height' arguments are used for the first time.
The following short patch code adds the three definitions to this
macro. Note that the image depth is assumed to be zero and therefore
the natural \totalheight is equal to \height.
The code comes as a minimal example. For normal documents the patch
code itself should be placed into a .sty file and loaded using
\usepackage.
\documentclass{article}
\usepackage{graphicx}
\makeatletter
%%% Patch graphicx to allow \width, \height and \totalheight as part %%
%%%%
%%% of the `height` and `width` arguments. %%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
\begingroup
% This new code is added at the beginning of \Gin@esetsize:
\toks@{%
\def\width{\Gin@nat@width}%
\def\height{\Gin@nat@height}%
\let\totalheight\height
}
\toks@\expandafter\expandafter
\expandafter{\expandafter\the\expandafter\toks@\Gin@esetsize}%
\xdef\Gin@esetsize{\the\toks@}
\endgroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%% Example usage:
\usepackage{calc}
\begin{document}
\includegraphics[width=.2\width,height=.1\height]{example}
\show\height
\show\width
\includegraphics[width=.2\width-10pt,height=.1\height]{example}
\includegraphics[width=.2\width,height=.1\height,keepaspectratio]
{example}
\end{document}
% EOF
Sorry, this two lines where only to see if the definitions are
correctly scoped and should be removed.
Also, a \def\depth{\z@} can be added if required.
Martin