3

I want an enumerate list be repeated in a different order (for example, a list of two statements and later a list of two proofs: first the second statement proof and then the first statement proof). I expected that the following code would do this, but in some reason it just produces a regular list with "0" strings.

Please help to find and correct my error.

\documentclass[english]{article}

\usepackage{enumitem}
\setlist[enumerate,1]{label=\arabic*$^\circ$.,ref=\arabic*$^\circ$}

\newlist{enumeratex}{enumerate}{5}
\setlist[enumeratex]%
{label=\arabic*$^\circ$.,%
before={\let\olditem=\item\renewcommand\item[1][]{\olditem[#1.]}},%
after={\let\item=\olditem}}

\begin{document}

\begin{enumerate}
  \item \label{a} a
  \item \label{b} b
\end{enumerate}

into

\begin{enumeratex}
  \item[\ref{b}] proof of b
  \item[\ref{a}] proof of a
\end{enumeratex}


\end{document}

The desired output is:

Two lists

Optionally, I want the second list labels to be hyperlinks to first list labels.

porton
  • 1,218
  • Not sure exactly what the desired output is, but I think you need to define a macro for each of the cases. \ref is used to provide a reference (clickable if hyperref is used) -- it does NOT duplicate the content (assuming that is what you are after). – Peter Grill Jun 06 '15 at 22:27
  • @PeterGrill The first list is correct in the output. The second list should be like the first list, but with second item before the first (1 and 2 reversed). – porton Jun 06 '15 at 22:28
  • @PeterGrill I don't need to duplicate the content, just to duplicate a list labels in possibly different order – porton Jun 06 '15 at 22:29
  • Instead of describing it, can you post an image of exactly what the desired output should be. – Peter Grill Jun 06 '15 at 22:32
  • @PeterGrill I've added an image with desired output to the question – porton Jun 06 '15 at 22:38
  • I found one error: It should be \olditem[#1.] rather than \olditem{#1.}, but this way it anyway does not work as expected – porton Jun 06 '15 at 22:49
  • I've corrected in the question the error which I mentioned in the previous comment, but LaTeX produces a wrong result anyway. Please help to find the remaining errors in my code – porton Jun 06 '15 at 22:51
  • Please update the title to some that is specific to your question so that it useful to a wider audience. – Peter Grill Jun 06 '15 at 23:40

1 Answers1

2

Here is an adaptation of Optional argument to \item to appear in brackets after the counter for your case:

enter image description here

Notes:

Code:

\documentclass{article}

\usepackage{enumitem} \usepackage{letltxmacro}

\setlist[enumerate,1]{label=\arabic$^\circ$.,ref=\arabic$^\circ$}

\LetLtxMacro{\OldItem}{\item}

\newcommand{\LabelText}{}% \newcommand{\MyItem}[1][]{% \renewcommand{\LabelText}{#1}\OldItem\leavevmode% }%

\newlist{enumeratex}{enumerate}{5} \setlist[enumeratex]% {label=\noexpand\LabelText.,% before={\let\item\MyItem},% after={\let\item\OldItem}}

\begin{document}

\begin{enumerate} \item \label{a} a \item \label{b} b \end{enumerate}

into

\begin{enumeratex} \item[\ref{b}] proof of b \item[\ref{a}] proof of a \end{enumeratex}

\end{document}

Peter Grill
  • 223,288
  • Thanks, but (out of pure curiosity) why my code did not work? – porton Jun 06 '15 at 23:41
  • @porton: Part of it has to with the \LetLtxMacro as per the link in the question, but not sure I can explain it fully. I only know how to get things to work by referencing previous solutions. My rep is very misleading. :-) – Peter Grill Jun 06 '15 at 23:59