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?

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.

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.