olivierverdier / python-latex-highlighting

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

Support for labels #10

Closed haenry closed 10 months ago

haenry commented 4 years ago

The original definition of the lstlistings environment is (at the bottom of listings.sty)

\lstnewenvironment{lstlisting}[2][]{%
     \lst@TestEOLChar{#2}%
     \lstset{#1}%
     \csname\@lst @SetFirstNumber\endcsname%
   }{%
     \let\if@nobreak\iffalse%
     \csname\@lst @SaveFirstNumber\endcsname%
   }

I redefined the python environment in the same way

GabrieleCalarota commented 3 years ago

What is missing this from merging? I Would like this to be added as well!

adamheffernan commented 3 years ago

It looks like it is okay to merge @olivierverdier

olivierverdier commented 3 years ago

I’m all for merging this, but what does that achieve?

yasirroni commented 2 years ago

Is this label support referencing and list of code? Can you help give minimum working example? @haenry

haenry commented 2 years ago

Sorry for the late reply. It fixes the issue found here: https://github.com/olivierverdier/python-latex-highlighting/issues/4#issue-230867502

With the PR you can add a label to your code snippet and then reference that label somewhere else like you can do with figures. There is also an example following the link above.

jonas-eschle commented 10 months ago

Hi @olivierverdier , any news on this? Would be great to have this in!