Seems that if you have an underscore in your label name (like in fig_logo
) sphinx replaces this with a minus (-
, this makes sense as latex sometimes behaves strange in cases whit underscores), while the reference still uses the underscore.
For that reason latex can not find the label 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 label and fig_logo
as reference.)
If you replace the underscore by a minus for instance
.. _fig-logo:
.. figure:: logo.png
Example of a figure
Reference to logo :num:`figure #fig-logo`
the tex code looks like this:
\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 the pdf generated this is resolved to
Reference to logo figure 1
Update
If you don't want to change all the labels you can update numfig
: it should be sufficient to add the line
target = target.replace('_', '-')
just before line 27 in your copy of the extension.
I opened an issue on bitbucket.