Web Analytics Made
Easy - StatCounter

Cropping images with trim option, in latex, when you're on OverLeaf.

Context: you’re writing in latex, and you want to crop an image used in a figure. Sure, you could do this in an editor, but cropping through latex allows you to crop all subfigures the same way, for instance.

You can do this with the graphicx package, here’s the relevant StackExchange.

Here, copied from StackExchange:

\documentclass{article}

\usepackage{graphicx}

\begin{document}
% 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}
\end{document}

And I always forget the order for the trim option. It is trim=left lower right upper.

Ok, this works on my local machine but it will not work on OverLeaf right now. You have to get rid of the curly braces. I don’t know why.

\documentclass{article}

\usepackage{graphicx}

\begin{document}
% 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}
\end{document}

© Amy Tabb 2018 - 2021. All rights reserved. The contents of this site reflect my personal perspectives and not those of any other entity.