4

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}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Loic Rosnay
  • 8,167

2 Answers2

6

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.

David Carlisle
  • 757,742
  • 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 ! – Loic Rosnay Mar 16 '12 at 09:45
4

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.

egreg
  • 1,121,712