A similar bag of tricks is available to users of sage-shell-mode in emacs, using TeX Input Method <https://www.emacswiki.org/emacs/TeXInputMethod> or one of its possible customizations.
But such variable names may cause havoc in a \LaTeX output. Consider: sage: var("λ") λ This works sage: latex(λ^2) λ^{2} Ahem: the rendition of λ is ... "λ", which pdflatex doesn't accept : sage: view(λ^2) An error occurred. [ pdflatex dumps its bowels : Snip... ] Latex error xelatex accepts this : sage: view(λ^2, engine="xelatex") but the λ is not rendered (probably because the default font used by xelatex has no λ symbol or because the preamble doesn't contain the "right" set of packages (maybe \usepackage{utf8} ?)...). Paradoxically, if your program is someday aimed at producing \LaTeX output, better not to use emacs' TeX input method, and stick to "classical" input. Or customize the preambles used by Sage (for view) and SageTeX. Probably not trivial... What happens when you want to export a Jupyter notebook with such symbols to PDF ? HTH, Le vendredi 21 février 2020 17:09:36 UTC+1, Nicolas M. Thiéry a écrit : > > Hi, > > Since Sage uses Python 3, we can finally use unicode symbols for > variables: > > sage: Φ = lambda λ: λ + 1 > > But how to input them? I just accidently discovered that IPython (and > thus Jupyter) makes it super easy. Type: > > sage: \Phi<tab> > > And you get: > > sage: Φ > > > https://ipython.readthedocs.io/en/stable/api/generated/IPython.core.completer.html#forward-latex-unicode-completion > > > Reverse conversion from symbol to latex name works too: > > sage: \Φ<tab> > > And you get: > > sage: \Phi > > Not all symbols are available by default; for example \otimes. But > it's possible to add more symbols: > > import IPython.core.completer > IPython.core.completer.latex_symbols[r'\otimes'] = '⊗' > > (best to add it as well to reverse_latex_symbol). > > > A rather big caveat though: one can easily input all the usual math > glyphs (mathbb, mathfrak, ...) of a character. However they all are > considered as equal by Python itself: > > sage: \mbfN<tab> > sage: 𝐍 > <function numerical_approx at 0x7f712339f6a8> > sage: N > <function numerical_approx at 0x7f712339f6a8> > > Cheers, > Nicolas > -- > Nicolas M. Thiéry "Isil" <nth...@users.sf.net <javascript:>> > http://Nicolas.Thiery.name/ > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/a995745a-6a28-4dba-bfd6-8ff9fd7ba2e5%40googlegroups.com.