GeneralReferencing the section in which a label appears

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kidd
Posts: 2
Joined: Wed Jun 17, 2009 10:46 am

Referencing the section in which a label appears

Post by kidd »

I created a new counter \newcounter{example} which resets at the start of each new section. I want to reference to this counter throughout my document, so I use \refstepcounter{counter} \label{x} and reference by \ref{x}. But then I am only given the counter number, say 2, instead of 3.2 (if it is in Section 3), which is what I desire.

There is a command \pageref{x}, which gives the page number in which a label appears. Something similar which gives the section number in which a label appears would be satisfactory.

Any suggestions?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Referencing the section in which a label appears

Post by Stefan Kottwitz »

Hi kidd,

welcome to the board!
Redefine \thecounter and use \thesection. Have a look at Manipulating the way counters are printed.

Stefan
LaTeX.org admin
kidd
Posts: 2
Joined: Wed Jun 17, 2009 10:46 am

Re: Referencing the section in which a label appears

Post by kidd »

Got it working now, thanks Stefan.

Martin
Post Reply