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.

The MWE below, by using paralist package, is supposed to allow \begin{enumerate}[...] where ... is flexible in "some way" (inherits from enumerates above).

\documentclass[a4paper,10pt]{report}

\usepackage{paralist,xargs}

\newcommand\mwe[2]{[{\ref{#1}.}.#2]}

\begin{document}

\newenvironmentx{enumwe}[2][2=1]{%
  \begin{enumerate}\mwe{#1}{#2}%
  %\expandafter\begin\expandafter{\expandafter enumerate\expandafter}\mwe{#1}{#2}%
  \ignorespaces%
}{\end{enumerate}%
  \ignorespacesafterend%
}

\begin{enumerate}[{A}1]

\item \label{one} {\bfseries~Appendix One}

  \begin{enumwe}{one}
    \item text
  \end{enumwe}

\end{enumerate}

\end{document}

However, the commented line seems a wrong attempt, while the MWE typesets wrong.

The expanded result expected would be the following.

\begin{enumerate}[{A}1]
\item \label{one} {\bfseries~Appendix One}
  \begin{enumerate}[{A1.}1.]
    \item text
  \end{enumerate}
\end{enumerate}

I appreciate any help or suggestions.

P.S.: I actually need to expand a macro in the optional parameter to enumerate environment, like \begin{enumerate}[\mwe{...}1.], but it's not working (the ?? occurs everywhere) and this MWE is my approach, but I got stuck with the weird error:

! LaTeX Error: \begin{enumerate} on input line 21 ended by \end{enumerate}.
share|improve this question
1  
You should use the package enumitem instead which is more flexible and allows what you want to achieve. –  Marco Daniel Aug 17 '12 at 16:24
2  
Your profile shows "0% accept rate". I'm sure that you have some good solutions to your questions and you should consider accepting the answers, giving the answerers the site reputation. –  yo' Aug 17 '12 at 16:25
    
@MarcoDaniel: sorry, all the rest of the class core code involved is based on paralist, for now. –  sjbiaga Aug 17 '12 at 16:58

1 Answer 1

up vote 3 down vote accepted

\expandafter only steps over a single token not brace groups, so the simplest thing is to put everything you want to step over into a single token:

\documentclass[a4paper,10pt]{report}

\usepackage{paralist,xargs}

\newcommand\mwe[2]{[{\ref{#1}.}.#2]}

\begin{document}

\newenvironmentx{enumwe}[2][2=1]{%
  \def\temp{\begin{enumerate}}%
  \expandafter\temp\mwe{#1}{#2}%
  \ignorespaces%
}{\end{enumerate}%
  \ignorespacesafterend%
}

\begin{enumerate}[{A}1]

\item \label{one} {\bfseries~Appendix One}

  \begin{enumwe}{one}
    \item text
  \end{enumwe}

\end{enumerate}

\end{document}
share|improve this answer

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.