git.iko.soy/typeable/pandoc
on master help sign in
Use \setkeys{Gin}{} to set appropriate defaults for \includegraphics, instead of entirely redefining this command.
a3cce8dYihui Xie
default.beamer+5−6
@@ -69,16 +69,15 @@ $if(url)$
69\usepackage{url}
69\usepackage{url}
70$endif$
70$endif$
71$if(graphics)$
71$if(graphics)$
72−\usepackage{letltxmacro}
72+\usepackage{graphicx}
73\makeatletter
73\makeatletter
74\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
74\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
75\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
75\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
76\makeatother
76\makeatother
77−\AtBeginDocument{
77+% Scale images if necessary, so that they will not overflow the page
78− \LetLtxMacro\Oldincludegraphics\includegraphics
78+% margins by default, and it is still possible to overwrite the defaults
79− \renewcommand{\includegraphics}[2][]{%
79+% using explicit options in \includegraphics[width, height, ...]{}
80− \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}}
80+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
81−}
82$endif$
81$endif$
83
82
84% Comment these out if you don't want a slide with just the
83% Comment these out if you don't want a slide with just the
default.latex+6−16
@@ -65,24 +65,14 @@ $if(tables)$
65$endif$
65$endif$
66$if(graphics)$
66$if(graphics)$
67\usepackage{graphicx}
67\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.
72\makeatletter
68\makeatletter
73−\def\ScaleIfNeeded{%
74− \ifdim\Gin@nat@width>\linewidth
69+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
75− \linewidth
70+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
76− \else
77− \Gin@nat@width
78− \fi
79−}
80\makeatother
71\makeatother
81−\let\Oldincludegraphics\includegraphics
72+% Scale images if necessary, so that they will not overflow the page
82−{%
73+% margins by default, and it is still possible to overwrite the defaults
83− \catcode`\@=11\relax%
74+% using explicit options in \includegraphics[width, height, ...]{}
84− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
75+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
85−}%
86$endif$
76$endif$
87\ifxetex
77\ifxetex
88 \usepackage[setpagesize=false, % page size defined by xetex
78 \usepackage[setpagesize=false, % page size defined by xetex