0

It seems as though using nested environments within a tabbing environment along with a new line causes a Extra }, or forgotten \endgroup error.

Here is a minimal working example:

\documentclass{article}

\usepackage{xparse}

\newenvironment{myouter}{\begin{tabbing}}{\end{tabbing}}
\newenvironment{myinner}{}{}

\begin{document}
    \begin{myouter}
        this works \\
    \end{myouter}

    \begin{myouter}
        \begin{myinner}
            so does this
        \end{myinner}
    \end{myouter}

    \begin{myouter}
        \begin{myinner}
            this doesn't \\
        \end{myinner}
    \end{myouter}
\end{document}

Does anybody know how to fix this, or what causes it?

2
  • Note that this doesn't require myouter, this works even if all myouter's are just tabbing environments, I just used outer/inner since it relates to my original problem more closely.
    – LambdaBeta
    Commented Jun 23, 2021 at 19:31
  • 1
    like all alignments cells in tabbing are a group you can not do \begin{myinner} \\ \end{myinner} as the enviornment starts in one group and ends in another, you could not do that in tabular either. Commented Jun 23, 2021 at 21:41

1 Answer 1

2

If your inner environment sets up an environment where \\ has a suitable definition then it works without error.

\documentclass{article}


\newenvironment{myouter}{\begin{tabbing}}{\end{tabbing}}
\newenvironment{myinner}{\begin{minipage}{2cm}}{\end{minipage}}

\begin{document}
    \begin{myouter}
        this works \\
    \end{myouter}

    \begin{myouter}
        \begin{myinner}
            so does this
        \end{myinner}
    \end{myouter}

    \begin{myouter}
        \begin{myinner}
            this doesn't \\
        \end{myinner}
    \end{myouter}
\end{document}

With an empty environment definition then the \\ in the inner environment is the \\ from tabbing and that can not work as tabbing cells, like all alignment cells, are groups You can not start an environment in one group and end it in another, it is essentially like this which gives the same error

\documentclass{article}

\newenvironment{myinner}{}{}

\begin{document}
 { \begin{myinner} }  { \end{myinner} }
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .