2

I would like to combine the tagging package with ntheorem to obtain ntheorem-environments that are tagged. A minimal example would be:

\documentclass{scrartcl}
\usepackage{tagging}
\usepackage{ntheorem}

\newtheorem{Def}{Definition}

%\usetag{DefTag}
\droptag{DefTag}

\newenvironment{TaggedDef}{ %
    \begin{taggedblock}{DefTag} %
        \begin{Def} %
}
{
        \end{Def} %
    \end{taggedblock} %
}

\begin{document}


\begin{TaggedDef}
Test
\end{TaggedDef}

\begin{taggedblock}{DefTag}
\begin{Def}
    Test
\end{Def}
\end{taggedblock}

\end{document}

Unfortunately, the first Test does not work. I obtain the error message:

\begin{TaggedDef} on input line 21 ended by \end{document}. \end{document}

The second Test works fine and the first Test works also fine, if one replaces the \droptag{DefTag} by \usetag{DefTag}.

What am I doing wrong? Is it not possible to nest environments that way?

1

Use the commands associated to the environments (I also added an optional argument to TaggedDef to keep the optional argument for Def but this, of course, it's optional):

\documentclass{scrartcl}
\usepackage{tagging}
\usepackage{ntheorem}
\usepackage{etoolbox}

\newtheorem{Def}{Definition}

\usetag{DefTag}
%\droptag{DefTag}

\newenvironment{TaggedDef}[1][]{%
    \taggedblock{DefTag}%
    \ifstrempty{#1}{\Def}{\Def[#1]}%
}
{%
        \endDef%
    \endtaggedblock%
}

\begin{document}

\begin{TaggedDef}
Test.
\end{TaggedDef}

\begin{TaggedDef}[An important definition]
Test.
\end{TaggedDef}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.