\ref returns section number instead of table number
KOMA-Script is a bundle of versatile LaTeX classes and packages
Brought to you by:
kohm
In a large, complex document references to tables only show ??, yet the links created by hyperref
work. In an attempt to debug this I made a MWE and found that with scrartcl
references to tables show the section number, while with article
they show the table number, see code below. Is that a bug, or have I forgotten how ref
works in KOMA-Script? I am using TeX Live 2025 with koma-script 76100 (3.46).
\documentclass{scrartcl}
\begin{document}
\begin{table}
\centering%
\caption{Caption}%
\label{aefgaert}%
\begin{tabular}{ll}
A & B\\
1 & 2
\end{tabular}
\end{table}
\begin{table}
\centering%
\caption{Caption}%
\begin{tabular}{ll}
A & B\\
1 & 2
\end{tabular}
\end{table}
\section{Section 1}
\section{Section 2}
\begin{table}
\centering%
\caption{Caption}%
\label{fghhfgdfghr}%
\begin{tabular}{ll}
A & B\\
1 & 2
\end{tabular}
\end{table}
See \ref{aefgaert}. See \ref{fghhfgdfghr}.
\end{document}
Thank you for the report.
It's a bug and I've fixed it in [r4203]. As a workaround you can move the
\label
command inside the\caption
argument. Another workaround would be to addto the document preamble, but this would also disable several features like option
captions=tableabove
(which you should use in your example).But note, that with the new fix, package
caption
under some circumstances throws additional warnings:These warnings can be ignored. Unfortunately package
caption
is no longer maintained and so I cannot ask the maintainer to remove these warnings.For other
caption
warnings see also [wiki-en:Warning_captionUnknownClass] (English) resp. [wiki-de:Warning_captionUnknownClass] (German).Related
Commit: [r4203]
Wiki (Deutsch): Warning_captionUnknownClass
Wiki (English): Warning_captionUnknownClass
Last edit: Markus Kohm 2025-08-25
Thanks.
That almost certainly means that
subcaption
, which the original document is currently using, is no longer maintained, too.Not by Axel Sommerfeldt. He discontinued development of all his packages.
But with [r4203] at least the combination of
subcaption
and KOMA-Script classes works again – despite the shown warning message.Related
Commit: [r4203]