olivierverdier / python-latex-highlighting

LaTeX style for Python highlighting
BSD 3-Clause "New" or "Revised" License
453 stars 125 forks source link

Symbol `%` highlighted and parsed as comments, but correctly rendered #20

Closed TijlE-1951707 closed 2 months ago

TijlE-1951707 commented 2 months ago

Well, I'm not sure if it's a duplicate to #3, but it can still be annoying when % symbols are inside the code block.

\pyth

When writing % inside \pyth, overleaf highlights the remainder of the code and text outside the curly braces as a comment. The pdf renders as desired though. image image

Overleaf also produces a warning. image

Notice that I had to use 2 blank spaces, otherwise the remaining code gets printed right next to the % symbol. image image

Finally, using \% gets printed as "\%" as expected, so it doesn't solve this either. (Though again, another space is necessary, which is not expected.) image image

\python

Similar, but acceptable annoyances exist in the \python command. image

Is there any way to fix this?

olivierverdier commented 2 months ago
  1. What you describe is mostly and editor problem that you may want to report to the issue tracker of the editor (overleaf, in your case). It is unlikely that they should fix it properly though.
  2. The double space after % is a distinct issue (a minor one, I guess), but I believe it is a problem of the listings package, in that case. I'd be happy to fix it if I can, though.
TijlE-1951707 commented 2 months ago

In the case nothing can be done for Overleaf being annoying, it can be closed. Thanks!