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 have a collection of images of different sizes. I would like to set a limit on their width, such that if the image is wider than this limit it will be scaled down, but if it is smaller then the image is inserted at its native size. Right now the only way I know how to manipulate the image width is with:


But this sets the width regardless of the current image size.

Two questions:

  • is it possible to limit the image width as described for a single image?
  • is it possible to configure a global setting so that a limit is applied to all images, without need to use [width=SOMEWIDTH] on individuals?
share|improve this question
Related: Shrink figure only when necessary? (the linked question doesn't provide a "global setting"). – Werner Nov 16 '13 at 3:45
up vote 13 down vote accepted

You can redefine \includegraphics to always set a maximum width of \linewidth with the aid of adjustbox:

enter image description here

\usepackage[export]{adjustbox}% http://ctan.org/pkg/adjustbox
  \oldincludegraphics[#1,max width=\linewidth]{#2}}

X \dotfill X


adjustbox's settings are exported to \includegraphics, which then allows you to use max width=<len> to set the maximum width of the included graphic. Anything wider than that will be shrunk; anything narrower than that will remain at that (natural) width.

share|improve this answer

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.