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.

8
  • 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). Jun 6, 2015 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 6, 2015 at 22:28
  • @PeterGrill I don't need to duplicate the content, just to duplicate a list labels in possibly different order
    – porton
    Jun 6, 2015 at 22:29
  • Instead of describing it, can you post an image of exactly what the desired output should be. Jun 6, 2015 at 22:32
  • @PeterGrill I've added an image with desired output to the question
    – porton
    Jun 6, 2015 at 22:38

1 Answer 1

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}
2
  • Thanks, but (out of pure curiosity) why my code did not work?
    – porton
    Jun 6, 2015 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. :-) Jun 6, 2015 at 23:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .