Revised Oct 23, 2012
A common question I get (at least common in Unicode terms) is what the code is for the p-hat (p̂) symbol and x-bar (x̄) symbols in statistics. Although these are common symbols, they haven’t made it as a single character into Unicode (much like there thermodynamic dot symbols are half missing unless they are also in Old Irish or another foreign language’s spelling system.
The good news is that they can be created in Unicode, but it’s quirky. The trick here is to forget math and think phonetics. There is a mechanism to place any diacritic/accent mark over any letter using one of the combining diacritics These are accents, but with a spacing specification that basically says to go backwards over the previous letter.
There’s a list of various combing diacritics for HTML at our sister site, Penn State Computing with Accents Diacritics page, but I’ll explain how it works for x̄ and p̂
For HTML, I recommend inputting the base letter (x or p) then the appropriate numeric escape code for the combining diacritic. See code examples below:
View the HTML Code
x-bar = x̄ or x̄ (hex)
p-hat = p̂ or p̂ (hex)
If the result of your code is something like p^or ^p rather than p̂, the problem is usually the font. Relatively few fonts support combining diacritics well (not even math fonts support diacritics well). Those that do are phonetics oriented and these include include:
- – Arial Unicode MS
- Unicode Symbols
- SIL Fonts – The SIL has created
- Junicode – Includes characters for medieval languages
- Aboriginal Serif – Includes Cherokee, Canadian Aboriginal, Central Asian Cyrillic
The first two fonts come from Microsoft/Apple, are commonly installed, and also include math symbols…but they are sans-serif fonts. If you want a serif font, you may want to specify one of the other serif phonetics fonts, then point users to it (but specify Arial Unicode/Lucida Grande as backups). Not a very pretty solution at the moment.
And now the fun really begins. You can input these characters in other programs (see below), but editing them will be odd (see below). Here’s the procedure:
- Switch to a font which supports combining diacritics and type the base letter (x or p in this case).
- Type a space and move your cursor back (you’ll thank me for this tip):
- Then you can insert the combining diacritic:
- With the Character Map (Windows) or Character Palette (Mac) OR:
- With an Alt code in Word for Windows or an Option code on the Mac Hex keyboard. See codes at http://tlt.its.psu.edu/suggestions/international/bylanguage/ipavowels.html The Word/Windows ALT code for x̄ x ALT+0772. The Option Hex code for on the Mac x Option+0304
When you edit, you will discover that sometimes you will delete the accent, and sometimes you will delete the letter beneath the accent (very entertaining). You may need to undo your delete move your cursor with your arrow keys when that happens. It doesn’t always look like the cursor is moving, but it is in Unicode text land. When you are trying to type a nasalized open-o /ɔ̃/, you do get some practice….