I'm inserting an image with a simple:
\includegraphics[height=5cm]{filename.png}
This results in an image that maintains the aspect ratio, and so gives me something like 6cm width. I only really want the left side of the image though, and would like to crop it to 50% width. Is it possible to do this?
If possible, I'd like to do this in a portable way (i.e. something that other authors of this document won't have to install packages for, and something that works with a reasonably old version of pdflatex
– our computers at work are in sore need of an upgrade).
Best Answer
You can crop your image with
graphicx
Use the
trim
option, which takes four space separated values.If you don’t give a unit, the package assumes
bp
i.e. big points to be the unit. After setting these values you must activate the cropping withclip=true
or justclip
.If you combine
trim
withheight
or something similar the image will be cropped and then resized. That means that the crop values must fit the original size. If found no solution to say crop to 50 % width.Update
As Martin said in the comments you can use
adjustbox
to clip the image exactly by 50 %. Note that you must replace\includegraphics
by\adjincludegraphics
, to access the\width
.adjustbox
also provides\height
,\depth
and\totalheight
.