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 many pictures within my beamer presentation. Somehow I'm tired of writing:


It works fine and does what I want, but I want to write less code :-)) e.g.:


Yes, I know scale but it works relative to the image size, but not (what I want) relative to the page size … Is there a lightweight and genuine way to achieve this?

share|improve this question
up vote 8 down vote accepted

You could define your own include command, like so:





edit by Claudio Fiandrino

To have the possibility of shrink the image with custom values, one could proceed with a small change to the \mycommand:

\usepackage{mwe}% for dummy images
% mycommand:
% #1: optional -> "shrink" value (default value to 0.8)
% #2: mandatory -> image


\begin{figure}% notice that in Beamer having floating figures is not necessary


The result:

enter image description here

share|improve this answer
See below: Sometimes I want to have a "shrink" of 0.8, sometimes of 0.4 or sth. else… this one would fix the page-image-ratio to 0.8, wouldn't it? But if I modify your solution using two parameters, I could achieve my goal… – Vincent Jan 13 '13 at 15:47
@Vincent: just change a bit the command: \newcommand{\mycommand}[2][0.8]{\includegraphics[width=#1\textwidth,height=#1\t‌​extheight,keepaspectratio]{#2}}. The use \mycommand{source} will use 0.8 by default, while \mycommand[0.1]{source} will shrink more the image. – Claudio Fiandrino Jan 13 '13 at 15:51
@ClaudioFiandrino: this is what I'm looking for and trying to build! Thank you. – Vincent Jan 13 '13 at 15:55

You can use


and it will apply to all following \includegraphics

If you want to make it paramatersised by argument then perhaps simplest is to observe that the keys you are using are defined by


so all you need is


Then myscale=0.8 does what you ask (\linewidth will be \textwidth or \columnwidth or some other length relevant for the current context.)

share|improve this answer
Note that \setkeys{Gin}{..} doesn't work with all graphicx keys (but with the three shown here it does), because some will try to affect the current image directly and if used like this there is no current image. Because of this I added a feature to adjustbox to also set such keys globally. – Martin Scharrer Jan 13 '13 at 20:19

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.