[Tex/LaTex] Crop an inserted image


I'm inserting an image with a simple:


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



% trim from left edge
\includegraphics[trim={5cm 0 0 0},clip]{example-image-a}
% trim from right edge
\includegraphics[trim={0 0 5cm 0},clip]{example-image-a}

Use the trim option, which takes four space separated values.

 trim={<left> <lower> <right> <upper>}

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 with clip=true or just clip.

If you combine trim with height 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.


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.



\adjincludegraphics[height=5cm,trim={0 0 {.5\width} 0},clip]{example-image-a}

adjustbox also provides \height, \depth and \totalheight.