[Tex/LaTex] Multiply the value by decimal number in latex

calculations

I used the following construct quite often:

\includegraphics[width=\textwidth/2]{pic.png}

But when I try to adjust the size a small bit, like this:

\includegraphics[width=\textwidth*0.45]{pic.png}

I get

! Package calc Error: `.' invalid at this point.

What am I doing wrong?

Best Answer

The calc package allows only division by integers or by reals which are announced as \real: so

\includegraphics[width=\textwidth*\real{0.45}]{pic}

will do, but

\includegraphics[width=0.45\textwidth]{pic}

works as well, doesn't require calc and is faster.