Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This is a follow-up question to Nested enumerate labels with parent label appended plus a single set of enclosing parentheses

First and foremost, sorry for my English, I'm learning it currently.

Exists any form to set first the numbers, and then enclose it between parenthesis, inside the local environment? I'm making my personal labelist environment, and I've the same problem. First my intended output and next my actual code:

(A) Item 1
  (A.1) Other item
  (A.2) Other item
(B) Item 2
  (B.1) More items.
     (B.1.1) Third level.
     (B.1.2) Other third-level item.
(C) And so on

And here the code of my actual custom environment:

\newcounter{list@depth}
\setcounter{list@depth}{0}

\newenvironment{labelist}{%

   \stepcounter{list@depth}

   \ifnumcomp{\value{list@depth}}{=}{0}{
      \begin{enumerate}[label=\Alpha*]
   }{
      \begin{enumerate}[label*=.\arabic*]
   }

   %% Here enclose the actual format between parenthesis

 }{%
    \ifnumcomp{\value{list@depth}}{=}{1}{
       \setcounter{list@depth}{0}
    }{
        \addtocounter{list@depth}{-1}
    }

    \end{enumerate}
 }

With this code, only I get outputs like this:

A Item 1
  A.1 Other item
  A.2 Other item
B Item 2
  B.1 More items.
     B.1.1 Third level.
     B.1.2 Other third-level item.
C And so on

Because I need only to add parenthesis enclosing labels (an "a posteriori" format).

share|improve this question
    
Could you give an example of what the output should look like? I haven't understood what you want. –  Seamus Nov 1 '12 at 12:11
    
Finished! Perhaps so is easier to understand my problem. –  Peregring-lk Nov 1 '12 at 13:10
    
Simply: label=(\Alpha*) –  Seamus Nov 1 '12 at 15:56
    
@Seamus that won't work- see my solution –  cmhughes Nov 1 '12 at 15:56
    
I need exactly something like "\actuallabel <- (\actuallabel)", affecting only to the actual environment (without affecting the entire document). –  Peregring-lk Nov 1 '12 at 16:21

1 Answer 1

up vote 6 down vote accepted

Here's a solution using the enumitem package.

enter image description here

My first attempt used things such as label*=(\Alph*) but of course this produced things such as

(A)(A)

which is not what is wanted.

Below I've created a newlist environment labelist using the \newlist command, and used the \setlist command combined with the counters labelisti (first level), labelistii (second level), labelistiii (third level).

\documentclass{article}

\usepackage{enumitem}
\newlist{labelist}{enumerate}{5}

\setlist[labelist,1]{label*=(\Alph*)}
\setlist[labelist,2]{label=(\Alph{labelisti}.\arabic{labelistii})}
\setlist[labelist,3]{label=(\Alph{labelistii}.\arabic{labelistii}.\arabic{labelistiii})}
\setlist[labelist,4]{label=(\Alph{labelistii}.\arabic{labelistii}.\arabic{labelistiii}.\arabic{labelistiv})}
\setlist[labelist,5]{label=(\Alph{labelistii}.\arabic{labelistii}.\arabic{labelistiii}.\arabic{labelistiv}.\arabic{labelistv})}
\begin{document}


\begin{labelist}
    \item First level
    \begin{labelist}
        \item Second level
        \item Second level
        \begin{labelist}
            \item Third level
            \item Third level
        \end{labelist}
    \end{labelist}
    \item First level
    \begin{labelist}
        \item Second level
        \item Second level
         \begin{labelist}
             \item Third level
             \item Third level
             \begin{labelist}
                    \item Fourth level
                    \item Fourth level
                    \begin{labelist}
                            \item Fifth level
                            \item Fifth level
                        \end{labelist}
                \end{labelist}
         \end{labelist}
    \end{labelist}
\end{labelist}
\end{document}
share|improve this answer
    
But this solution has two problems that I want to avoid. First, this is "static", in the sense that you have to know the maximun required depth and to configure the label for each possible depth. My example had depth 3 but it was only an example. Second, this configuration concerns to all document. I want this customization only to this specific environment (labelist). –  Peregring-lk Nov 1 '12 at 16:03
    
@Peregring-lk You can use my answer and define as many levels you want. –  egreg Nov 1 '12 at 16:21
    
But I have to write a new setlist line for each new deepth that I need. And also this solution concerns with any enumerate in the document. –  Peregring-lk Nov 1 '12 at 16:25
    
@Peregring-lk I've updated my solution; it now only affects your custom list. I agree that it is somewhat 'static' in the sense that you describe, but from a practical point of view, how deep are your lists going to go? –  cmhughes Nov 1 '12 at 21:37
1  
@Peregring-lk ok, but how would I have known that from your question? In your question you state what your intended output is, and my solution gives that output! –  cmhughes Nov 2 '12 at 16:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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