latex style should limit change of `\fboxsep` in a scope by extra pair of braces

Issue #1410 new
jfbu
created an issue

The LaTeX Formatter style produces (with prefix = PYG):

\def\PYG@do#1{\PYG@bc{\PYG@tc{\PYG@ul{%
    \PYG@it{\PYG@bf{\PYG@ff{#1}}}}}}}

This means that \PYG@bc macro acts at "top level". But, at https://bitbucket.org/birkenfeld/pygments-main/src/7941677dc77d4f2bf0bbd6140ade85a9454b8b80/pygments/formatters/latex.py?at=default&fileviewer=file-view-default#latex.py-304 and again at https://bitbucket.org/birkenfeld/pygments-main/src/7941677dc77d4f2bf0bbd6140ade85a9454b8b80/pygments/formatters/latex.py?at=default&fileviewer=file-view-default#latex.py-309 it is defined in a way which modifies the LaTeX length \fboxsep. This modification should be kept local. Of course, normally this is all encountered inside a Verbatim where each code line is a hbox hence limits the scope. But, in theory, even in this context it is still possible some macros are executed on same code line and then \fboxsep default should not be modified for them.

This is very minor problem.

Anyway, one way to fix it would be to modify above definition to

\def\PYG@do#1{{\PYG@bc{\PYG@tc{\PYG@ul{%
    \PYG@it{\PYG@bf{\PYG@ff{#1}}}}}}}}

or modify

\def\PYG#1#2{\PYG@reset\PYG@toks#1+\relax+\PYG@do{#2}}

to

\def\PYG#1#2{{\PYG@toks#1+\relax+\PYG@do{#2}}}

notice that in second approach, there is no need for \PYG@reset anymore (but it will have to have been executed once in the style file so that \PYG@bf etc... are initially \relax (or \empty)).

We encountered the problem at Sphinx and fixed it at https://github.com/sphinx-doc/sphinx/pull/4250/files.

Comments (0)

  1. Log in to comment