Hacker News new | ask | show | jobs
by guipsp 2762 days ago
But you can't type α, ∂, or ∫ in a standard keyboard.
7 comments

I feel like this is the sweet spot for the editor to do some of the heavy lifting, for example being able to type "\alpha" and have the editor automatically transform it into the symbol α. I write a lot of LaTeX, and I would absolutely love an editor which could just transparently deal with all of the underlying mathematics markup so I would never have to see it again, and just directly edit the damn equations. Serialising and unserialising mathematics markup mentally is basically the antithesis of mathematical notation.
In case you haven't already heard of it, LyX [1] does exactly that and it's phenominal. As an added bonus, when you move your cursor out of the equation it goes from a graphical almost-right visualisation to a proper LaTeX-generated absolutely-right preview, and manages other related LaTeX things like heading levels with a live clickable outline.

The big disadvantage to LyX is that it's not LaTeX editor but a LaTeX generator. So if you want to write your next article or dissertation and can commit to it then it's great, but if you want to import work so far or collaborate with someone not using LyX then it doesn't really work (it has an import function but it's almost unusable).

[1] http://www.lyx.org/

I've actually had good luck round-tripping lyx-latex-lyx repeatedly to collaborate with lyx-phobic co-authors. (As long as they don't mind equations they typed getting auto-formatted, etc.)
The julia interpreter does this. Or you have to press tab to do the transformation.
Emacs already has you covered. Good old C-x RET C-\ TeX will switch your input method to TeX, converting \alpha etc to unicode alpha, etc for most math symbols. Additionally, ^[char] or _[char] will become superscript/subscript unicode chars.

Once you've done that once in the session, you can just hit C-\ to toggle it on and off (C-x RET C-\ [input method] actually lets you select from a wide variety of input methods, and C-\ toggles on and off the most recently selected input method).

There are some editor plugins that do something like this. I know for Vim there is tex-conceal (https://github.com/KeitaNakamura/tex-conceal.vim), which collapses a lot of LaTeX symbols to their Unicode equivalent on lines other than your current line. It's a nice middle-ground, though far from perfect.
I use LaTeX with unicode-math regularly and I use emacs with quail mode to do exactly this.
Vim digraph feature (ctrl-k) is very convenient for this. Digraphs are two-character mnemonics for symbols. They tend to be easy to remember and they are standardized in RFC 1345 [1].

Greek letters are always a latin letter followed by an asterisk. Arrows and comparison operators are what one would guess. Mathematical symbols generally make some sense:

    <C-k> a *     α
    <C-k> F *     Φ

    <C-k> = >     ⇒
    <C-k> - >     →
    <C-k> > =     ≥

    <C-k> 0 0     ∞
    <C-k> d P     ∂
    <C-k> I n     ∫
[1]: https://tools.ietf.org/html/rfc1345
> But you can't type α, ∂, or ∫ in a standard keyboard.

I have a standard keyboard and I type greek letters easily. ALTGR+a, and so on.

If somebody is not able to configure their keyboard to do this they are not probably writing LaTeX, either.

If memory serves me correctly, there was no way to type those symbols on an Acorn A5000 which is where I did the bulk of my LaTeXing back in the day (1992-95).

(Admittedly, this anecdata is even more useless than usual.)

Unfortunately ANSI (US layout) keyboards make this much more difficult.
In DrRacket, you can press Ctrl+\ to insert a lambda character.
Of course you can. Armed with only a text editor, a craft knife and some tippex, you can have any keyboard layout you like on a standard keyboard.
On a recent mac, you can enable Greek as a second keyboard, and tick the box there to make caps lock switch keyboards.

As long as you don't need caps lock as your escape key...

You can on a Mac. Holding the option key allows typing a whole host of symbols.

https://beebom.com/how-type-hidden-mac-keyboard-symbols/

This is like asking someone to use Alt codes (https://www.alt-codes.net/) on Windows, it's highly unintuitive and cumbersome.
They aren’t terribly intuitive, but they are much easier than alt-codes. If you’re a touch typist it doesn’t take long to memorize a reasonable number of symbol positions. I still can’t temember any alt-codes though when I’m on a windows machine.
I know the few I use regularly and the rest are easy to get via ctrl CMD Space. I’ve added various symbol sets to the character viewer and it suits my work flow.
Right, and you can do the same on linux with the compose key. But it isn't very intuitive, discoverable or rememberable.
Badly discoverable? Sure. You can vastly improve the remembering part by picking appropriate mnemonics. The Plan 9 keyboard file is a nice start, I think.

It follows a set of rules so you don't have to remember a large number of sequences but can often guess the right one intuitively.

    ASCII digraphs for mathematical operators give the corresponding operator, e.g., <= yields ≤.
    Greek letters are given by an asterisk followed by a corresponding latin letter, e.g., *d yields δ.
https://github.com/9fans/plan9port/blob/master/lib/keyboard

https://9fans.github.io/plan9port/man/man7/keyboard.html

There's a program (mklatinkbd) to convert it to a format usable with X11.

> you can do the same on linux with the compose key. But it isn't very intuitive, discoverable or rememberable.

Well, LaTeX itself is not very discoverable either

It’s pretty good IMHO. Greek symbols are all obvious. \Omega and \omega for upper and lowercase omega etc. Super and subscripts with ^{} and _{} also work with \sum and \int for indices and intervals.

Software like Latexit and Mathpix also help a lot.

You can do so relatively easily with Vim digraphs. For example, the alpha symbol can be obtained by typing

Ctrl-k a Shift-8