0
    \documentclass{article}
    \usepackage{blindtext}
    \usepackage{graphicx}
    \usepackage[utf8]{inputenc}
    \usepackage{multirow}
    \usepackage{siunitx}
    \usepackage{caption}
    \usepackage{subcaption}
    \usepackage{subfig}
    \usepackage{hyperref}
    \usepackage[section]{placeins}
    \usepackage[margin=1.5in,footskip=0.3in]{geometry}
    \usepackage{wrapfig}
    \usepackage[table,xcdraw]{xcolor}
    \usepackage{circuitikz}
    
    \begin{document}
    
    [...]
    
    \begin{equation}\label{eq:cape}
    \centering
    t_{rise_{A}} = t_{rise_{B}} \times V_A / V_B
    \end{equation}
    
    [...]

    Inoltre sono stati misurati dei tempi di salita  $t_{rise}$  in linea con quanto previsto dalla relazione \ref{eq:cape}.
    \end{document}

This is my code. The compiler doesn't read the reference and it gives as error an undefined control sequence: "\reserved@b ->\T@ref

l.186 ...con quanto previsto dalla relazione \ref{
                                                  eq:cape}. Infine è stato ...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
". 
7
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Mar 24, 2022 at 9:39
  • Welcome to TeX.SX! Please replace your first [...] with \begin{document} and add \end{document} at the end, so that the example becomes compilable. I get several errors, first among them is: Package subcaption Error: This package can't be used in cooperation with the subfig package. In fact, when I remove \usepackage{subfig}, all errors disappear and the \ref works properly.
    – marquinho
    Mar 24, 2022 at 9:42
  • 1
    Thank you @marquinho, the problem was with '''subfig'''.
    – James
    Mar 24, 2022 at 10:16
  • 1
    Unrelated: what's \centering doing inside equation?
    – egreg
    Mar 24, 2022 at 11:51
  • 2
    @marquinho On the other hand, subfig is compatible with several document classes that aren't compatible with caption (notably revtex4-2 and IEEEtran), so it still has use cases.
    – egreg
    Mar 24, 2022 at 11:53

1 Answer 1

3

Pruning your code to get a proper Minimal Working Example, we find that the following reproduces your error:

\documentclass{article}
%\usepackage[utf8]{inputenc}   % default since 2018, so probably redundant
\usepackage{caption}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{hyperref}

\begin{document}

\begin{equation}\label{eq:cape}
x<1
\end{equation}

\begin{equation}\label{eq:cape2}
x>0
\end{equation}

Inoltre si osservino le relazioni \ref{eq:cape} e \ref{eq:cape2}.

\end{document}

The code doesn't compile properly: The first of several errors is

Package subcaption 
Error: This package can't be used in cooperation with the subfig package.

In fact, the package subfig is very old and appears not to have been maintained since 2005 (!). This might be the reason why subfig is not set up to work with hyperref properly.

EDIT: @egreg points out the following: "subfig is compatible with several document classes that aren't compatible with caption (notably revtex4-2 and IEEEtran), so it still has use cases."

Also, the maintainer(s) of subcaption have added the above warning that subcaption and subfig are incompatible. (Note that subcaption is actively maintained.)

If we heed this warning and disable subfig, the code compiles and the references are processed properly.

\documentclass{article}
%\usepackage[utf8]{inputenc}   % default since 2018, so probably redundant
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{hyperref}

\begin{document}

\begin{equation}\label{eq:cape}
x<1
\end{equation}

\begin{equation}\label{eq:cape2}
x>0
\end{equation}

Inoltre si osservino le relazioni \ref{eq:cape} e \ref{eq:cape2}.

\end{document}

example works with two equations

To sum up:

  • If you need subfigures (subfloats) in your document, you should avoid subfig, but subcaption is a better choice. Ultimately, this depends on your needs (not shown in this MWE).

  • subcaption requires pkg caption, which might be a problem with some document classes (remember egreg's hint).

  • note that in general, \usepackage{hyperref} must be loaded last in your preamble, because hyperref has to adjust itself to all your other packages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .