Applied Statistics

Typing x-bar, y-bar, p-hat, q-hat, and all that! In Microsoft Word

This is how ILLUMINATED I felt when I figured out how to type statistical symbols in MS Word... the temple at Burning Man 2014. Image Credit: John David Tupper (photographerinfocus.com)

This is how ILLUMINATED I felt when I figured out how to type statistical symbols in MS Word… the temple at Burning Man 2014. Image Credit: John David Tupper (photographerinfocus.com)

I use Microsoft Word to prepare documents. I do not like Microsoft Equation Editor. And I have to type equations and expressions not often (like every sentence or every other sentence), but definitely regularly. This has led me to apply what I like to call “agile shortcuts” — basically, I’ll write down the equation in my own handwriting, take a picture of it, and then use a paint program to crop and clean up my equation before inserting it into my document. This works nicely, and even though some people might think it’s a kludge, I kind of like the ability to retain the personality of my own handwriting in my technical documents.

However, I don’t want to be embedding images if all I have to do is make reference to a variable within a paragraph of text… and I’ve never had a good solution. UNTIL THIS MORNING when I really, really, really wanted to be able to use y-bar and p-hat in my paragraph, without having to do the even kludgier thing where you just call them “y-bar” and “p-hat” in the text. That doesn’t feel good.

Even Arial Unicode MS, the behemoth of fonts (it even contains tons of Chinese, Japanese, and Korean characters) does not have essential statistical symbols. But turns out, it DOES have this very useful capability called “combining diacritics” — and here’s how you can use it to type characters with their own hats and bars on them:

1. Open up Microsoft Word

2. Choose “Arial Unicode MS” as your font

3. First, type in a letter that you want to adorn with a hat. Say, for example, p.

4. Next, go to Insert -> Symbol, drop down to “More Symbols”, and in the window that pops up, make sure you have selected “Arial Unicode MS” as the font. In the bottom right, you’ll see a text area and a dropdown. To the right of the text area labeled “Character code:” type in 0302. That’s the code for a hat-on-top-of-a-letter. Going further right, there’s a dropdown that says “from:” and you’ll want to make sure that you see “Unicode (hex)” selected in that box. Click “Insert”.

5. Voila, your p has a hat!! Now, type a few spaces and let’s do this again.

6. Only now, type in a letter that you want to adorn with a bar. Say, for example, x.

7. Next, go to Insert -> Symbol, drop down to “More Symbols”, and in the window that pops up, make sure you have selected “Arial Unicode MS” as the font. In the bottom right, you’ll see a text area and a dropdown. To the right of the text area labeled “Character code:” type in 0305. That’s the code for a bar-on-top-of-a-letter. Going further right, there’s a dropdown that says “from:” and you’ll want to make sure that you see “Unicode (hex)” selected in that box. Click “Insert”.

8. Voila again! Your x has a bar.

Go forth into the world and enjoy the same liberation I have just felt… o, ye writers of statistical stuff in documents.

