# Latex trimbox figure?

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}


• 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

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}


• 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