# Command enclosing content of custom environment

I want to create an environment that wraps the content in a command so that I can write this:

\begin{mybox}
content
\end{mybox}


and get this:

\psshadowbox{content}


When doing it as a custom command it's no problem because everything is defined in the same block, but since custom environments are defined over two blocks I'd have to put the closing brace for the command in another block than the starting brace which obviously doesn't work:

\newenvironment{mybox}
{ }             }


The reason I don't want to use a command for this is mainly readability, because the content can get quite long and a mere closing brace just isn't very expressive.

-

You need to store the content first into a box and then use the box with the command:

\newenvironment{mybox}{%
\begin{lrbox}{0}%
}{%
\end{lrbox}%
}


You can also use the adjustbox package/environment for this:

\begin{adjustbox}{precode=\psshadowbox}
...

-

You can also use the package framed to allow page breaks:

\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{pstricks}
\newenvironment{mybox}{%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\usepackage{lipsum}
\begin{document}
\begin{mybox}
\lipsum
\end{mybox}
\end{document}

-

In general you can also use the environ package which provides the content of the environment in \BODY, which can be passe to a macro:

\documentclass{article}
\usepackage{environ}

\newcommand{\MyMacro}[1]{MyMacro = #1}%

\NewEnviron{mybox}{%
\MyMacro{\BODY}%
}{}%

\begin{document}
\begin{mybox}
content
\end{mybox}
\end{document}


For your specific application with \psshadow:

% !TEX program = xelatex
\documentclass{article}
\usepackage{pstricks}
\usepackage{environ}