The problem with box-saving environments is that all code inside the environment is usually local. The 'lrbox' environment actually breaks out of its own group to ensure that the box assignment is part of the surrounding scope. This makes including it as part of other environments difficult. Using the "plain-TeX style" \lrbox .. \endlrbox causes issues because of the special group handling.
Either you replicate the internal code of lrbox (see the file latex.ltx) or you use global assignments, which will earn you minus points in the B-mark but is much simpler to implement and might be acceptable in your case. You can use the lower-level TeX code (\setbox with \bgroup and \egroup instead of braces) to store the environment content. You need to add the internal color grouping statements to ensure that all color macros, if any, are properly stored in the box as well.
\documentclass{article}
\makeatletter
\newenvironment{patternn}[1]{%
\par % I think you should start a paragraph first, but it's up to you
\textbf{Pattern}%
\newsavebox{#1}%
\global\setbox#1\hbox\bgroup\color@setgroup
}{%
\color@endgroup\egroup
\usebox{#1}%
}
\makeatother
\begin{document}
\begin{patternn}{\aaa}
test
\end{patternn}
And now try again:
\usebox{\aaa}
\end{document}
#1rather than\#1. – yannisl Feb 26 '12 at 20:32environpackage. – mbork Feb 26 '12 at 20:44\csname...\endcsnameconstruction, but since you are using LaTeX, I suggest that you avoid this and just require the argument to your environment to be a command name in the first place. – Ryan Reich Feb 26 '12 at 20:57etoolboxand its\csdefand similar commands (though in this particular case it might not work anyway). Maybeexpl3? – mbork Feb 26 '12 at 21:00\newenvironmentcommand. You have to define a command in the first required argument and use it in the second:newenvironment{textenv}[1]{define here. more stuff}{use here}. – Feb 26 '12 at 21:50