Unicode For Mathematical Typesetting

In the last month, the way I typeset math has changed dramatically. It’s a result of a combination of several tools that I’ve discovered.

The first is XCompose. If you’re on a Unixy OS (Linux/Mac/etc) you can easily typeset in unicode using XCompose. You set a key to be your XCompose key (for me it is Caps Lock) and then you can hit it and enter a series of symbols that map to a unicode character; you choose the codes that map to characters with the file ~/.XCompose. It’s a little bit like how backslash works in LaTeX, but at the input level.

Using this awesome XCompose file you get nice things like the following:

  • <compose> * a → α
  • <compose> * b → β
  • <compose> | R → ℝ
  • <compose> | Q → ℚ
  • <compose> ^ 1 → ¹
  • <compose> ^ 2 → ²
  • <compose> _ 1 → ₁
  • <compose> _ 2 → ₂
  • <compose> i n → ∈
  • <compose> n i → ∋
  • <compose> & i n t → ∫
  • <compose> & o i i n t → ∯

As you can see, it’s inspired by LaTeX. If you know LaTeX, you’ll pick it up very fast.

By itself, XCompose is great as a solution to typing math online. If you want to type into a tweet or a reddit post, its perfect.

(Other options exist: Unicodedeit (Mac/Linux) allows one to highlight LaTeX and it will convert it into unicode. It has an online version that is cross platform.  Windows has built in solutions, but they require memorizing unicode codes.)

Then a natural question arises: can LaTeX accept unicode? And the answer is that theres a package for that. In particular, a lot of unicode support can be gained with the following:


\usepackage[utf8x]{inputenc}
\usepackage{amssymb}

Awesome. It isn’t perfect though. $α$ will cause errors because it maps α to \textalpha. Blackboard causes problems because it maps to \mathbbm rather than \mathbb. There’s also some characters like ⅓ that it doesn’t support. We can fix that though:

\let\textalpha=\alpha
\let\mathbbm=\mathbb
\DeclareUnicodeCharacter{8531}{\frac{1}{3}}

This allows for much simpler LaTeX. Compare

\item Suppose not. Then $(∃S, μ(S)=ε>0)(∃δ>0)(∀x∈S)(∀n∈ℕ)(f_n(x)>δ)$. Then it must be the case that $∫f_n>εδ$. Then $∫f_n \not → 0$.

with

\item Suppose not. Then $(\exists S, \mu(S)=\epsilon>0)(\exists \delta>0)(\forall x \in S)(\forall n∈\mathbb{N})(f_n(x)>\delta)$. Then it must be the  case that $\int f_n> \epsilon \delta$. Then $\int f_n \not \to 0$.

One of them is much easier to read.

About these ads

Tags: , ,

3 Responses to “Unicode For Mathematical Typesetting”

  1. Ansgar Says:

    You can use something like XCompose on Windows, too.

    http://sourceforge.net/projects/allchars/

  2. Vikhyat Korrapatit Says:

    I wrote another web-based tool like unicodeit.net recently: http://vikhyat.net/stuff/latex_to_unicode/

  3. Michael Ummels Says:

    For unicode support in math mode, have a look at unicode-math: https://github.com/wspr/unicode-math (works only with LuaTeX and XeTeX though). This saves you from redefining \textalpha et al.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

Join 464 other followers

%d bloggers like this: