From a3cce8d3594fd5da7a83c9926e39eb3ec210b83b Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Fri, 11 Apr 2014 17:22:45 -0500 Subject: Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics, instead of entirely redefining this command. Note we also consider the height of images; if an image is too high, 0.8\textheight will be used for beamer slides, and \textheight is used for articles (see http://tex.stackexchange.com/q/11954/9128). If the user has explicitly provided the width/height options in \includegraphics[], our defaults will be overwritten, and this approach is better than the check `\@ifnextchar[` after \includegraphics because the latter approach simply gives up everything once it sees [, whereas \setkeys{Gin} can keep the good defaults unless they are explicitly overwritten in []. closes #30, closes #28, and closes #26 --- default.beamer | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'default.beamer') diff --git a/default.beamer b/default.beamer index 102772aea..3291bb3f2 100644 --- a/default.beamer +++ b/default.beamer @@ -69,16 +69,15 @@ $if(url)$ \usepackage{url} $endif$ $if(graphics)$ -\usepackage{letltxmacro} +\usepackage{graphicx} \makeatletter \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 -\AtBeginDocument{ - \LetLtxMacro\Oldincludegraphics\includegraphics - \renewcommand{\includegraphics}[2][]{% - \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}} -} +% Scale images if necessary, so that they will not overflow the page +% margins by default, and it is still possible to overwrite the defaults +% using explicit options in \includegraphics[width, height, ...]{} +\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} $endif$ % Comment these out if you don't want a slide with just the -- cgit v1.2.3