3

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.

2 Answers 2

4

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}
2
  • I noticed that the nesting problem I had happened actually when I combined induction and description environments. Does that also occur here? I'm not sure that I will really need to combine these two, but I'd be interested to see how I prevent the renewed description label to carry over to ordinary description environments.
    – Egbert
    Oct 7, 2014 at 0:29
  • 1
    @Egbert: I've updated the answer to include the option of mixing description with induction.
    – Werner
    Oct 7, 2014 at 0:44
3

You can obtain what you want and automatic numbering of items within enumerate-like environments, with enumitem:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{enumitem}

\newlist{induction}{enumerate}{4}%% up to 4 levels for this new list
\setlist[induction]{wide=0pt, leftmargin =3em}
\setlist[induction, 1]{label=\bfseries\boldmath$A\textup{-induction}${,} $a\arabic* $:}
\setlist[induction, 2]{label=\bfseries\boldmath$B\textup{-induction}${, }$b\arabic* $:}

\begin{document}

Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

\begin{induction}%{A}
  \item Part~$a1$ of the induction proof.
  \item Part~$a2$ of the induction proof. This one needs a further induction argument over~$B$.
  \begin{induction}%{B}
    \item Part~$b1$ of the induction proof. This part of the induction proof can be very very long.
  \end{induction}
\end{induction}

\end{document} 

enter image description here

You must log in to answer this question.

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