Menu

#92 \ref returns section number instead of table number

KOMA-Script 3.47
closed
\ref (1) bug (35)
2025-08-25
2025-08-25
dila
No

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}

Discussion

  • Markus Kohm

    Markus Kohm - 2025-08-25
    • labels: \ref --> \ref, bug
    • status: open --> closed
    • assigned_to: Markus Kohm
     
  • Markus Kohm

    Markus Kohm - 2025-08-25

    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 add

    \usepackage[disablepatch=caption]{tocbasic}
    

    to 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:

    Package caption Warning: The type was already set to `\@captype '
    

    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
    • dila

      dila - 2025-08-25

      Thanks.

      That almost certainly means that subcaption, which the original document is currently using, is no longer maintained, too.

       
      • Markus Kohm

        Markus Kohm - 2025-08-25

        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]


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.