Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Say I have an image my_image.png that I am loading in my LaTeX document using:

\begin{figure}
\includegraphics[width=0.5cm]{my_image.png}}
\end{figure}

Is there a way of telling LaTeX to only render a specific rectangular portion (in percentages) of the original image?

For example, say I want to just render a cropped image:

  • Trim 5% of the original image width from the left
  • Trim 10% of the original image width from the right
  • Trim 15% of the original image height from the top
  • Trim 20% of the original image height from the bottom
share|improve this question
    
have a look at the package adjustbox with the option export. –  Marco Daniel Apr 20 '12 at 14:10

1 Answer 1

up vote 17 down vote accepted
\documentclass{article}
\usepackage{graphicx}
\usepackage{adjustbox}

\begin{document}

\adjustbox{trim={.05\width} {.2\height} {0.1\width} {.15\height},clip}%
  {\includegraphics[width=0.5cm]{cupdot.png}}

\end{document}

Since \includegraphics produces no depth, you can use the fact that \adjustbox knows the \width and the \height of the image.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.