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.

I'm having difficulties with a list where the label is defined as a command. Below is a minimal example:

\documentclass[a4paper, 11pt]{article}

\usepackage{enumerate}

\newcommand{\myLabel}{1)}

\newenvironment{myList}%
  {%
    \begin{enumerate}[\myLabel]
  }
  {%
    \end{enumerate}
  }



\begin{document}

\begin{myList}
  \item Item 1
  \item Item 2
  \item Item 3
\end{myList}

\end{document}

When I compile this, I get the following warning

LaTeX Warning: The counter will not be printed.
         The label is: \myLabel  on input line 19.

and the generated list only has 1, 1, 1 as labels instead of 1, 2, 3.

Any idea how to work around this problem?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

You have to expand \myLabel before using it

\documentclass[a4paper, 11pt]{article}

\usepackage{enumerate}
\newcommand\myLabel{1)}

\newenvironment{myList}%
  {\expandafter\enumerate\expandafter[\myLabel]}
  {\endenumerate}

\begin{document}

\begin{myList}
  \item Item 1
  \item Item 2
  \item Item 3
\end{myList}

\end{document}
share|improve this answer
    
Ah thanks! That fixed it. =) –  gablin Aug 18 '11 at 8:57
add comment

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.