title: Reference Figures in reStructuredText via Figure Numbers using :numref:
body: <p>I am currently trying to setup a reStructuredText template. I want to include numbered figures and references to those. So I followed the instructions given in the sphinx documentation ( <a href="http://www.sphinx-doc.org/en/stable/markup/inline.html" rel="nofollow noreferrer">http://www.sphinx-doc.org/en/stable/markup/inline.html</a> ).</p>
  
  <p>First I included the line</p>
  
  <pre><code>numfig = True
  </code></pre>
  
  <p>in the file 'conf.py'. I implemented the figure and the reference to it in my file 'rstTemplate.rst' as follows:</p>
  
  <pre><code>.. _my-figure:
  
  .. figure:: images/scen-smartcity.*
      :scale: 50 %
      :alt: smartcity symbol
      :align: center
  
      This is the caption of the figure (a simple paragraph).
  
      This is the legend of the figure
  
  Reference to the figure :numref:`(Fig. %s) my-figure`
  </code></pre>
  
  <p>When I build the html file using <code>make html</code></p>
  
  <pre><code>Running Sphinx v1.6.1
  loading pickled environment... done
  building [mo]: targets for 0 po files that are out of date
  building [html]: targets for 1 source files that are out of date
  updating environment: 0 added, 2 changed, 0 removed
  reading sources... [100%] rstTemplate
  rstTemplate.rst:: WARNING: duplicate label my-figure, other instance in &gt;&lt;path-to-file&gt;\rstTemplate.rst
  &lt;path-to-file&gt;\rstTemplate.rst:: WARNING: duplicate label my-figure, other instance in &lt;path-to-file&gt;\index.rst
  looking for now-outdated files... none found
  pickling environment... done
  checking consistency... done
  preparing documents... done
  writing output... [100%] rstTemplate
  rstTemplate.rst:41: WARNING: undefined label: (fig. %s) my-figure
  &lt;path-to-file&gt;\rstTemplate.rst:41: WARNING: undefined label: (fig. %s) my-figure
  generating indices... genindex
  writing additional pages... search
  copying images... [100%] images/scen-smartcity.svg
  copying static files... done
  copying extra files... done
  dumping search index in English (code: en) ... done
  dumping object inventory... done
  build succeeded, 6 warnings.
  </code></pre>
  
  <p>The file index.html then shows the figure, the caption and the reference to it as shown here:
  <a href="https://i.stack.imgur.com/GMJcI.png" rel="nofollow noreferrer">output index.html</a></p>
  
  <p>So the caption shows a nice 'Fig. 1' but the reference using <code>:numref:</code> obviously does not work. I also tried </p>
  
  <pre><code>:numref:`my-figure`
  </code></pre>
  
  <p>which led to a similar result.</p>
  
  <p>Does anybody know why the reference does not work here?</p>
  
  <p>What is also interesting: all the above mentioned is in my file 'rstTemplate.rst' which I included in the file 'index.rst' via <code>.. include:: rstTemplate.rst</code>. After the html build I recieve the files 'index.html' and 'rstTemplate.html'. Unlike in the 'index.html' version the 'Fig. 1' is not included in the caption of the figure in 'rstTemplate.html'. Might that be related to what is going wrong here?</p>
  
  <p>Thanks in advance.</p>