Fix issue #52: set max width and height of images in default.beamer

This commit is contained in:
Garrick Aden-Buie 2014-04-09 23:59:16 -04:00 committed by John MacFarlane
parent 79806d4417
commit b8ae07eb09

View file

@ -66,25 +66,16 @@ $if(url)$
\usepackage{url} \usepackage{url}
$endif$ $endif$
$if(graphics)$ $if(graphics)$
\usepackage{graphicx} \usepackage{letltxmacro}
% Redefine \includegraphics so that, unless explicit options are
% given, the image width will not exceed the width of the page.
% Images get their normal width if they fit onto the page, but
% are scaled down if they would overflow the margins.
\makeatletter \makeatletter
\def\ScaleIfNeeded{% \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\ifdim\Gin@nat@width>\linewidth \def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother \makeatother
\let\Oldincludegraphics\includegraphics \AtBeginDocument{
{% \LetLtxMacro\Oldincludegraphics\includegraphics
\catcode`\@=11\relax% \renewcommand{\includegraphics}[2][]{%
\gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}% \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}}
}% }
$endif$ $endif$
% Comment these out if you don't want a slide with just the % Comment these out if you don't want a slide with just the