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}


  • 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

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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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