When writing RST that will be processed with Sphinx, I can\'t get Sphinx LaTeX output to use figure numbers when referencing figures. For instance, this code:
One can use raw latex code, inline. For the example above, a role for raw latex code is first defined and than used to refer to the figure with the \ref{}
latex command, and to set a label to the figure with the \label{}
latex command.
The following should work:
.. role:: raw-latex(raw)
:format: latex
The lemmings are attacking, as can be seen in :ref:`figlem`
on figure :raw-latex:`\ref{pic:lem}`.
.. _figlem:
.. figure:: _static/lemming_invasion.*
They're coming! :raw-latex:`\label{pic:lem}`
Note that the \label{}
command will appear inside the caption in the tex file, but it is still acceptable, at least by pdflatex
. Also note that there should be at least one space before :raw-latex
.