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.

When using \label and \ref, can I get the \ref to display as a letter instead of a number (so if \ref is 3, it will print c instead)?

share|improve this question
4  
It's quite unclear what you want: if the item to which you are referring is numbered 3, then the reference should show that number. –  egreg Feb 10 '12 at 0:02
add comment

2 Answers

up vote 6 down vote accepted

The default counter representation is \arabic (or numerical). If you want a counter to be referenced alphabetically rather than numberically, then you can redefine the representation using

\newcounter{mycount}
\renewcommand{\themycount}{\alph{mycount}}

\the<counter> refers to the representation of the counter. So you're essentially redefining it from being displayed as \arabic to \alph.


If you don't care about what is displayed and how it's referenced, then the following will work:

enter image description here

\documentclass{article}
\usepackage{fmtcount}% http://ctan.org/pkg/fmtcount
\begin{document}
\setcounter{section}{2}
\section{This is a section}\label{ref:section}
This is section~\ref{ref:section}. This is section~\aaalphnum{\ref{ref:section}}.
\end{document}

The fmtcount package can easily be used to convert between different number formats.

share|improve this answer
    
I was wondering if there were a way to do this other than to counter names. –  Ryan Reich Feb 10 '12 at 0:11
add comment

Any counter can be printed alphabetically using the command \alph{counter}. You can make that work with \label and \ref by redefining the counter you are referencing to print things that way. For example, to refer to sections by letter, write:

\documentclass{article}
\renewcommand\thesection{\alph{section}}
\begin{document}
 \section{A section}
 \label{s:a section}

 In section \ref{s:a section}\dots
\end{document}

Of course, all your sections will be "lettered" rather than numbered; however, it is very confusing to refer to a numbered item by letter, so this is probably what you should do anyway if you want references to print letters.

share|improve this answer
add comment

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.