3

Is there an easy way to use item label as if they were typed directly in the code (see the 2nd formatting in my MWE)? If it is not the case, I will use another way to acheive my goal.

\documentclass[12pt]{article}

\usepackage{enumitem}

\newcommand\recproof[1]{
    \bfseries
    \ifnum#1=1
        Initialization.
    \else
        \ifnum#1=2
            Heredity.
        \else
            Conclusion.
        \fi
    \fi
}

\setlength\parindent{0cm}


\begin{document}

Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\begin{enumerate}[label=\protect\recproof{\value*}]
    \item $n = 0$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

    \item $n \Rightarrow n + 1$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

    \item $\forall n$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...
\end{enumerate}

Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\textbf{Initialization.} $n = 0$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\textbf{Heredity.} $n \Rightarrow n + 1$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\textbf{Conclusion.} $\forall n$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\end{document}

1 Answer 1

2

You want wide=0pt.

You also want less clumsy code.

\documentclass[12pt]{article}

\usepackage{enumitem}

\ExplSyntaxOn
\NewDocumentCommand{\recprooflabel}{m}
 {
  \int_case:nnF { #1 }
   {
    {1}{Initialization}
    {2}{Heredity}
    {3}{Conclusion}
   }
   {????}   % Some error to raise here?
 }
\ExplSyntaxOff

\NewDocumentEnvironment{recproof}{O{}}
 {\begin{enumerate}[label=\bfseries\recprooflabel{\value*}.,wide=0pt,#1]}
 {\end{enumerate}}
 

\begin{document}

Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\begin{recproof}
  \item $n = 0$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
  bla, bla, bla, bla, bla, bla, bla...

  \item $n \Rightarrow n + 1$, bla, bla, bla, bla, bla, bla, bla, bla, 
  bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

  \item $\forall n$, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
  bla, bla, bla, bla, bla, bla, bla, bla...
\end{recproof}

Bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, 
bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla, bla...

\end{document}

enter image description here

The recproof environment has an optional argument for additional enumitem keys.

1
  • Thanks for the customized environment, and the cleaner code. I didn't read the whole doc of enumitem, I plead guilty about the wide option. Thanks for that!
    – projetmbc
    Commented Nov 11, 2022 at 21:33

You must log in to answer this question.

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