25 replies »

  1. Hi, I tried this and it works! If the letter is upper-case, the symbol goes through it, but lower case p or x has the symbol above. The cursor has to be to the right of the letter to be correctly positioned. Great feature in MS Word.

    • Can you post a screen shot of what comes up after you do Insert->Symbol? I don’t use Macs, but would be interested in figuring this out for Macs too.

  2. Found a way to correct the bar and letter misalignment and goes through the upper case letter. Type a letter, then go to Symbol, In “Font”, select Arial, and choose “Combining Diacritical Marks” in Subject. Type 0304 for lower case, and 0305 for upper case and insert it. Afterwards, mostly the upper case will not align. The correction is to do “copy/paste”. Copy it (both letter and bar) and paste it as text ( A in Word and 123 in Excel). It works in MS office 2010. If need more bars on top, inert bar twice, you double bars on top, and so on.

  3. If you’re looking for a way to not have to do so many mouse clicks and interrupt your typing, there are options to TYPE many math symbols and operators.
    For example, “x\bar” will produce x̅, or “q\hat” will produce q̂. For Greek letters “\sigma” produces σ, while “\Sigma” produces Σ. (In all of these cases, do NOT type the quotes.)
    Click on File > Options > Proofing > AutoCorrect Options > Math AutoCorrect
    Check the box next to “Use Math AutoCorrect rules outside of math regions”
    — This allows you to use these math and symbol typing short-cuts outside of the equation tool (a little mini-window within your document for equations). Equation”.
    Check the box next to “Replace as you type”
    — This initiates a special kind of AutoCorrect that replaces the text you are typing with symbols or diacritical marks.
    You can find a list of typing shortcuts here: https://support.office.com/en-za/article/Math-AutoCorrect-symbols-b8b463d9-f47d-45c4-a00f-9245c2b38843
    Or, if you have an equation tool open, you can hover your cursor over the symbol and the name of the symbol and any available typing shortcuts (e.g. “Infinity (\infty)”) will appear.

  4. This is an AMAZING tip! I do layouts which have the odd letter with a hat in, and this will make then look so much better! Thank you for finding out how to do this!!

  5. @Nicole. I’m surprised that if you write equations often in your work and are a fan of quality that you don’t move to software such as LaTeX. Not as intuitive to begin with as word, but once mastered produces fantastically amazing documents.

    • Hi Charles — I use LaTeX often (since mid 90’s)… but my students don’t, and I’d rather they focus on the material than on the typesetting of equations. Definitely agree though, once you get over the LaTeX learning curve, there’s no comparison! 🙂

  6. Hi Nicole, great thread and it pushed me to figure this out for Office for Mac 2016. I found it’s an easy solution on Word for Mac and hope it’s the same for previous versions: select Word from the menu and go to Preferences. Then select AutoCorrect. Click the radio button for “use Math AutoCorrect rules outside of math regions.” There is a list of about 100 math symbols that will be replaced automatically. For example, typing X\bar will be replaced by an X with a bar on top. Typing X\Bar will be replaced by an X with a double bar on top. Typing \div will insert the division symbol. Really great shortcuts.

    • Thanks!! As a non Mac user, I would not have ventured into attempting a solution, so your contribution is very VERY much appreciated 🙂

  7. This is great as far as it goes. I can do y\bar and q\hat but unfortunately it does not work well for Greek symbols such as \theta\hat. The hat gets lost in the Greek letter. Any suggestions?

  8. Thank you for taking the time to find out this information and sharing it with us! I am taking my first stats for psych class and googled how to make “p-hat”, and your blog article was the first hit. I am so grateful for Google and for wonderful people like you. 🙂

  9. Thank you so much for posting! I have been trying to figure this out for YEARS and you are the only person that has explained a method that works!

  10. I’m using Word 2013 and what I found to look best (good enough for me) are simply the BOLD Capital letters of “Times New Roman” (go figure). I’d show you, but I guess I can’t use Times New Roman here.

    For numbers greater than 4,999 you’ll need one or more overbars. There’s a few ways to do an overbar, but the one that looks best to me can be done by inserting a symbol. Let’s say you want to represent 106,748. Using Times New Roman, BOLD, type capital “C”, go to Insert -> Symbol -> More Symbols (the shortcut to get there is Alt-n-u-m), then for font (Alt-f) choose “(normal text)”, then in the lower right of the dialog (Alt-c), choose “Character code: 0305” and at the top right, the Subset should automatically switch to “Combining Diacritical Marks”. If it doesn’t, make sure you typed the letter “C” using Times New Roman, but in any case, you need to choose “(normal text)” or some other font that gives you “Combining Diacritical Marks” and a valid symbol at 0305. Next, back to the lower right corner (Alt-m), make sure it says “from: Unicode (hex)”, then finally press the Insert button (Alt-i, left arrow, Enter). Now your “C” should have an overbar. Next type “V” and when you go back to Insert -> Symbol (Alt-n-u), the last symbol that was used should always appear as the first choice in the upper left of the pull-down, so press Enter (or click the symbol) and your “V” should have its overbar, too. (If not, check all those previous steps again.) Last type “MDCCXLVII” and your final result should be the Roman numeral for 106,748: C̅V̅MDCCXLVII

    I had mixed results simply using the “0305 Alt-x” shortcut. Sometimes I could type the letter immediately followed by the number “0305” (no space) and then Alt-x and it usually inserts the overbar, but sometimes it didn’t work correctly. However, going up to the Insert Symbols dialog and making sure all the options were correct always worked.

    Hope that helps.

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