[Tugindia] Want help in creating counters
Radhakrishnan CV
cvr at river-valley.org
Tue Jul 13 10:19:04 CEST 2010
On Mon, Jul 12, 2010 at 7:05 PM, Kannan Moudgalya <kannan at iitb.ac.in> wrote:
>
> Radhakrishnan CV wrote:
>>
>> I am slightly confused about the TOC requirements. Can you please send
>> me a small example file off list to me? That will be very helpful to
>> understand the issues involved.
>
> If I build the table of contents for the document that you sent in your
> previous mail, the sections numbers appear as 1 and 2. In their place, I
> want string 1 and string 2, created through the command \curlabel.
Ah, you need to include the redefinition of the counter in the
definition of \curlabel. Please see below:
% --------- Begin -----------
\documentclass{article}
\usepackage{times,lipsum}
\usepackage[colorlinks,bookmarksopen]{hyperref}
\makeatletter
\def\curlabel#1{\def\thesection{#1}\def\@currentlabel{#1}}
\makeatother
% But this has the drawback of including \thesection in a hard way into
% \curlabel. You need to parametrize this too, if you want to use it for
% other environents as well. That is why, I asked for a minimal
% example, so that we can design the macro in a crafty way.
\begin{document}
\tableofcontents
\curlabel{One}
\section{This is first section}
\label{sec1}
\lipsum[1]
Testing cross reference: \ref{sec2}. Name ref: \nameref{sec2}.
\clearpage
\curlabel{Two}
\section{This is second section}
\label{sec2}
\lipsum[2]
\ref{sec1}.
\end{document}
% --------- End -------------
> Thanks a lot for your help. Regards.
Welcome, Sir.
Best regards
--
Radhakrishnan
More information about the tugindia
mailing list