I tried to use a \savebox around the \BODY macro of \NewEnviron. Can I keep the linebreaks somehow (they are gone, in the MWE)?
\documentclass{article}
\usepackage{environ}
\newsavebox{\mybox}
\NewEnviron{myenv}{%
\savebox{\mybox}{\BODY}
\usebox{\mybox}
}
\begin{document}
\begin{myenv}
A
B
\end{myenv}
\end{document}
The problem is probably independent from the environ package but that is what I'm trying to use.
Or: Is there a way to determine the vertical and horizontal size of the \BODY?

\newsavebox{\mybox}outside of the environment's definition (try using the environment twice to see why) – cgnieder Nov 10 '13 at 16:02\par) as part of the tokenization stage. Moreover\saveboxtypesets its contents in horizontal mode, so you'll get a long line. Maybe you can expand your question telling what's your aim. – egreg Nov 10 '13 at 16:05\BODY.\saveboxseemed to be the closest to this aim. – masu Nov 10 '13 at 16:13\linewidth. – egreg Nov 10 '13 at 16:15adjustboxpackage should help you here. You need to use thevarwidthkey to get a variable width. An alternative is to use thelrboxenvironment with avarwidthenvironment inside it (needs thevarwidthpackage). – Martin Scharrer Nov 10 '13 at 16:16