0

I found this question Adding some common text to enumerated description lists to be the closest:

\documentclass{scrbook}

\usepackage{enumitem}
\newcounter{descriptcount}
\newlist{enumdescript}{description}{1}
\setlist[enumdescript,1]{%
  before={\setcounter{descriptcount}{0}%
          \renewcommand*\thedescriptcount{\arabic{descriptcount}}},
        font={\bfseries\stepcounter{descriptcount}Case \thedescriptcount,~}
}

\begin{document}

\begin{enumdescript}
   \item item one
   \item item two
   \item[Some Text] item three
   \item item four
   \item item five
\end{enumdescript}
\end{document}

enter image description here


The only difference, it that I would like to put the number after the custom text, and not before, i.e., instead of doing:

Case 1, item one
Case 2, item two
Case 3, Some Text item three
Case 4, item four
Case 5, item five

I would like to do:

\begin{enumdescript}
   \item[Some first] item one
   \item[Some second] item two
   \item[Some third] item three
   \item[Some forth] item four
   \item[Some Fifth] item five
\end{enumdescript}
Some first 1) item one
Some second 2) item two
Some third 3) item three
Some forth 4) item four
Some fitth 5) item five

Related questions:

  1. Illegal parameter number in definition of \enit@before. You meant to type ## instead of #, right?
  2. How to fix Illegal parameter number in definition of a new Tikz command?
  3. Enumerated description list
  4. Intertext like command in enumerate environment?
  5. Adding some common text to enumerated description lists
  6. Optional argument to \item in enumitem list
  7. Insert a space after a command: {}, vs \ , vs \space
  8. What is the difference in citing/referencing with or without tilde?
  9. What commands are there for horizontal spacing?
  10. When should I use non-breaking space?
  11. Difference between control space and non-breaking space

Other questions:

  1. Difference between control space and non-breaking space
  2. Combining newcommand and renewcommand with optional arguments
  3. When to use \LetLtxMacro?
  4. How to redefine the caption command with optional arguments
  5. Optional parameter in newcommand
  6. Creating new counter formats on-the-fly with enumitem's \AddEnumerateCounter*
  7. correct usage of \@namedef and \@nameuse
  8. What is the difference between \let and \def?
  9. enumitem package and description lists
  10. How do I change the `enumerate` list format to use letters instead of the default Arabic numerals?
  11. Redefine the bullets of the enumerate environment
  12. LaTex enumitem - controlling alignment of items by level
  13. How to remove space at the start of inline enumitem itemized list?
3

Here is a solution: I create a new environment, which first redefines the \makedescriptionlabel command, then enters a description environment.

\documentclass{scrbook}

\usepackage{enumitem}
\usepackage{xparse}
\newcounter{descriptcount}

\NewDocumentEnvironment{enumdescript}{O{}}{%
    \setcounter{descriptcount}{0}%
    \renewcommand*\descriptionlabel[1]{%
      \stepcounter{descriptcount}%
      \normalfont\bfseries ##1~\arabic{descriptcount})%
    }%
    \description%
  }%
  {\enddescription}

\begin{document}

\begin{enumdescript}
   \item[Some first] item one
   \item[Some second] item two
   \item[Some third] item three
   \item[Some fourth] item four
   \item[Some Fifth] item five
\end{enumdescript}

\end{document} 

enter image description here

  • What is this O{} passed as argument to \NewDocumentEnvironment? Or where I can find the documentation for this \NewDocumentEnvironment? I keep searching but I cannot find it. – user Oct 14 at 3:34
  • I just found it. It is from the xparse package: O As for o, but returns (default) if no value is given. Should be given as O{(default)} – user Oct 14 at 3:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.