@@ -66,25 +66,16 @@ $if(url)$
6666\usepackage{url}
6767$endif$
6868$if(graphics)$
69−\usepackage{graphicx}
70−% Redefine \includegraphics so that, unless explicit options are
71−% given, the image width will not exceed the width of the page.
72−% Images get their normal width if they fit onto the page, but
73−% are scaled down if they would overflow the margins.
69+\usepackage{letltxmacro}
7470\makeatletter
75−\def\ScaleIfNeeded{%
76− \ifdim\Gin@nat@width>\linewidth
77− \linewidth
78− \else
79− \Gin@nat@width
80− \fi
81−}
71+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
72+\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
8273\makeatother
83−\let\Oldincludegraphics\includegraphics
84−{%
85− \catcode`\@=11\relax%
86− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
87−}%
74+\AtBeginDocument{
75+ \LetLtxMacro\Oldincludegraphics\includegraphics
76+ \renewcommand{\includegraphics}[2][]{%
77+ \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}}
78+}
8879$endif$
8980
9081% Comment these out if you don't want a slide with just the