git.iko.soy/typeable/pandoc
on master help sign in
Fix issue #52: set max width and height of images in default.beamer
b8ae07eGarrick Aden-Buie
default.beamer+8−17
@@ -66,25 +66,16 @@ $if(url)$
66\usepackage{url}
66\usepackage{url}
67$endif$
67$endif$
68$if(graphics)$
68$if(graphics)$
69−\usepackage{graphicx}
69+\usepackage{letltxmacro}
70−% Redefine \includegraphics so that, unless explicit options are
71−% given, the image width will not exceed the width of the page.
72−% Images get their normal width if they fit onto the page, but
73−% are scaled down if they would overflow the margins.
74\makeatletter
70\makeatletter
75−\def\ScaleIfNeeded{%
76− \ifdim\Gin@nat@width>\linewidth
71+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
77− \linewidth
72+\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi}
78− \else
79− \Gin@nat@width
80− \fi
81−}
82\makeatother
73\makeatother
83−\let\Oldincludegraphics\includegraphics
74+\AtBeginDocument{
84−{%
75+ \LetLtxMacro\Oldincludegraphics\includegraphics
85− \catcode`\@=11\relax%
76+ \renewcommand{\includegraphics}[2][]{%
86− \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
77+ \Oldincludegraphics[#1,width=\maxwidth,height=\maxheight,keepaspectratio]{#2}}
87−}%
78+}
88$endif$
79$endif$
89
80
90% Comment these out if you don't want a slide with just the
81% Comment these out if you don't want a slide with just the