@@ -65,24 +65,14 @@ $if(tables)$
66$if(graphics)$
66$if(graphics)$
67\usepackage{graphicx}
67\usepackage{graphicx}
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
71−% are scaled down if they would overflow the margins.
72\makeatletter
68\makeatletter
74− \ifdim\Gin@nat@width>\linewidth
69+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
75− \linewidth
70+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
80\makeatother
71\makeatother
81−\let\Oldincludegraphics\includegraphics
72+% Scale images if necessary, so that they will not overflow the page
82−{%
73+% margins by default, and it is still possible to overwrite the defaults
83− \catcode`\@=11\relax%
74+% using explicit options in \includegraphics[width, height, ...]{}
84− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
75+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
88 \usepackage[setpagesize=false, % page size defined by xetex
78 \usepackage[setpagesize=false, % page size defined by xetex