Cropping images with trim option, in latex, when you're on OverLeaf.
16 Aug 2021Context: 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}