Zulip Chat Archive
Stream: new members
Topic: Printing Lean source code
Aki Hideaki Kawai (Jan 14 2026 at 01:40):
What is the common way to (physically) print out the lean source code? I tried "Print" extension on VSCode but syntax highlighting was not functioning. I just wanted to print out what I see on VSCode.
Notification Bot (Jan 14 2026 at 10:58):
This topic was moved here from #lean4 > Printing Lean source code by Kevin Buzzard.
Kevin Buzzard (Jan 14 2026 at 10:58):
I don't think this is really a question about Lean -- it sounds like a question about VS Code and could be asked about any programming language. Does a web search asking for printing code with syntax highlighting show up anything?
Snir Broshi (Jan 14 2026 at 10:59):
Snir Broshi (Jan 14 2026 at 10:59):
The easy way is to copy-paste the code into powerpoint (or similar).
All the syntax highlighting is preserved, you just have to set the background color.
Aki Hideaki Kawai (Jan 15 2026 at 01:22):
Thanks for the response. I found copy-paste into TextEdit works.
Aki Hideaki Kawai (Jan 15 2026 at 02:08):
Sorry for the unclear wording in my original question, but I wasn’t really asking about VS Code itself. What I’m actually wondering is whether there is any Lean-community–recommended way to export or print Lean code with proper syntax highlighting.
My impression is that this may be related to the current state of Lean’s syntax-highlighting infrastructure (e.g. how parsing/highlighting is implemented in editors), but I may be mistaken.
Is there any recommended approach, or is copy-paste into rich-text editors currently the de facto solution?
Snir Broshi (Jan 15 2026 at 02:11):
I imagine you won't find many people interested in printing code, this sounds super niche
(however exporting code to Latex/Powerpoint/Keynote/HTML is probably a common occurrence)
Kevin Buzzard (Jan 15 2026 at 08:17):
When I display code blocks in talks I just take a screenshot and insert that.
Michael Rothgang (Jan 15 2026 at 09:01):
Do you specifically want to print source code, or quote it when you're giving a presentation? (These are different.)
Michael Rothgang (Jan 15 2026 at 09:01):
The easiest way to ensure perfectly matching syntax highlighting is to take a screenshot: always works, no potential for failures somewhere, but updating them as code changes is more annoying.
Michael Rothgang (Jan 15 2026 at 09:03):
Other ways depend on your goal: are you doing a powerpoint presentations? (No idea then; good luck.) LaTeX beamer (people have managed; I've struggled with it)? Typst (heard good things, but not tried yet). Writing a paper (then typst won't help you.)
If you tell us what you really want to do, we can answer your real question :-)
Mirek Olšák (Jan 15 2026 at 19:57):
For example, I wanted some basic syntax highlighting for a poster, and used this code2svg.
Aki Hideaki Kawai (Jan 16 2026 at 05:15):
Thanks for the suggestions.
To be more specific, I wanted review a few hundred lines of Lean code. For me, reading on paper is sometimes easier than on screen, and thus, having good syntax/semantic highlighting matters for legibility.
In that sense my question is about printing/exporting rather than presentation or publication.
I learned that copy-pasting into a rich-text editor works, which is good to know. I was just wondering whether there is any other approach people use in this situation, especially when doing this repeatedly.
Jakub Nowak (Jan 16 2026 at 05:32):
That sounds like a very bad idea to me tbh. You lose all the interactive feature like hover information, which for me are essential for understanding Lean code, because of type inference.
Aki Hideaki Kawai (Jan 18 2026 at 02:18):
That makes sense, thanks for sharing your thoughts!
Last updated: Feb 28 2026 at 14:05 UTC