Search code examples
pythonpython-sphinxread-the-docs

Bad Sphinx :linenos: alignment


Line numbers are not aligned in Sphinx's Read The Docs Theme.

The highlighted lines are 5 and 8.

enter image description here

The restructured text which produced this:

.. code-block:: python
    :emphasize-lines: 5, 8
    :linenos:

Thoughts on why this might be happening?


Solution

  • I can reproduce the problem with sphinx_rtd_theme 0.2.4. It has been fixed in the master branch: https://github.com/rtfd/sphinx_rtd_theme/issues/381.

    Commit (8 March 2017): https://github.com/rtfd/sphinx_rtd_theme/pull/382/commits/deb553c1d2da7a74c56ab825353522c98d2e9093.