0

Python and Julia support unicode which makes it easy to write code which looks like math, i.e. (f = σ-> κ* σ ). Now, I'm trying to copy over some of this code into notes, with the listings package. But pdflatex doesn't want to compile it. I tried lualatex, and then I have no errors, but the symbols don't show up. Just to reiterate, I am not trying to include the unicode in a math environment.

Example:

\begin{lstlisting}[language=python]
F = lambda x: α * x + β 
\end{lstlisting}

Compiles, but α and β appear as blank, in the tex:enter image description here

  • 1
    As always on the site you are much much more likely to get help if you provide a full (but minimal) self contained example that others can test as is. – daleif Sep 19 '19 at 14:46
  • 2
    That being said listings does not support random 2byte chars so I would not be surprised that (f = σ-> κ* σ ) does not work in listings. There are some workarounds but they mostly involve specifying mappings for the needed non ascii chars. – daleif Sep 19 '19 at 14:47
  • The symbols will show up with luatex if you use a suitable font that has the characters. for pdflatex it's a bit harder but a start would be `\documentclass{article} \usepackage[T1,LGR]{fontenc} \begin{document}

    f = σ-> κ* σ )

    \end{document} ` (but note the f) If you want help with an error show a small but complete document and teh exact error that you get.

    – David Carlisle Sep 19 '19 at 15:14
  • See here about how to add arbitrary symbols to listings https://tex.stackexchange.com/questions/25391/the-listings-package-and-utf-8/25396#25396 (you still need a suitable font for the symbols). – Ulrike Fischer Sep 19 '19 at 15:34
  • Fischer's suggested link doesn't work for the greek characters I want (but does, otherwise, work). – user2379888 Sep 21 '19 at 14:25

0 Answers0