[Tex/LaTex] Enumerate box environment

enumitem

I want to write a book of close to 300 mathematics exercises. I want to list them in numerical order (and put solutions at the end part of the book).

I think I am gonna use enuitem, however,in normal enuitem, the margin of H of How is equal to that of H of Hi. How can I make the margin of the H of How equal to that of the box of number 1?

enter image description here

Best Answer

Another solution :

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[frenchb]{babel}
\usepackage{enumitem}
\usepackage{xcolor}

\newcommand\twodigits[1]{%
  \ifnum#1<10 0\number#1 \else #1\fi
}

\begin{document}

\begin{enumerate}[label=\fcolorbox{black}{black!15}{\scriptsize H-\protect\twodigits{\arabic*} :}, leftmargin=1.5cm,itemsep=1pt,labelsep=1cm]
  \item Coucou\\
    test
\item Coucou\\
  \hspace*{-1cm}test1
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\item Coucou
\end{enumerate}
\end{document}

enter image description here

Related Question