bar and hat only apply to certain letters

(I'm navigated from stackoverflow.com where I asked almost the same question)

I'm a beginner in Mathematica. Like shown in the image below, I'm trying to put hat and bar to some letters in a statement (I basically want to write vector notation) but only some letters can have them. What's wrong with how I do?

In the stackoverflow.com page I cited above, someone suggested functions OverHat/OverBar. These could do the similar work when I only want a letter in a line. But as I described, I want to write a statement, which consists of left-hand & right-hand sides, where those functions might not work as it seems.

If you could provide online resource that covers these syntax, that would be more appreciable. Thank you.

(Environment) { Mac OSX 10.7, Ubuntu 11.10, Ubuntu 10.10}, Mathematica 8.0.4 Student Edition

-
OverHat is simply the FullForm version. You can use the shortcut ctrl-Shift-7 (on Mac) to get into 2D input, then esc ^ esc to make the hat. I was able to assign things to variables that way. –  JxB Feb 1 '12 at 2:24
I just chose the best easiest solution but all the answers given so far are of value to me for learning Mathematica's functionality. Thx –  IsaacS Feb 1 '12 at 4:12
What no one has mentioned is that "composed" names (which are not atomic symbols, like Overbar[a]) can be cumbersome to work with. See any/all of the following: mathematica.stackexchange.com/q/1004/12 stackoverflow.com/q/4253883/695132 stackoverflow.com/q/5481216/695132 mathematica.stackexchange.com/q/373/12 mathematica.stackexchange.com/q/869/12 –  Szabolcs Feb 1 '12 at 8:57

You can use the menu Palettes -> Basic Math Assistant and click the overscript button:

Then you can type j, followed by the tab key, followed by ^.

It should be possible at this point to assign to this typesetting construct.

Also, in this same grid of buttons you will see a button with a black square and a ^ already on top of it, which should save you one step. There is also a button for the overbar construction.

-

Taking the recommendation from the StackOverflow thread:

In addition to Ctrl+Shift+7 and then _ or ^, you can also use OverBar[thing] or OverHat[thing], select the expression and press Ctrl+Shift+N to convert to InputForm

-

The reason why some letters work using the esc a ^ esc and others not is that the ones that do have their own atomic symbol name in the Mathematica language.

ô // FullForm
\[OHat]


Versus

\!$$\*OverscriptBox[\(h$$, $$^$$]\) // FullForm
(* sorry that's how it pasted across *)
OverHat[h]


The ones that have atomic representation are all vowels: here is a list in the online documentation. Note that capital vowels with hats also work.

As Spartacus' answer shows, you can use the OverHat and OverBar syntax for the other letters to assign expressions to them.

-

What has not been mentioned so far is that putting hats on the garden variety i's and j's is, well, somewhat ugly. This is precisely why Mathematica provides for the dotless versions, "$\imath$" and "$\jmath$". Try typing OverHat[\[DotlessI]] and OverHat[\[DotlessJ]] on the front end.

-

As a comment to J.M.s answer, if you find the OverBar too close to your letters you can insert an additional Overscript:

   OverBar[Overscript["YourExpression", Style["", 1]]]

-

In addition to what is already written about it, if you need to make vectors you might like to use this

OverVector[x]


Try it. All this is for the use in input fields. If what you need is the text field, however, you may be more comfortable with accepting the notations typical for scientific journals, where vectors are printed in bold. Use then the in-line math cell for formulas (Ctrl+9), and in it you may use bold and plain.

-