GeneralLabel and reference issue

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
crod
Posts: 1
Joined: Fri Aug 03, 2012 1:04 am

Label and reference issue

Post by crod »

Hello fellow latex users.

I have a problem regarding the cross referencing of my images. I want to include the section number. Say for instance I write \label{fig:image} AFTER the \caption tag in a inserted image. I reference it and get the number of my figure to 4. But if I want to include the section number aswell eg instead of just figure 4, I want figure 11-4 denoting section 11 figure 4 in that section.

Any ideas?

//Christian

Recommended reading 2024:

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

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

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Label and reference issue

Post by kaiserkarl13 »

If you just want to include a reference to the section number, then

Code: Select all

\section{my section header} \label{sec:mysec}
will produce a label such that \ref{sec:mysec} will return its number.

If, instead, you want all figure numbers to automatically be numbered N-M, where N is the section number and M is the figure number, try

Code: Select all

\numberwithin{figure}{section}
You'll need the amsmath package.

The default is to separate them by periods. If you want hyphens, you'll have to redefine \thefigure, like so:

Code: Select all

\renewcommand{\thefigure}{\thesection-\arabic{figure}
This is basically what \numberwithin does anyway.
Post Reply