15

In LaTeX, is it possible to create an empty box that has exactly the dimensions of some content given?

Example:

\emptybox{abc}

would insert an empty box of the size as if "abc" was printed there.

25

You can use a phantom: \phantom{abc}

\phantom makes an invisible box whose height, depth and width are the same as those of the string used in the argument. There's also \vphantom, which makes an invisible box whose height and depth are the same as those of the string used in the argument, but the width is zero. Finally, \hphantom has the width of the string used in the argument, but its height and depth are zero.

6

See also, the related commands:

\settowidth{\mylength}{stuff}
\settoheight{\mylength}{stuff} % height above baseline
\settodepth{\mylength}{stuff}  % depth below baseline

Example:

\newlength{\mywidth}
\settowidth{\mywidth}{plugh}

\hspace*{\mywidth}Hello

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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