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.
\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,

enter image description here

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

share|improve this question

1 Answer 1

up vote 11 down vote accepted

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}
share|improve this answer
    
Is there any macro to remove the "shield" made by \usebox? –  Please don't touch Mar 9 '13 at 2:52
3  
@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

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.