Code blocks and latexpdf

18 views
Skip to first unread message

Paul Smith

unread,
May 25, 2024, 6:44:41 PMMay 25
to sphinx-users
I recently upgraded to Sphinx v5.3.0, and it looks like something has changed in the latexpdf generation. I have an rst file with the following C code snippet:

:code:`"%zu\n"`

Previously, this worked fine in producing latex output. However, with v5.3.0, I get the following error on "make latexpdf":

! Text line contains an invalid character.
l.14023 \sphinxcode{\sphinxupquote{"\%zu^^@
                                           n"}} is a suitable format %

So, the \n in the code block was converted into "^@n" in the .tex file, which throws an error with latex. What is the proper way to put in the "\n" in a code block and have it work with latex?

jfbu

unread,
Jun 4, 2024, 3:54:28 PMJun 4
to sphinx...@googlegroups.com
Hi Paul,
this is strange indeed. Yes ^@ will break LaTeX. I could not reproduce with v5.3.0.

Sphinx version: 5.3.0
Python version: 3.12.3 (CPython)
Docutils version: 0.21.2
Pygments version: 2.18.0
Jinja2 version: 3.1.4

I only see \sphinxcode{\sphinxupquote{"\%zun"}} with no fancy null character in output.

Variants with syntax highlighting have no issue either.

```
:code:`"%zu\n"`

.. code:: C

"%zu\n"


.. role:: Ccode(code)
:language: C

:Ccode:`"%zu\n"`
```

What is your version of Docutils

Best,

Jean-François

Reply all
Reply to author
Forward
0 new messages