Zulip Chat Archive
Stream: general
Topic: LaTeX syntax highlighting
Yaël Dillies (Apr 27 2025 at 09:46):
I have my own syntax highlighting setup for Lean back from when Bhavik I wrote this paper about Szemerédi's regularity lemma in 2022, but I know things have moved and I thought I would get up to date.
Yaël Dillies (Apr 27 2025 at 09:47):
I therefore tried following the instructions for minted here: https://lean-lang.org/documentation/latex-syntax-highlighting/
Yaël Dillies (Apr 27 2025 at 09:49):
The very first line says:
First install Pygments (version 2.18 or newer). Then save the following sample LaTeX file
test.tex
into the same directory:
I do not know how you are supposed to install pygments, but when I did (using pip install Pygments
), I was not told what folder it was installed in. I believe it is in fact a global install and I do not need to install it once per directory. So "save the following sample LaTeX file test.tex
into the same directory" seems nonsensical. Is this interpretation correct?
Yaël Dillies (Apr 27 2025 at 09:52):
Then I ran xelatex --shell-escape test.tex
in the correct folder. Of course I didn't have FreeMono installed, and I find installing fonts a really confusing process (fonts are not executables, but you can still "install" them??), but anyway I solved that, so I went onto a new error:
-- Lots of classic latex gibberish
! Package minted Error: You must have `pygmentize' installed to use this packag
e.
-- a bit more latex gibberish
Yaël Dillies (Apr 27 2025 at 09:53):
Scrutinising https://lean-lang.org/documentation/latex-syntax-highlighting/, pygmentize
is mentioned exactly once, here:
--shell-escape
is needed to allowxelatex
to executepygmentize
in a shell.
Yaël Dillies (Apr 27 2025 at 09:54):
So I do not know what pygmentize
is, how I installed it or failed to do so, and I am stuck.
Yaël Dillies (Apr 27 2025 at 09:54):
If that's relevant, I am on Windows 10, and I believe I installed Pygments back in 2022, although I have no clue how to actually check the version I have
Jz Pan (Apr 27 2025 at 16:31):
Maybe you can search on Internet "Windows LaTeX how to use minted package"
Jz Pan (Apr 27 2025 at 16:31):
It's working for me, but I didn't remember how it was installed.
Jz Pan (Apr 27 2025 at 16:33):
Julian Berman (Apr 27 2025 at 17:29):
Just to answer part of the original question -- pygmentize
is an executable installed with pygments
, and xetex
seems like it's looking for that executable and not finding it.
Julian Berman (Apr 27 2025 at 17:31):
If you ran pip install stuff
it got installed globally typically yes, and I've seen that Windows' Python installer's behavior is still very odd, specifically I saw students not have that directory added to their PATH by default, which might be your case as well -- so you might have a global install of pygmentize which nothing can run without knowing it's in your Python installation's script folder.
Julian Berman (Apr 27 2025 at 17:33):
If you have pipx
installed you could have done pipx install pygments
probably, or uv tool install pygments
which is the newer way -- or if you just want to know where what you have ended up, you can run python -m sysconfig | rg scripts
or thereabouts and it'll tell you what directory it was installed to, and then you can add that to your PATH in the Windows menus somewhere.
Eric Wieser (Apr 27 2025 at 17:33):
The PATH question is asked when you install Python for the first time via the windows installer, but I'm not sure what the default is.
Julian Berman (Apr 27 2025 at 17:33):
Yeah empirically I'm betting it's still not turned on by default because 90% of students I saw have issues with it. Which is weird because I remember some hubbub about it like 5 - 10 years ago even. (EDIT: though the truth is I have not run a Python installer in ~10 years so possibly the default is the same on macOS even though I doubt it as I had no students asking me to help there.)
Eric Wieser (Apr 27 2025 at 17:34):
Probably rerunning the python installer is a good option too, since I think it will offer that choice without changing the rest of your installation
Eric Wieser (Apr 27 2025 at 17:34):
(add / remove programs on Windows might tell you where your installer is)
Yaël Dillies (Apr 27 2025 at 23:01):
Julian Berman said:
If you ran
pip install stuff
it got installed globally typically yes, and I've seen that Windows' Python installer's behavior is still very odd, specifically I saw students not have that directory added to their PATH by default, which might be your case as well -- so you might have a global install of pygmentize which nothing can run without knowing it's in your Python installation's script folder.
I am now almost sure that this is the case. I could not see Python on my PATH and I see this default option when running the 3.13 Python installer.
Jz Pan (Apr 28 2025 at 08:41):
You can manually edit PATH on Control Panel. There should be tutorials on the Internet.
Jz Pan (Apr 28 2025 at 08:43):
On Windows 10 it should be in (sort of) All Settings -> System -> About -> Advanced System Settings (you need permission) -> Advanced -> Environment Variable
Jz Pan (Apr 28 2025 at 08:46):
It's enough to only add it to your personal account's environment variable. Add C:\path\to\your\python_directory
and C:\path\to\your\python_directory\Scripts
to PATH
and set PYTHON
environment variable to C:\path\to\your\python_directory\python.exe
.
Yaël Dillies (Apr 28 2025 at 08:52):
I have now fixed it all, but I now remember that xelatex isn't accepted on arxiv, so maybe I'll stick to lstlistings :sweat_smile:
Kevin Buzzard (Apr 28 2025 at 09:02):
I've heard that @Eric Wieser has a hack for this. I had a word with the ArXiv people about the fact that the software stack is decades out of date but right now it turns out that they are mainly worried about other things.
Patrick Massot (Apr 28 2025 at 09:04):
It's really not encouraged but you can still use xelatex on arxiv.
Eric Wieser (Apr 28 2025 at 10:51):
Jireh told me that you can just ask nicely and they'll let you upload stuff using other texes
Eric Wieser (Apr 28 2025 at 10:52):
(no need for the hack to thwart their detection)
David Thrane Christiansen (Apr 28 2025 at 20:07):
When I tested those instructions two weeks ago, I used a Python virtualenv to set up everything. I think this thread is a sign that the page needs to be more specific, but I actually don't know enough about multi-platform Python to give the right advice.
Is there a standard resource to link to that describes how to get Python tools set up on various platforms? It seems silly to duplicate these things ourselves, and at that point it'd take less time to just set up a little Verso-based tool :)
Michael Rothgang (Apr 28 2025 at 21:55):
I think using a virtualenv is good advice (probably using uv
instead of pip
, these days).
Michael Rothgang (Apr 28 2025 at 21:56):
(It does have some barrier to entry, but it is much more error-proof...)
Last updated: May 02 2025 at 03:31 UTC