'Create my own environment with itmize without countering (latex)
I want to create a "recurrence" environment (to create my math lessons). I want this code:
latex
\begin{recurrence}
\Item $\forall n \in \mathbb{N}, P_n$\\
\item Initialisation\\
\item Heredity\\
\item $\forall n \in \mathbb{N}, P_n$\\
\end{recurrence}
to give:

Solution 1:[1]
Personally, I would use a description and manually write the labels
\begin{description}
\item[Prove:] $\forall n \in \mathbb{N}, P_n$
\item[Initialisation:] Initialisation
\item[Heredity:] Heredity
\item[Conclusion:] $\forall n \in \mathbb{N}, P_n$
\end{description}
but if you insist on your syntax you could jump through some hopes and do:
\documentclass{article}
\usepackage{amsfonts}
\usepackage{getitems}
\makeatletter
\def\doitem#1{%
\ifnum\thecurrentitemnumber=1%
\item[Prove:]
\fi%
\ifnum\thecurrentitemnumber=2%
\item[Initialisation:]
\fi%
\ifnum\thecurrentitemnumber=3%
\item[Heredity:]
\fi%
\ifnum\thecurrentitemnumber=4%
\item[Conclusion:]
\fi%
#1}%
\makeatother
\usepackage{environ}
\NewEnviron{recurrence}{%
\expandafter\gatheritems\expandafter{\BODY}%
\gathereditem{0}%
\begin{description}%
\loopthroughitemswithcommand{\doitem}%
\end{description}
}
\begin{document}
\begin{recurrence}
\item $\forall n \in \mathbb{N}, P_n$
\item Initialisation
\item Heredity
\item $\forall n \in \mathbb{N}, P_n$
\end{recurrence}
\end{document}
Solution 2:[2]
An easy version using a tabular-like environment:
\documentclass{article}
\usepackage{amssymb,array}
\begin{document}
\begin{tabular}{>{\bf}ll}
Prove~: & $\forall n\in\mathbb{N}$, $P_n$\\
Initialisation~: & Initialisation\\
Heredity~: & Heredity\\
Conclusion~: & $\forall n\in\mathbb{N}$, $P_n$\\
\end{tabular}
\end{document}
The code >{\bf}ll gives a first left-aligned column with contents in bold (>{\bf}l) and a second left-aligned column (l). The tilde characters ~ only serve to implement french spacing (if you really want it, othewise remove them).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | samcarter_is_at_topanswers.xyz |
| Solution 2 | MattAllegro |


