[Tex/LaTex] customize description environment

descriptionenvironments

I would like to define an environment induction which is like the description environment. I have in mind that the output of

\begin{induction}{A}
\item[a1] Part $a1$ of the induction proof.
\item[a2] Part $a2$ of the induction proof. This one needs a further induction argument over $B$.
\begin{induction}{B}
\item[b1] Part $b1$ of the induction proof.
\end{induction}
\end{induction}

should be

\begin{enumerate}
\item[($A$-induction, $a1$)] Part $a1$ of the induction proof.
\item[($A$-induction, $a2$)] Part $a2$ of the induction proof. This one needs a further induction argument over $B$.
\begin{enumerate}
\item[($B$-induction, $b1$)] Part $b1$ of the induction proof.
\end{enumerate}
\end{enumerate}

I have tried to redefine \descriptionlabel but the way I did it I ran into trouble with nested induction environments.

Best Answer

Here is one possibility, by redefining the way \descriptionlabel works at the beginning of every induction environment:

enter image description here

\documentclass{article}

\newenvironment{induction}[1]
  {\renewcommand{\descriptionlabel}[1]{\hspace\labelsep\normalfont\bfseries$#1$-induction, $##1$}%
   \begin{description}}
  {\end{description}}
\begin{document}

\begin{induction}{A}
  \item[a1] Part~$a1$ of the induction proof.
  \item[a2] Part~$a2$ of the induction proof. This one needs a further induction argument over~$B$.
  \begin{induction}{B}
    \item[b1] Part~$b1$ of the induction proof.
  \end{induction}
\end{induction}

\end{document}

One thing I might change in your usage is to supply $A$ rather than A; that is, remove the automated math-mode insertion of the arguments to induction and \item.


The above solution re-uses the description environment within the induction environment. If you wish to mix the two, it's best to define induction to be completely separate from description:

enter image description here

\documentclass{article}

\providecommand*\inductionlabel{}

\makeatletter
\newenvironment{induction}[1]
  {\renewcommand{\inductionlabel}[1]{\hspace\labelsep\normalfont\bfseries$#1$-induction, $##1$}%
   \list{}{\labelwidth\z@ \itemindent-\leftmargin
          \let\makelabel\inductionlabel}}
  {\endlist}
\makeatother

\begin{document}

\begin{induction}{A}
  \item[a1] Part~$a1$ of the induction proof.
  \item[a2] Part~$a2$ of the induction proof. This one needs a further induction argument over~$B$.
  \begin{induction}{B}
    \item[b1] Part~$b1$ of the induction proof.
    \begin{description}
      \item[something] something else
    \end{description}
  \end{induction}
\end{induction}

\end{document}