From b8ae07eb09b921beec11d67ea35b4f79941fdd09 Mon Sep 17 00:00:00 2001 From: Garrick Aden-Buie Date: Wed, 9 Apr 2014 23:59:16 -0400 Subject: Fix issue #52: set max width and height of images in default.beamer --- default.beamer | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/default.beamer b/default.beamer index b220a43b9..0806e362f 100644 --- a/default.beamer +++ b/default.beamer @@ -66,25 +66,16 @@ $if(url)$ \usepackage{url} $endif$ $if(graphics)$ -\usepackage{graphicx} -% 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. +\usepackage{letltxmacro} \makeatletter -\def\ScaleIfNeeded{% - \ifdim\Gin@nat@width>\linewidth - \linewidth - \else - \Gin@nat@width - \fi -} +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} +\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi} \makeatother -\let\Oldincludegraphics\includegraphics -{% - \catcode`\@=11\relax% - \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}% -}% +\AtBeginDocument{ + \LetLtxMacro\Oldincludegraphics\includegraphics + \renewcommand{\includegraphics}[2][]{% + \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}} +} $endif$ % Comment these out if you don't want a slide with just the -- cgit v1.2.3