[Tugindia] Want help in creating counters

Radhakrishnan CV cvr at river-valley.org
Sun Jul 11 18:17:48 CEST 2010

On Sun, Jul 11, 2010 at 8:32 PM, Kannan Moudgalya <kannan at iitb.ac.in> wrote:
> Dear All,
> For an open source software project based on standard textbooks, I would
> like to modify how the counters are created in LaTeX.
> Normally, counters have numbers.  These are incremented automatically.  One
> can increase or decrease these numbers at will.
> What I want to do is to assign a string to the counter, inside the
> environment that I defined.  In other words, I want to assign an arbitrary
> string to the counter inside the environment.  The value assigned should be
> remembered and be available for cross referencing, in the table of contents
> of that environment, etc.  Actually, the word counter is a misnomer here - I
> do not want it count anything - just to accept the value that I assign.

You just need to define the \@currentlabel as your custom string so
that it can be used for cross referencing.  Does the code given below
serve your purpose?

%------- Begin -----------





\section{This is first section}
\curlabel{string 1}


Testing cross reference: \ref{sec2}. Name ref: \nameref{sec2}.


\section{This is second section}
\curlabel{string 2}


% -------- End -------

Best regards


More information about the tugindia mailing list