目前我正在試圖安裝一個新結構化模板。我想包括編號的數字和參考。所以我也跟着獅身人面像文檔(http://www.sphinx-doc.org/en/stable/markup/inline.html)中的說明。參考圖
首先我包括線
numfig = True
在文件 'conf.py'
。我實現了這個數字,在我的文件「rstTemplate.rst」對它的引用如下:
.. _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`
當我建立使用make html
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 ><path-to-file>\rstTemplate.rst
<path-to-file>\rstTemplate.rst:: WARNING: duplicate label my-figure, other instance in <path-to-file>\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
<path-to-file>\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.
HTML文件中的index.html文件則顯示圖中,標題和引用如下所示: output index.html
因此,標題顯示一個不錯的'圖。 1「,但使用:numref:
的參考顯然不起作用。我也試過
:numref:`my-figure`
這導致了類似的結果。
有誰知道爲什麼引用不在這裏工作了?
還有什麼值得注意的:上述所有內容都在我的文件'rstTemplate.rst'中,我通過.. include:: rstTemplate.rst
將它包含在文件'index.rst'中。在構建html之後,我收到文件'index.html'和'rstTemplate.html'。與'index.html'版本不同,'Fig。 1'不包含在'rstTemplate.html'圖中的標題中。可能與這裏出了什麼問題有關?
在此先感謝。
我建議先解決重複標籤警告,然後看看未定義的標籤警告是否持續。 –