@@ -22,24 +22,14 @@
22\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
22\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
23\usepackage{fancyvrb}
23\usepackage{fancyvrb}
24\usepackage{graphicx}
24\usepackage{graphicx}
25−% Redefine \includegraphics so that, unless explicit options are
26−% given, the image width will not exceed the width of the page.
27−% Images get their normal width if they fit onto the page, but
28−% are scaled down if they would overflow the margins.
29\makeatletter
25\makeatletter
31− \ifdim\Gin@nat@width>\linewidth
26+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
32− \linewidth
27+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
37\makeatother
28\makeatother
38−\let\Oldincludegraphics\includegraphics
29+% Scale images if necessary, so that they will not overflow the page
39−{%
30+% margins by default, and it is still possible to overwrite the defaults
40− \catcode`\@=11\relax%
31+% using explicit options in \includegraphics[width, height, ...]{}
41− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
32+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
44 \usepackage[setpagesize=false, % page size defined by xetex
34 \usepackage[setpagesize=false, % page size defined by xetex
45 unicode=false, % unicode breaks when used with xetex
35 unicode=false, % unicode breaks when used with xetex