Consider the following macro:
\newcommand{\sxfigure}[4]{
\includegraphics[width=#1*#3 cm, height=#2*#3 cm]{#4}
}
#1
and #2
is some value to determine the width and height of the figure, #3
is to control the zoom ratio. However, the above code doesn't work. Could someone provide a solution? I have tried the following, still not work. Could some point out the mistake?
\usepackage{pgf}
\newcommand{\sxmultiply}[2]{\pgfmathparse{#1*#2}\pgfmathresult}
\newcommand{\sxfigure}[5]{
\begin{figure}
\begin{center}
\includegraphics[width=$\sxmultiply{#3}{#5}$ cm, height=$\sxmultiply{#4}{#5}$ cm]{#1}
\end{center}
\caption{#2}
\end{figure}
}
Best Answer
The
fp
package is an easy-to-use arithmetic bundle that could help here:However, I would opt for an improved syntax using a key-value approach for exactly the reason mentioned in the first paragraph of the
xkeyval
documentation: