It seems that if you have an underscore in the label name (for example, in fig_logo ), sphinx replaces it with a minus sign ( - this makes sense, since latex sometimes behaves strangely in cases with underscore), while the link is still uses an underscore. For this reason, latex cannot find the tag referenced.
This is the resulting tex code generated by sphinx:
\includegraphics{logo.png} \caption{Example of a figure}\label{index:fig-logo}\end{figure} Reference to logo \hyperref[index:fig_logo]{figure \ref*{index:fig_logo}}
(Note the difference between fig-logo as a label and fig_logo as a link.)
If you replace the underscore with a minus sign, for example
.. _fig-logo: .. figure:: logo.png Example of a figure Reference to logo :num:`figure #fig-logo`
tex code is as follows:
\includegraphics{pandas_bar.png} \caption{Example of a figure}\label{index:fig-logo}\end{figure} Reference to logo \hyperref[index:fig-logo]{figure \ref*{index:fig-logo}}
and in pdf file it is allowed
Logo Link 1
Update
If you don't want to change all the shortcuts you can update numfig : this is enough to add a line
target = target.replace('_', '-')
before line 27 in your copy of the extension.
I opened issue on a bitbucket.
source share