@@ -65,15 +65,19 @@ $if(tables)$
6565$endif$
6666$if(graphics)$
6767\usepackage{graphicx}
68−% We will generate all images so they have a width \maxwidth. This means
69−% that they will get their normal width if they fit onto the page, but
68+% Redefine \includegraphics so that, unless explicit options are
69+% given, the image width will not exceed the width of the page.
70+% Images get their normal width if they fit onto the page, but
7071% are scaled down if they would overflow the margins.
7172\makeatletter
7273\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
7374\else\Gin@nat@width\fi}
7475\makeatother
7576\let\Oldincludegraphics\includegraphics
76−\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
77+{%
78+ \catcode`\@=11\relax%
79+ \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\maxwidth]}}%
80+}%
7781$endif$
7882\ifxetex
7983 \usepackage[setpagesize=false, % page size defined by xetex