Zulip Chat Archive

Stream: new members

Topic: Lean to Latex


Gabriel Moise (Apr 08 2021 at 12:49):

Hello!
I wanted to write a project that has some Lean code attached to it in LaTeX, however I encountered some difficulties:

  • there is no Lean option in the lstlisting environment, which means I can't get the pretty colouring etc. that I have for example in VS code
  • in Lean there are a lot of symbols used, and it seems a little tedious to have to rewrite each of them to the LaTeX version of them for each line of code

Are there people who wrote Lean code into LaTeX who have any suggestions or sample LaTeX code?

Eric Wieser (Apr 08 2021 at 12:56):

Somewhere on github there's a listings config file to solve these problems

Eric Wieser (Apr 08 2021 at 12:56):

I had a good experience with minted instead of listings, but it requires a recent version of the Python pygments package

Eric Wieser (Apr 08 2021 at 12:57):

https://github.com/leanprover-community/lean/blob/master/extras/latex/lstlean.md

Holly Liu (Jul 21 2021 at 12:56):

i followed the setup instructions and am confused on how to get the symbols to show up in LaTeX? i'm doing \lstinline{list \upalpha} which shows up as list \upalpha when compiled.

Anne Baanen (Jul 21 2021 at 13:05):

In a listing, you should write the actual Lean code, including Unicode characters. So something like \lstinline{list α} would work.

Holly Liu (Jul 21 2021 at 13:44):

is there an easier way to do this instead of copy and pasting each symbol?

Anne Baanen (Jul 21 2021 at 13:51):

I have my Linux system set up with a Compose key. So α is compose-*-a, β is compose-*-b, → is compose--->, ...

Anne Baanen (Jul 21 2021 at 13:52):

Or you can look into X Input Methods in general, I think there are a few that allow you to type LaTeX symbol names and get unicode characters

Holly Liu (Jul 21 2021 at 14:20):

thanks. i'll look into it

Eric Rodriguez (Jul 21 2021 at 16:26):

if you're on Windows, I strongly recommend WinCompose :)


Last updated: Dec 20 2023 at 11:08 UTC