Сфинкс rst2pdf: нумерация фигур - PullRequest
0 голосов
/ 23 марта 2020

У меня есть несколько документов на Sphinx 2.x. В дополнение к версии HTML (make html) я хочу экспортировать ее также в PDF-версию, предпочтительно используя rst2pdf :

В моих документах есть изображения с рисунками. Вот фрагмент из index.rst.

.. figure:: ./_images/img01.png

   Caption for img01.


.. figure:: ./_images/img02.png

   Caption for img02.

Я хочу добавить "Рисунок <#>" в начале каждой подписи. У кого-нибудь есть мысли? Обратите внимание:

  • numfig не работает с rst2pdf.

Обновление (3/22/2020). Добавить следующие строки в conf.py.

numfig = True

numfig_format = {
    'figure': 'Figure %s.'
    }

numfig_secnum_depth = 1

На выходе HTML это работает.

HTML output with numfig

В файле rst2PDF версия, вы не видите "Рисунок #" .

rst2PDF output with the same numfig configuration

  • : counter: * Директива 1044 * не работает со Sphinx; Я получаю следующую ошибку:
.. figure:: ./_images/img01.png

   Figure :counter:`figure`. Caption for img01.
$ sphinx-build -b pdf ./source/ ./build/
Running Sphinx v2.4.4
/home/sarah/sphinx_test/lib/python3.6/importlib/__init__.py:126: RemovedInSphinx30Warning: sphinx.environment.NoUri is deprecated.
Check CHANGES for Sphinx API modifications.
  return _bootstrap._gcd_import(name[level:], package, level)
Initiated sphinxcontrib-images backend: `sphinxcontrib_images_lightbox2.lightbox2:LightBox2`
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index

Exception occurred:
  File "/home/sarah/sphinx_test/lib/python3.6/site-packages/docutils/nodes.py", line 439, in copy
    return self.__class__(reprunicode(self), rawsource=self.rawsource)
AttributeError: 'CounterNode' object has no attribute 'rawsource'
The full traceback has been saved in /tmp/sphinx-err-1bzghsm6.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
...