2

I wonder if it is possible to have a trim box in latex that can trim figures?

For example using latex trim, I know it's possible for example to trim the top of a figure (see left figure down below). Now suppose I don't want to trim the full width of the top but maybe just 50 % of the width from the top (see figure to the right down below). Is it possible to do this?

\includegraphics[trim={0 0 1cm 0},clip]{duck.png}

enter image description here

  • 1
    I don't think you can trim only part of the image. However, you can put something else on top - another image, or some sort of frame, or text with a white background - so that part of the image is not visible. – Marijn Apr 23 at 13:42
7

You can use tikz to clip it:

\documentclass{article}
\usepackage{tikz,graphicx}
\begin{document}
\newsavebox\mybox
\savebox\mybox{\includegraphics[width=10cm]{example-image-duck}}
\begin{tikzpicture}
\clip(0,0)--++(0,\ht\mybox)--++(0.5\wd\mybox,0)--++(0,-1cm)--++(0.5\wd\mybox,0)--++(0,-\ht\mybox+1cm)--cycle;
\node[inner sep=0pt,anchor=south west]{\usebox\mybox};
\end{tikzpicture}


\end{document}

enter image description here

  • Could you explain what the options in \clip command does? – Turbotanten Apr 23 at 14:13
  • I'm simply drawing the path for the clip (and use the height and width of the box). – Ulrike Fischer Apr 23 at 14:16

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.