The LaTeX way: package calc
Package calc redefines \setlength, \addtolength, \setcounter, \addtocounter to support expressions. If another package uses these macros for setting length and counters with user provided values, then it inherits the power from package calc. It is enough to load the package, the other package does not even know about calc:
\usepackage{graphicx}
\usepackage{calc}
...
\includegraphics[width=(\textwidth - 50mm)/2]{myfig.eps}
The eTeX way: \dimexpr
If the eTeX extensions are enabled (usually the default for LaTeX based formats nowadays), \dimexpr can be used, where a TeX length is expected (see Herbert's answer):
\includegraphics[width=\dimexpr(\textwidth-50mm)/2]{myfig.eps}
Comparison
- Dependencies: Package
calc vs. eTeX
- eTeX's
\dimexpr, \numexpr, … are expandable.
\dimexpr also works, if internally \setlength is not used, e.g. \vspace.
- I expect
calc to be slower, because of the internal macro work that needs to be done.
\dimexpr calculates with higher precision.
- Package
calc truncates: 5/2 = 2
eTeX rounds: 5/2 = 3
- Package
calc provides additional operators (\widthof, \heightof, \totalheightof, \maxof, \minof).