Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.3k
Description
Describe the bug
Tabulation characters from files which get inserted usingliteralinclude end up "as is" both in the.html and in the.tex file produced by the respective builders.
In the PDF they get converted to 8 spaces, independently of their location.
This is in contrast with viewing the HTML where at least with my Firefox the rendering uses tab stops every 8 characters. Note though that I have found notab-size setting for<pre> in the CSS files (when building the MWE below) so this may be browser dependent. Indeed, I am ignorant if there is a universal convention that in absence oftab-size, tab stops inside<pre> are every 8 characters.
Important: here we do not use:tab-width: option. If using that option tabs are converted to spaces both with LaTeX and HTML and the outputs match one another with tab stops matching the option (only tested with:tab-width: 8).
How to Reproduce
.. literalinclude:: filewithtabs.txtwithfilewithtabs.txt being
============================LINUX KERNEL MEMORY BARRIERS============================hellowherearelittletabsgone?PDF output:

HTML:

Environment Information
Platform: darwin; (macOS-15.7.2-arm64-arm-64bit-Mach-O)Python version: 3.13.3 (v3.13.3:6280bb54784, Apr 8 2025, 10:47:54) [Clang 15.0.0 (clang-1500.3.9.4)])Python implementation: CPythonSphinx version: 8.3.0+/5d0ad1686Docutils version: 0.22.4b1.devJinja2 version: 3.1.6Pygments version: 2.19.1Sphinx extensions
Additional context
Tested with Docutils0.22.3 and0.21.2.
This issue was originally reported at#13656 (comment) by@akiyks.
Note that as work-around it is enough to add:tab-width: 8 option to theliteralinclude directive. Then the.tex file (and also.html) will contain only spaces, matching tab-stops at each multiple of 8 characters.