in this MWE you can see/explore (hopefully, as it does not work for me) that \ref{tab:2}
produces the right label but if you click on it, it will lead you to the \label{tab:1}
.
\usepackage{appendix}
and \begin{appendix} ... \end{appendix}
doesn't helped and as I assume I'm using the \label
at the right position.
EDIT: The solution putting the \numbering behind the hyperref worked well(!), but another error occured in combination with subfigures. The label does not fit anymore, if the \numbering is placed before the include of the subfigure package. I´ve heard that hyperref should be the last included package for some reasons, but as solution for this error: Can I just place the \usepackage{subfigure} after hyperref and \numbering?
\documentclass[12pt,a4paper]{scrartcl}
\KOMAoptions{captions=tableheading}
\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{thumbpdf}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{color}
\usepackage[
colorlinks,
allcolors = blue,
]{hyperref}
\numberwithin{equation}{section}
\numberwithin{figure}{section}
\numberwithin{table}{section}
\begin{document}
\section{sec one}
\begin{table}[!h]
\caption{Tab one}
\label{tab:1}
\centering
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{l|c|c}
1 & 2 & 3\\
\end{tabular}
\end{table}
MWE, more in the appendix, tab \ref{tab:2}
\section{sec two}
\begin{figure}[!h]
\centering
\subfigure[left fig \label{fig:left}]{\includegraphics[width=0.49\linewidth]{default.png}}
\subfigure[right fig \label{fig:right}]{\includegraphics[width=0.49\linewidth]{default.png}}
\caption{left and right fig}
\end{figure}
Next Problem: subfigures \ref{fig:left}
\appendix
\clearpage
\section{appendix}
\subsection{to sec one}
\begin{table}[!h]
\caption{Tab two}
\label{tab:2}
\centering
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{l|c|c}
1 & 2 & 3\\
\end{tabular}
\end{table}
\end{document}
Best Answer
hyperref
supports\numberwithin
, but only if it awares of it. Therefore,\numberwithin
should be used after packagehyperref
.Further remarks:
Option
allcolors
simplifies the setting of the colors to one color with optioncolorlinks
.Package
hyperref
detects driverpdftex
automatically, it does not need to be set explicitly.KOMAScript option
captions=tableheading
fixes the skip settings around table captions, which are used above the table. Thus, the empty line hack can be removed.Full example: