29

How can I input Greek symbols using the TeX descriptions (like \beta, \alpha, \lambda, etc) in emacs?

JB.
  • 40,344
  • 12
  • 79
  • 106

9 Answers9

36

Use

C-x RET C-\ TeX RET

to get TeX entry mode. Then you can use many of the standard sequences from TeX to enter things.

\alpha       α
\Gamma       Γ

as well as the whole gamut of mathematical symbols

\rightarrow  →
\Leftarrow   ⇐
\oplus       ⊕
\int         ∫
x_3          x₃
M^-^1        M⁻¹
v^x          vˣ
sigfpe
  • 7,996
  • 2
  • 27
  • 48
17

I tend to use the RFC 1345 input mode for this.

C-x RET C-\ "rfc1345" RET

You can then turn the input mode on and off with C-\.

According to RFC 1345, Greek characters are accessed by appending the * character. Special symbols in general start with &. So you can type &a* and get α, &l* gets λ. I use RFC 1345 because it also gives me access to all sorts of other symbols, like &TE for "there exists" or &FA for "for all".

You could also use the Greek input mode, which is easier to use but doesn't give you extra symbols.

C-x RET C-\ "greek" RET

One of the advantages of these methods is that they work the same way across all platforms — as long as you're using Emacs.

Dietrich Epp
  • 205,541
  • 37
  • 345
  • 415
  • If you get a helm binding conflict trying to enable `rfc1345`, instead use: `C-u C-\ rfc1345 RET` to toggle the input method. – Micah Elliott Dec 13 '16 at 22:20
7

i always input `λ' by the following punch:

C-x 8 RET 3bb

象嘉道
  • 3,657
  • 5
  • 33
  • 49
3

There is also the greek-babel input method which is selected (similarly to other input methods) with C-x RET C-\ greek-babel.

In this mode, the regular alphabet keys are mapped to greek characters as shown in this little table:

Αα Ββ Γγ Δδ Εε Ζζ Ηη Θθ Ιι Κκ Λλ Μμ Νν Ξξ Οο Ππ Ρρ Σσς Ττ Υυ Φφ Χχ Ψψ Ωω
Aa Bb Gg Dd Ee Zz Hh Jj Ii Kk Ll Mm Nn Xx Oo Pp Rr Ssc Tt Uu Ff Qq Yy Ww

plus some for entering sampi, digamma, stigma, koppa and various diacriticals. For a full list of the mappings done by greek-babel use C-h I greek-babel.

In ordinary usage the only somewhat weird mappings to watch out for are Θ/θ, ς, Υ/υ, Ψ/ψ and Ω/ω.

It is named so because the LaTeX package babel when loaded with the greek option enables one to type greek text with regular latin latters using the above mapping.

This input mapping is especially useful if you're writing the occasional Greek word in a (La)TeX document that you want to keep fully in UTF-8 without any ugly hacks like writing bibloc in your source instead of actual Greek βιβλος.

<Rant>
As a side note, things like C-\ are really annoying with a Danish keyboard because \ = AltGr + <, so to enter C-\ you need to hold down both Ctrl keys plus AltGr. If you hold just one Ctrl key plus AltGr plus < you just get a backslash.
</Rant>

kahen
  • 230
  • 2
  • 8
3

You can also learn some unicode and use M-x ucs-insert, e.g. M-x ucs-insert 3BB gives you a beautiful lambda.

nihtml
  • 111
  • 4
2

I have Ubuntu set up so that I can type in Greek after pressing Shift+CapsLock — λικε τηισ — and then press Shift+CapsLock again to get back to Latin letters. Are you using Windows, MacOS, what?

Edit: You're using Ubuntu too, so: go to Start menu → System → Preferences → Keyboard → Layouts. [Add...] a layout for Greece. Select a key combination you like under [Options...] → Key(s) to switch between layouts. Personally I don't have "Separate layout for each window" set, but YMMV. Finally, I clicked [Apply System-Wide...].

(I'm using Ubuntu lucid 10.04 LTS — if you're using a newer version, the steps might be slightly different.)

dave4420
  • 46,404
  • 6
  • 118
  • 152
1

Depending on your goal, e.g. which programming language you want to edit, you might want to consider using the input mode available in agda2-mode; it provides a more programming oriented alternative to TeX (but very similar);

I'm personally using it with my Haskell buffers instead of the TeX input method or the automagic but limited Haskell unicode input method.

Examples:

  • typing \:: yields
  • typing \-> yields
  • typing \br yields

Installing agda2-mode means using your package manager or Cabal to install Agda (e.g. brew install agda on OS X), then $ agda-mode compile and then:

(load-file (let ((coding-system-for-read 'utf-8))
                (shell-command-to-string "agda-mode locate")))

Optionally, to auto-enable the agda input mode for e.g. Haskell buffers:

(require 'agda-input)
(add-hook 'haskell-mode-hook
          (lambda () (set-input-method "Agda")))
Community
  • 1
  • 1
Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
  • 1
    Also, Emacs comes with `prettify-symbols-mode`: http://ergoemacs.org/emacs/emacs_pretty_lambda.html – Lassi Apr 03 '19 at 17:49
0

if you have an Apple, there is a very easy way to access all of the characters available to the "Character Viewer". In Sys Prefs -> keyboard -> input sources, select show input menu in menu bar. Bring up the character viewer and then make favorites of the N characters you need to access. Then, hit the small box to the right of char viewers search bar. The char viewer disappears, and what's left is a small window with your chosen char set. Position your cursor in your editor, click on the desired char in the favs.

0

You can copy paste them from the character map to the editor.

BenjaminB
  • 1,809
  • 3
  • 18
  • 32