# Why does \textit not produce the expected result when used with \usebox?

\documentclass[border=3pt]{standalone}

\newsavebox\temp
\newenvironment{definition}
{\begin{lrbox}{\temp}}
{\end{lrbox}\textit{\usebox\temp}}

\begin{document}
\begin{definition}
Hello World!
\end{definition}
\end{document}


produces a normal typeface as follows,

Why \textit does not produce the expected result when it works with \usebox?

-

Because the \usebox is a fixed entity, locked in concrete. It can be scaled, but its contents cannot be changed (other than by redefining it from scratch). The way you have it setup, the \textit tries to work on the already complete box. The \textit needs to go inside the box.

\documentclass{article}

\newsavebox\temp
\newenvironment{definition}
{\begin{lrbox}{\temp}\begin{itshape}}
{\end{itshape}\end{lrbox}{\usebox\temp}}

\begin{document}
\begin{definition}
Hello World!
\end{definition}
\end{document}

-
Is there any macro to remove the "shield" made by \usebox? –  Please don't touch Mar 9 '13 at 2:52
@GarbageCollector No: a box contains typeset material, that's the entire point. If you want to collect the content of an environment and typeset it at the end, look at the environ package. –  Joseph Wright Mar 9 '13 at 10:18