Text Formatting\ref with tables

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
bebbo
Posts: 3
Joined: Fri Aug 28, 2009 10:47 am

\ref with tables

Post by bebbo »

Hallo together,
i have some problems with references to tables.
The numbering is working as i want it for figures and tables. Therefore i use this

Code: Select all

\numberwithin{figure}{section}
\numberwithin{table}{section}
in the preamble

And if I want to reference to a figure it looks like this in the document
Text ... \ref{fig:sapexceldatei}

Code: Select all

\begin{figure}
\centering
\includegraphics[width=12cm]{bilder/exceldimaccount.eps}
\caption{Excel-Datei für Dateneingabe für Dimensionen}
\label{fig:sapexceldatei}
\end{figure}
and this I use again in the preamble

Code: Select all

\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}
\makeatletter \@addtoreset{figure}{section} \makeatother
Now I tried the same for tables with

Code: Select all

\renewcommand{\thetable}{\arabic{section}.\arabic{table}}
\makeatletter \@addtoreset{table}{section} \makeatother
but it is not returning the correct result. \ref{} will be replace with the number of subsection there and not with {section}{table}.

What am i doing wrong? Thanks for any help,
Martin

Recommended reading 2024:

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

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

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

\ref with tables

Post by gmedina »

Hi,

the problem can be caused by misplacement of the \label command; please make sure that the \label command is placed after the corresponding \caption command in the figure and table environments.

If the problem persists, please post a minimal working example showing the undesired behaviour.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bebbo
Posts: 3
Joined: Fri Aug 28, 2009 10:47 am

Re: \ref with tables

Post by bebbo »

Thanks for you answer. But as a matter of fact. The placement of the \label command seems not to change anything. Even if I put it after the \caption command, the problem stays.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: \ref with tables

Post by gmedina »

Then, please do as I suggested before and post a minimal working example (MWE); otherwise we cannot provide effective help (instructions on how to build such a MWE can be found following the link I provided in my previous reply).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bebbo
Posts: 3
Joined: Fri Aug 28, 2009 10:47 am

Re: \ref with tables

Post by bebbo »

Ok thanks for your help. Now it seems to work. \label after \caption.
Post Reply