git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #58 from yihui/master

Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics

commitc3a7937a2852e654da23df978b7abf79955008b7 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 30 Apr 2014, 23:20 (13 years ago) parent2afb079a3cce8d
2 files changed+11−22
default.beamer+5−6 default.latex+6−16
default.beamer+5−6
@@ -69,16 +69,15 @@ $if(url)$
6969\usepackage{url}
7070$endif$
7171$if(graphics)$
72−\usepackage{letltxmacro}
72+\usepackage{graphicx}
7373\makeatletter
7474\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
7575\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
7676\makeatother
77−\AtBeginDocument{
78− \LetLtxMacro\Oldincludegraphics\includegraphics
79− \renewcommand{\includegraphics}[2][]{%
80− \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}}
81−}
77+% Scale images if necessary, so that they will not overflow the page
78+% margins by default, and it is still possible to overwrite the defaults
79+% using explicit options in \includegraphics[width, height, ...]{}
80+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
8281$endif$
8382
8483% Comment these out if you don't want a slide with just the
default.latex+6−16
@@ -65,24 +65,14 @@ $if(tables)$
6565$endif$
6666$if(graphics)$
6767\usepackage{graphicx}
68−% Redefine \includegraphics so that, unless explicit options are
69−% given, the image width will not exceed the width of the page.
70−% Images get their normal width if they fit onto the page, but
71−% are scaled down if they would overflow the margins.
7268\makeatletter
73−\def\ScaleIfNeeded{%
74− \ifdim\Gin@nat@width>\linewidth
75− \linewidth
76− \else
77− \Gin@nat@width
78− \fi
79−}
69+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
70+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
8071\makeatother
81−\let\Oldincludegraphics\includegraphics
82−{%
83− \catcode`\@=11\relax%
84− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
85−}%
72+% Scale images if necessary, so that they will not overflow the page
73+% margins by default, and it is still possible to overwrite the defaults
74+% using explicit options in \includegraphics[width, height, ...]{}
75+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
8676$endif$
8777\ifxetex
8878 \usepackage[setpagesize=false, % page size defined by xetex