6

(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?

enter image description here

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

IsaacS
  • 583
  • 1
  • 4
  • 14
  • 1
    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 01 '12 at 02: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 01 '12 at 04: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: http://mathematica.stackexchange.com/q/1004/12 http://stackoverflow.com/q/4253883/695132 http://stackoverflow.com/q/5481216/695132 http://mathematica.stackexchange.com/q/373/12 http://mathematica.stackexchange.com/q/869/12 โ€“ Szabolcs Feb 01 '12 at 08:57

6 Answers6

6

Taking the recommendation from the StackOverflow thread:

Mathematica graphics

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

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
6

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.

Verbeia
  • 34,233
  • 9
  • 109
  • 224
6

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
5

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

enter image description here

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.

Arnoud Buzing
  • 9,801
  • 2
  • 49
  • 58
1

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]]]
malumno
  • 349
  • 1
  • 11
0

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.

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96