aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-04-30 23:20:42 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-04-30 23:20:42 -0700
commitc3a7937a2852e654da23df978b7abf79955008b7 (patch)
treef22c73d1cf184ade166207bcfff9dd02357a11fa
parent2afb0792ba411006f51cd078fb7c409f0df19dbb (diff)
parenta3cce8d3594fd5da7a83c9926e39eb3ec210b83b (diff)
downloadpandoc-c3a7937a2852e654da23df978b7abf79955008b7.tar.gz
Merge pull request #58 from yihui/master
Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics
-rw-r--r--default.beamer11
-rw-r--r--default.latex22
2 files changed, 11 insertions, 22 deletions
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
diff --git a/default.latex b/default.latex
index 3f833f5fd..f1b1d19b4 100644
--- a/default.latex
+++ b/default.latex
@@ -65,24 +65,14 @@ $if(tables)$
$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.
\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>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
-\let\Oldincludegraphics\includegraphics
-{%
- \catcode`\@=11\relax%
- \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
-}%
+% 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$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex