5

I am facing a problem with the use of list command. I need to generate lists with specific numbering systems and then cross-reference them in different parts. By using the list command I am able to create lists with the correct system of numbering. However when I use the \ref command to refer back to them it only prints the Arabic numeral equivalent of the entry instead of the numbering system I have used. Is there any way I could resolve this so that I could get the correct cross-reference inserted.

To illustrate my problem I have written a short code for this which states my problem too.


\documentclass[12pts,a4paper]{report}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{color}

\newcounter{sections}
\newcounter{sub-section}
\newcounter{clause}
\newcounter{sub-clause}
%this is the counter command  

\title{Problem with cross-referencing using list command}

\author{Shubho Roy}

\begin{document}
\maketitle


\begin{list}{(\arabic{sub-section})}{\usecounter{sub-section}}
\item This is some text in sub-section which is using Arabic
  numerals. \label{sub-sec:arabic_numerals}
\begin{list}{(\alph{clause})}{\usecounter{clause}}
\item This is a clause which is using alphabetical numbering
\label{clause:alphabetical}
\begin{list}{(\roman{sub-clause})}{\usecounter{sub-clause}}
\item This is a sub-clause using roman numbering. \label{sub-clause:roman_numerals}
\end{list}    
\end{list}    
\end{list}


\begin{itemize}
\item If I refer to the sub-section using the ref command I get a correct
reference like this: \ref{sub-sec:arabic_numerals}

\item However when I refer to the clause list which is a nested list and
uses alphabetical numbering I still get Arabic numbering as reference:
\ref{clause:alphabetical}. I would like this to be (a)

\item The same problem is available in the case of sub-clause list where I
should get roman numerals but I still get the Arabic numeral:
\ref{sub-clause:roman_numerals}. I would like this to be (i)

\end{itemize}

\end{document}

The problem arising when I use label to reference to different parts of the document.

The hyperref command sends it to the correct link but the numbering printed is always in Arabic while I have used other numbering systems for this. Any help!!

2 Answers 2

3

You must redefine the \the<counter> commands. Also you should avoid nonletters in counter names, it makes such redefinitions arkward. Use subclause instead of sub-clause:

\renewcommand\theclause{(\alph{clause})}
\renewcommand\thesubclause{(\roman{subclause})}
2

The enumitem package works well for this sort of set-up. Create new types of list with e.g. \newlist{clause}{enumerate}{4}; this is a list based on the usual enumerate environment, but called clause and automatically gets a new counter clause associated to it. You customize the formatting of the label by \setlist[clause]{label=(\alph*)} where \alph* is the command corresponding to \alph. Putting this together your example becomes:

\documentclass[12pt,a4paper]{report}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{color}
\usepackage{enumitem}

\newlist{sub-section}{enumerate}{5}
\setlist[sub-section]{label=(\arabic*)}

\newlist{clause}{enumerate}{4}
\setlist[clause]{label=(\alph*)}

\newlist{sub-clause}{enumerate}{3}
\setlist[sub-clause]{label=(\roman*)}

\title{Problem with cross-referencing using list command}

\author{Shubho Roy}

\begin{document}
\thispagestyle{empty}

\begin{sub-section}
\item This is some text in sub-section which is using Arabic
  numerals. \label{sub-sec:arabic_numerals}
\begin{clause}
\item This is a clause which is using alphabetical numbering
\label{clause:alphabetical}
\begin{sub-clause}
\item This is a sub-clause using roman numbering. \label{sub-clause:roman_numerals}
\end{sub-clause}    
\end{clause}    
\end{sub-section}

\begin{itemize}
\item If I refer to the sub-section using the ref command I get a correct
reference like this: \ref{sub-sec:arabic_numerals}

\item However when I refer to the clause list which is a nested list and
uses alphabetical numbering I still get Arabic numbering as reference:
\ref{clause:alphabetical}. I would like this to be (a)

\item The same problem is available in the case of sub-clause list where I
should get roman numerals but I still get the Arabic numeral:
\ref{sub-clause:roman_numerals}. I would like this to be (i)

\end{itemize}

\end{document}

Sample output

You must log in to answer this question.

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