Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Often, during a conversation or an email, or at a forum, I would like to type some math, but I don't need full equation support. Unicode symbols should suffice.

What I need is an easy way to type math related unicode symbols. Since I already know latex, it makes sense to use the latex symbol mnemonics to type the math symbols.

What I currently did is to write an AutoHotKey script which automatically replaces \latexSymbol with the corresponding unicode symbol, using the "hotstrings" AutoHotKey feautres. However, the AutoHotKey hotstrings proved unstable for many strings. Having a couple of tens lines would cause AHK to fail recognizing the strings from time to time.

Any other solution? (No, Alt+unicode number isn't convenient enough)

Attached is my AHK script. The PutUni function is taken from here.

::\infty::
PutUni("e2889e")
return
::\sum::
PutUni("e28891")
return
::\int::
PutUni("e288ab")
return
::\pm::
PutUni("c2b1")
return
::\alpha::
PutUni("c991")
return
::\beta::
PutUni("c992")
return
::\phi::
PutUni("c9b8")
return
::\delta::
PutUni("ceb4")
return
::\pi::
PutUni("cf80")
return
::\omega::
PutUni("cf89")
return
::\in::
PutUni("e28888")
return
::\notin::
PutUni("e28889")
return
::\iff::
PutUni("e28794")
return
::\leq::
PutUni("e289a4")
return
::\geq::
PutUni("e289a5")
return
::\sqrt::
PutUni("e2889a")
return
::\neq::
PutUni("e289a0")
return   
::\subset::
PutUni("e28a82")
return
::\nsubset::
PutUni("e28a84")
return
::\nsubseteq::
PutUni("e28a88")
return
::\subseteq::
PutUni("e28a86")
return
::\prod::
PutUni("e2888f")
return
::\N::
PutUni("e28495")
return
share|improve this question
    
Did the bookmarklet work for you ? –  Kasper Nov 3 '13 at 4:39
    
Didn't try that yet. –  Elazar Leibovich Nov 3 '13 at 7:42

5 Answers 5

up vote 2 down vote accepted

I use a javascript bookmarklet for typing unicode symbols at math.stackexchange.com. Mathjax renders most unicode the same as the corresponding latex macros. For example $ℝ$ and $\mathbb{R}$ give the same result. I like the way tex code stays more compact and readable with unicode symbols.

I think this code is able to do what you want. I like to use not too many keystrokes, so instead of \alpha I use \a to produce α. You can modify this script to your own needs, and then convert it to a bookmarklet, using this website for example: http://jasonmillerdesign.com/Free_Stuff/Instant_Bookmarklet_Converter

If you want to use this script on a website without jquery, then you first need to run this bookmarklet: http://www.learningjquery.com/2006/12/jquerify-bookmarklet/

jQuery.fn.autocorrect = function(options)
{
    if ("text" != jQuery(this).attr("type") && !jQuery(this).is("textarea"))
    {
        return;
    }
var defaults = {
        corrections: {
            a: "α",
            b: "β",
            c: "γ",
            d: "δ",
            e: "ϵ",
            emp : "∅",
            f: "\\frac{}{}",
            in : "∈",
            s: "σ",
            t: "\\text{}",
            tau : "τ",
            th : "θ",
            p: "π",
            pm : "±",
            o : "ω",
            O : "Ω",
            r : "ρ",
            A : "∀",
            E : "∃",
            R: "ℝ",
            C: "ℂ",
            H: "ℍ",
            N: "ℕ",
            Q: "ℚ",
            Z: "ℤ",
            int: "\\int_{}^{}",
            inf : "∞",
            sum : "\\sum_{}^{}",
            "-1": "^{-1}",
            ph: "ϕ",
            ch: "χ",
            ps: "ψ",
            leq : "≥",
            xi : "ξ", 
            geq : "≤",
            "/=" : "≠",
            "==" : "≡",
            "<" : "\\langle {} \\rangle",
            "->" : "→",
            "=>" : "⇒",
            "<=" : "⇐",
            "<>" : "⇔",
            "sq" : "\\sqrt{}"
    }
};
if (options && options.corrections)
{
    options.corrections = jQuery.extend(defaults.corrections, options.corrections);
}
var opts = jQuery.extend(defaults, options);
getCaretPosition = function(oField)
{
    var iCaretPos = 0;
    if (document.selection)
    {
        var oSel = document.selection.createRange();
        oSel.moveStart("character", 0 - oField.value.length);
        iCaretPos = oSel.text.length;
    }
    else if (oField.selectionStart || oField.selectionStart == "0")
    {
        iCaretPos = oField.selectionStart;
    }
    return (iCaretPos);
}
function setCaretPosition (oField, iCaretPos)
{
    if (document.selection)
    {
        var oSel = document.selection.createRange();
        oSel.moveStart("character", 0 - oField.value.length);
        oSel.moveStart("character", iCaretPos);
        oSel.moveEnd("character", 0);
    }
    else if (oField.selectionStart || oField.selectionStart == "0")
    {
        oField.selectionStart = iCaretPos;
        oField.selectionEnd = iCaretPos;
    }
}
this.keyup(function(e)
{
    if (32 != e.keyCode)
    {
        return;
    }
    var caretPosition = (getCaretPosition(this) - 1);
    if (1 > caretPosition)
    {
        return;
    }
    var valueOfField = this.value;
    var stringUptoCaretPosition = (valueOfField).substr(0, caretPosition);
    if (" " == stringUptoCaretPosition.charAt(caretPosition - 1))
    {
        return;
    }
    var beginIndex = stringUptoCaretPosition.lastIndexOf('\\');
    if (beginIndex < stringUptoCaretPosition.lastIndexOf(' '))
    {
        return;
    }
    var stringToSearch = stringUptoCaretPosition.substring(beginIndex+1);
    var stringNotToSearch = stringUptoCaretPosition.substring(0, beginIndex);
    if (!opts.corrections[stringToSearch])
    {
        return;
    }
    var stringToReplace = opts.corrections[stringToSearch];
    stringUptoCaretPosition = stringNotToSearch+ stringToReplace;
    var stringFromCaretPositionUptoEnd = (valueOfField).substr(caretPosition+1);
    this.value = (stringUptoCaretPosition + stringFromCaretPositionUptoEnd);
    if (stringToReplace.indexOf("{}")!=-1 )
    {
    setCaretPosition(this, stringUptoCaretPosition.indexOf("{}")+1);
    }
    else { setCaretPosition(this, stringUptoCaretPosition.length);}

});
};
$(document).ready(function()
{
    $("textarea").autocorrect();
});
share|improve this answer

I like to use a software package for inputting characters from languages with non-Latin characters, such as Chinese. In, for example, Sogou pinyin one can define strings to be other strings of Unicode characters. Then, when typing, I quickly switch over to Chinese, write alpha, choose α from the list of suggestions and silently switch back to my original input language. This is really convenient!

share|improve this answer

Type up a short LaTeX fragment and tell them to cut and paste it into http://www.numberempire.com/texequationeditor/equationeditor.php and press "Render". Example:

\begin{align*}
R_s &\;=\; \frac{\widehat{\sigma}_s}{K} \left(\sqrt{1 - \sum^{15}_{k=1} \beta_k^2} \right) G_s
\quad.
\\
& \text{Parlez-vous Fran{\c c}ais? Czy mo\.zna u\.zy\'c tego?}
\\
& \mathbb{Z}_2 \oplus \mathbb{Z}_3 \cdots \oplus \mathbb{Z}_p,  
\end{align*}
share|improve this answer
1  
-1. I asked: "What I need is an easy way to type math related unicode symbols." You told me how to render latex online to an image. I don't see how what you say helps me. It doesn't allow me to paste the result anywhere. –  Elazar Leibovich Mar 25 '10 at 11:07
    
I said you should "tell them [your reader] to cut and paste" the LaTeX to the site to view the equations. –  Peon Mar 25 '10 at 19:06
    
It's really a burden. What if I include 10 small equations? What if I'm chatting with my friend, and he's reading it through a smartphone? –  Elazar Leibovich Oct 4 '11 at 7:30
    
If this disturbs you so much, why don't you write an app which translates unicode mneumonics to characters? Write it for his smartphone (Android, PalmOS, or WebOS), port it to Windows and Mac as well. Have it integrate with all existing apps too. If you are really deeply serious about it, of course. Otherwise you can have him learn to read Latex. Since your symbols are so limited, you can use an app that understands HTML and therefore can render unicode escape sequences into unicode characters. –  Peon Oct 5 '11 at 23:57
    
The nice thing about unicode is, I don't have to write the app for his smartphone. I can just type the unicode symbols, and they would appear nicely on his smartphone without any effort from my side. An app for windows is enough (and actually it's sort-of what I've written in the answer). –  Elazar Leibovich Oct 6 '11 at 4:51

You could use MSKLC to create a math-centric keyboard layout. For example eurokb includes symbols like ≡≤≠±∔π∜ on AltGr dead key combinations. (eurokb probably isn't math-heavy enough for you, but it might give you some ideas.)

share|improve this answer
    
The only downside is, no mnemonics at all. I'll have to memorize tens of keyboard combinations. BTW I think you should include a simulation of the keyboard mapping of your eurokb map on its website, and not just in the distribution. That would be useful for testing it. –  Elazar Leibovich Jan 4 '10 at 14:43
    
(I do: hit the UK or US documentation link and it's at the top.) Yeah, you would certainly have to come up with a logical way to arrange and remember the layout, but you've got quite a lot of latitude to play with when you can have any combination of two potentially-shifted-or-alted keys. The Greek letters you pretty much already have by doing as eurokb does and following the standard Greek keyboard layout (en.wikipedia.org/wiki/Keyboard_layout#Greek). Then you could group by function, eg. AltGr+S for set functions; AltGr+S,= for ∈, AltGr+S,/ for ∉, or whatever. –  bobince Jan 5 '10 at 2:49

If I need it I just tend to type the math in Word and copy/paste. Word uses the same macros LaTeX uses by default and auto-converts them into proper Unicode. And I find the linear format there more readable than LaTeX markup.

Still, if your mail recipients read from some dumb terminal or without proper font support (on XP maybe) you probably want to just type up raw LaTeX instead of Unicode just to allow them to understand what you want to say.

share|improve this answer
1  
First, I stated explicitly the use case. Online internet forum/chat. There's no sane webservice today that do not support UTF-8. I might not be able to use the more obscure symbols, but common machines with common unicode fonts has much more than I could use. I have no intention to support terminal, although xterm should be able to cope with that. About Word: (1) It works only with Office07, other math support lame. (2) I'm trying to avoid this context switch. What about chatting session? Alt-tab+Ctrl-C+Ctrl-v is not good enough. –  Elazar Leibovich Jan 3 '10 at 15:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.