jgm/pandoc-templates — pull request #58 by yihui (2014-04-11 22:41:26+00:00)
Title: 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 `[]`.

This closes the issues #26, #28, and #30.

I have provided the test case with a variety of figure sizes here: https://www.dropbox.com/sh/72mw64o8iqlwn1b/-ETTcO13rU

```bash
pandoc -o test-article.pdf --template default.latex test.md
pandoc -o test-beamer.pdf --template default.beamer -t beamer test.md
```

It seems this approach works pretty well in both articles and beamer slides.