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.

How to suppress units in length macros such that they can be passed to viewport. See the following Minimal Not Working Example,

\documentclass{article}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{bald}}
\newdimen\width
\newdimen\height
\width=\wd\IBox
\height=\ht\IBox
\parindent=0bp
\begin{document}
\makeatletter
\includegraphics[viewport=0 0 \strip@pt\width \strip@pt\height]{bald}
\makeatother
\end{document}
share|improve this question
1  
Note that \width and \height are often used temporally by macros like \raisebox and then set to the content size. It's not an issue here, I just want to point that out. I'm planning to add this to \includegraphics in the next feature release of adjustbox. –  Martin Scharrer Jul 12 '11 at 9:37
    
@Martin: Can you give me an example where \width and \height will affect \raisebox in a practical situation? –  xport Jul 12 '11 at 14:09

1 Answer 1

up vote 2 down vote accepted

The viewport option actually accepts units, but defaults to bp if none are used. The issue here is that the macro is eating the space behind it which is used as a separator by viewport (and also trim). The solution is to wrap the expression in { } (which is removed afterwards) to protect the space:

\includegraphics[viewport=0 0 {\width} \height]{bald}
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.