TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Pandoc to convert from markdown to LaTeX or Beamer. The LaTeX template of Pandoc has nice command so that images are resized to fit the text width but the Beamer output is not.


So I tried to copy the commands to the Beamer template, but then it gives an error while compiling with pdflatex. I checked the preamble but couldn't figure out which one is incompatible. Maybe beamer class itself is the problem?

Here is my sample beamer code.

\usepackage{fixltx2e} % provides \textsubscript

% Comment these out if you don't want a slide with just the
% part/section/subsection/subsubsection title:
\setlength{\parskip}{6pt plus 2pt minus 1pt}
\setlength{\emergencystretch}{3em}  % prevent overfull lines



Testing image size from R saved by various methods.



All images were set width = 7. For ggsave, the dpi =300.

\begin{block}{Saved by ggsave}

\caption{Saved by ggsave}


share|improve this question
beamer does a lot of things at the start of the document. Did you try your redefinition \AtBeginDocument? (This might all explode, by the way.) – Joseph Wright Aug 16 '12 at 19:42
up vote 5 down vote accepted

The beamer class redefines \includegraphics, but "at begin document", so your redefinition must be given at the same time:


See the documentation of letltxmacro for understanding why \LetLtxMacro is needed.

share|improve this answer
Yet, your solution works. I had tried \PassOptionsToPackage{draft}{graphicx} but didn't work. – microbe Aug 16 '12 at 21:33
So the key is use \LetLtxMacro instead of \let. Maybe because the macro has optional parameters or was defined as robust. Anyway, this makes Pandoc much more useful. Thank you. – microbe Aug 16 '12 at 21:45
@microbe It wouldn't be necessary for the original \includegraphics, but it is for the macro as redefined by beamer. – egreg Aug 16 '12 at 23:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.