Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix includegraphics using default keys #30

Closed
wants to merge 1 commit into from

1 participant

@jtanguy

Instead of redefining \includegraphics in LateX and beamer templates, the
preambles now use the graphicx \setkey system.

I believe it solves the graphicx problems for PR #26 and #28

@jtanguy jtanguy Use graphicx defaults
Instead of redefining \includegraphics in LateX and beamer templates, the
preambles now use the graphicx \setkey system.
6bc432f
@jgm jgm closed this pull request from a commit
@yihui yihui 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
a3cce8d
@jgm jgm closed this in a3cce8d
@jrbing jrbing referenced this pull request from a commit in jrbing/pandoc-templates
@yihui yihui 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
05ce16e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 4, 2013
  1. @jtanguy

    Use graphicx defaults

    jtanguy authored
    Instead of redefining \includegraphics in LateX and beamer templates, the
    preambles now use the graphicx \setkey system.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 9 deletions.
  1. +2 −3 default.beamer
  2. +2 −6 default.latex
View
5 default.beamer
@@ -53,7 +53,7 @@ $if(url)$
$endif$
$if(graphics)$
\usepackage{graphicx}
-% Redefine \includegraphics so that, unless explicit options are
+% Set \includegraphics defaults 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.
@@ -66,8 +66,7 @@ $if(graphics)$
\fi
}
\makeatother
-\let\Oldincludegraphics\includegraphics
-\renewcommand{\includegraphics}[2][]{\Oldincludegraphics[width=\ScaleIfNeeded]{#2}}
+\setkeys{Gin}{width=\ScaleIfNeeded}
$endif$
% Comment these out if you don't want a slide with just the
View
8 default.latex
@@ -65,7 +65,7 @@ $if(tables)$
$endif$
$if(graphics)$
\usepackage{graphicx}
-% Redefine \includegraphics so that, unless explicit options are
+% Set \includegraphics defaults 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.
@@ -78,11 +78,7 @@ $if(graphics)$
\fi
}
\makeatother
-\let\Oldincludegraphics\includegraphics
-{%
- \catcode`\@=11\relax%
- \gdef\includegraphics{\@ifnextchar[{\Oldincludegraphics}{\Oldincludegraphics[width=\ScaleIfNeeded]}}%
-}%
+\setkeys{Gin}{width=\ScaleIfNeeded}
$endif$
\ifxetex
\usepackage[setpagesize=false, % page size defined by xetex
Something went wrong with that request. Please try again.