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?
General ⇒ Referencing the section in which a label appears
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
Hi kidd,
welcome to the board!
Redefine \thecounter and use \thesection. Have a look at Manipulating the way counters are printed.
Stefan
welcome to the board!
Redefine \thecounter and use \thesection. Have a look at Manipulating the way counters are printed.
Stefan
LaTeX.org admin
Re: Referencing the section in which a label appears
Got it working now, thanks Stefan.
Martin
Martin