Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

\end occurred inside a group

86 views
Skip to first unread message

Ahmed Musa

unread,
Apr 14, 2011, 4:34:05 PM4/14/11
to
Please why is there an unclosed group in the following?

\RequirePackage[logonly]{trace}
\documentclass{article}
\makeatletter

\newcommand*\newcomment{%
\begingroup
\def\do##1{\catcode`##1=12}%
\dospecials
\endlinechar`\^^M\catcode`\^^M=12\relax
\@comment
}
\begingroup
\catcode`\^^M=12 %
\endlinechar\m@ne%
\gdef\@comment#1^^M{
\def\@stuff{#1}
\ifx\@stuff\endnewcomment\expandafter
\endgroup\else\expandafter\@comment\fi
}
\endgroup
\begingroup
\catcode`\{=12
\catcode`\}=12
\catcode`\!=0
\catcode`\[=1
\catcode`\]=2
\catcode`\\=12
!gdef!endnewcomment[\end{newcomment}]
!endgroup

\traceon

\begin{newcomment}
xxx
xxx
xxx
\end{newcomment}

\traceoff
\stop

\begin{document}

\end{document}

% Log file:
(\end occurred inside a group at level 1)
### semi simple group (level 1) entered at line 32 (\begingroup)
### bottom level

Bruno Le Floch

unread,
Apr 14, 2011, 5:05:43 PM4/14/11
to
> \begin{newcomment}
> xxx
> xxx
> xxx
> \end{newcomment}

\begin{foo} already opens a group, so you don't need to open another
one in the definition of \newcomment. Alternatively, you can close two
groups (yours and LaTeX's in the \end-definition). If you want the
command to work both as an environment and a command, you will need to
test \@currenvir to see \newcomment was invoked from
\begin{newcomment} or on its own.

Regards,
Bruno

GL

unread,
Apr 14, 2011, 5:09:59 PM4/14/11
to
Le 14/04/2011 22:34, Ahmed Musa a écrit :
> Please why is there an unclosed group in the following?

because \begin opens a group and \end is gobbled and does not closes it.

besides \expandafter\endgroup \else is \endgroup \else !

0 new messages