# Refer to customized enumerate counter

## Background

I'm typesetting a list of conditions for a certain mathematical object. There are three conditions. Later on I wish to provide an equivalent condition for the third. Therefore, it would be nice to have this kind of numbering:

c) condition 1

b) condition 2

c) condition 3

while later on there would be

c') condition 3 (alternative)

My idea was to use a \label{c} for the original condition and write

\item[\ref{c}]\label{c-prime} ...


and it hoping it would be able to refer to c') this way. But \ref{c-prime} results in the number of the definition, not in the enumerate counter.

## Solution

I've got a solution, based on a hard-coded starting point for the counter and fixed layout. Using enumitem I can write

\begin{enumerate}[label=\alph*'),ref=(\alph*'),start=3]


and everything works smoothly

## Question

There are some drawbacks:

• I have to hand pick the starting point for the counter, rendering it impossible to automatically change the ordering;
• the formatting for labels and references is hard-coded, if I change the global format I still have to adapt it locally.

What can I do to make this more flexible?

I am aware this is a rather academic question as it already works, but I'm curious

-
A "costumized" counter is one with a costume on? – Will Robertson Dec 2 '10 at 6:33
No, it's one who has according to Oxford dictionary been "modified to suit a particular individual or task." – Pieter Dec 2 '10 at 6:49
I tried to generalize this to having altconditions in two different places within my LaTeX document, but am having problems getting it to work: tex.stackexchange.com/questions/221020/… – EthanAlvaree Jan 7 at 1:02

The enumitem package gives you lots more—you can create enumerate-like list environments and set their format globally. Then you can use a counter to save the value of the current item to feed to start later on.

\documentclass{article}
\usepackage{lipsum}% just for blind text
\usepackage{enumitem}
\newlist{conditions}{enumerate}{1}
\newlist{altconditions}{enumerate}{1}
\setlist[conditions]{label=\alph*),ref=(\alph*)}
\setlist[altconditions]{label=\alph*$'$),ref=(\alph*$'$)}
\newcounter{favoritecondition}
\begin{document}

\lipsum[1]

\begin{conditions}
\item condition 1
\item condition 2
\item condition 3\label{c}\setcounter{favoritecondition}{\value{conditionsi}}
\item condition 4
\end{conditions}

\lipsum[2]

An alternative to condition \ref{c} is

\begin{altconditions}[start=\value{favoritecondition}]
\item\label{c-prime} condition 3 alternative
\end{altconditions}

We leave as an exercise to the reader that \ref{c} and \ref{c-prime} are equivalent.
\end{document}

-
Good answer; the key is the line \setcounter{favoritecondition}{\arabic{conditionsi} although I think \value would strictly be better than \arabic here (even though both work). – Will Robertson Dec 2 '10 at 6:35
@Will Robertson: I agree with your opinion but I couldn't get \value to work for me. But I just made the change in my copy and it worked fine, so I must have been doing something else wrong. I'll edit. – Matthew Leingang Dec 2 '10 at 10:40
Thanks for the great answer! If you can help, I tried modifying this code to allow for altconditions in two different places within the document, and I can't quite get it to work: tex.stackexchange.com/questions/221020/… – EthanAlvaree Jan 6 at 23:49
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7712966799736023, "perplexity": 1511.6731457666413}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-48/segments/1448398464536.35/warc/CC-MAIN-20151124205424-00348-ip-10-71-132-137.ec2.internal.warc.gz"}