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.

I want to superpose a text to some other object (in this aces a picture). My idea is to store the picture in \mabox, to display it with in a \makebox with 0 width and height, then to display the text thru a second \makebox, with width and height equal to those of \mabox. My attempt fails, because \wd\mabox delivers a length with unit, and \makebox expects a length without unit. How could i do it better?

\documentclass{article}
\usepackage{graphicx}
\usepackage{blindtext}

\begin{document}

\newsavebox\mabox
\sbox{\mabox}{\includegraphics[scale=0.10]{Pingouin}}
\makebox(0,0)[b]{\put(0,0){\usebox\mabox}}
\fbox{\makebox(\wd\mabox,\ht\mabox)[b]{\put(0,0){\parbox{\wd\mabox}{\blindtext}}}}

\end{document}
share|improve this question
    
Would it be a solution to use TikZ? In that case, take a look at tex.stackexchange.com/questions/9559/… –  ilpssun Mar 16 '12 at 9:36
add comment

2 Answers

up vote 6 down vote accepted

Don't tell anyone I told you, but you can go

\def\unitlength{}
\sbox{\mabox}{\includegraphics[scale=0.10]{Pingouin}}
\makebox(0pt,0pt)[b]{\put(0pt,0pt){\usebox\mabox}}
\fbox{\makebox(\wd\mabox,\ht\mabox)[b]{\put(0pt,0pt){\parbox{\wd\mabox}{blindtext}}}}

Note that having made \unitlength unitless, you have to put explicit units in places that normally take an integer.

The alternative is to use \strip@pt defined in LaTeX eg this use where LaTeX is switching between unit and non-unit font size representation

   \edef\f@size{\strip@pt\@tempdimb}%

but often it's easier just to use units everywhere in picture mode, then you are not restricted to using the same units throughout.

share|improve this answer
    
ok, i will not tell anyone ;) But the command \strip@pt makes exactly what i want : just put a \strip@pt before \wd\mabox and \ht\mabox in my second makebox. Thanks ! –  nicolas roy Mar 16 '12 at 9:45
add comment

Use the picture package, so that

\makebox(1cm,3in){...}

is accepted; you're allowed to put explicit and implicit (that is, expressed as register values) dimensions in all commands of the picture environment.

share|improve this answer
add comment

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.