Add line highlighting to latex formatter

Issue #1187 new
David Handy
created an issue

I am writing a book using Sphinx, and would like highlighting of individual lines of Python code samples to work in PDF format like it does in HTML format.

Bram Geron on the Sphinx-dev list was kind enough to advise me that adding line highlighting support to the latex formatter in pygments was the way to solve this problem: https://groups.google.com/forum/#!topic/sphinx-dev/GSLzhsYsdyU

I'm proposing to add hl_lines and hl_color options to LatexFormatter, similar to what was done for ImageFormatter in this ticket: https://bitbucket.org/birkenfeld/pygments-main/issues/457/highlight-line-in-imageformatter

Help and advice welcome!

Comments (4)

  1. Tim Hatch

    Yes, that sounds great. How to properly highlight lines in latex is the missing part that I don't know.

    (Moving to Sprint milestone since it's bite-sized, and we may end up with a contirbutor that knows as well to help.)

  2. Geoffrey Poore

    As far as the LaTeX side is concerned, my fvextra package for LaTeX extends the fancyvrb package that is currently used for Pygments LaTeX output. fvextra adds highlightlines and highlightcolor options to the Verbatim environment.

  3. Log in to comment