I was trying to write an environment using the
environ
package. The new environment
can be defined without any problem. For some personal reasons, I want to
put the start and end of environments to some macros.
See this MWE:
\documentclass{article}
\usepackage{environ}
\makeatletter
\NewEnviron{workpl@n}{\BODY}[\relax]
% The following will not pose any problem
% \newenvironment{workpl@n}{\relax}{\relax}
\def\beginworkplan{\begin{workpl@n}}
\def\endworkplan{\end{workpl@n}}
\makeatother
\begin{document}
% Does not work
% \beginworkplan
\makeatletter
% Works
\begin{workpl@n}
Plan
% Works
\end{workpl@n}
% Does not work
% \endworkplan
\makeatother
\end{document}
Strangely, \beginworkplan
, \endworkplan
command pair fails
with the message:
! LaTeX Error: \begin{workpl@n} on input line 14 ended by \end{document}.
However, if the environment is started and finished directly (using \begin{workpl@n}
and \end{workpl@n}
), it also works.
Moreover, if a new environment is defined using the basic \newenvironment
command,
putting the start and end of environments to\beginworkplan
and \endworkplan
does not pose any problem at all.
I need to use \NewEnviron
since I have the necessity to collect the
environment body.