Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OverVector can be used to make a symbol look like a vector in text sections of documents. I happen to like bold symbols for vectors better, as in latex \mathbf{x} output.

I've found that I can do, say, Style[x, Bold], but this is actually a very subtle seeming change, and I find it hard to actually notice the difference. Perhaps this is because the default font picked for variables is something quite different from what one gets with \mathbf. If this is just a font issue, what's a good font for this sort of output (i.e. like \mathbf{x}), and how would it be selected?

Also, the Style function applies to expressions, whereas I want it to apply to just particular variables (i.e. leaving scalars in regular font), so that when they are used in input, the output comes out in the desired way.

Is there a mechanism to declare a variable, and have specific style settings associated with it, so that it is displayed in the desired way?

share|improve this question
up vote 7 down vote accepted

I am not sure I understand your needs, but consider this:

Format[OverVector[v_]] := Style[HoldForm[v], FontFamily -> "Arial Black"]

{q, r, OverVector[s], t, u, v}

Mathematica graphics

share|improve this answer

This is mainly an add-on to David solution. I'm new in SE, so I can't comment yet. So I put it in an answer.

One could maintain a list of the symbols, which should be displayed as vectors, eg:

vList = {}
defAsVector[x__Symbol] := (vList = Union[Join[vList, {x}]];)
defAsVector[] := vList
undefAsVector[x__Symbol] := (vList = Complement[vList, {x}];)
undefAsVector[] := (vList = {}; $PrePrint =.;)
$PrePrint = # /. {x_ /; MemberQ[vList, x] :> Style[x, Bold]} &;
share|improve this answer

I only have my iPhone now, but something like this should work well.


Better yet you could 'declare' that certain symbols represent vectors.

share|improve this answer
  • You can specify a different font by using the FontFamily parameter for Style: enter image description here

  • If you want specific symbols to be printed differently on output, you may want to have a look at $Post and $PrePrint. For example, the following prints the symbol x bold and in Helvetica:

(Ignore this line, tricking the bad markup of SE)

$PrePrint =.
$PrePrint = # /. {x -> Style[x, Bold, FontFamily -> "Helvetica"]} &;

enter image description here

Be careful though, a styled object can have unwanted side effects. Therefore, in this paragraph, I sincerely disencourage you to change styling of symbols you want to do calculations with, and would recommend doing the prettyprinting in the very end, using an explicit handcoded function.

share|improve this answer
What kind of bad side effects are you thinking of? Don't have time to fiddle with this, but I thought of using Interpretation to make the output re-usable, what do you think? – Szabolcs Feb 24 '12 at 8:53
Imagine you've got something with a style and apply some definitions to it, and then use the normal symbol again - not fun to fix. In other places both of them might be equivalent, I don't think there's a consistenz way of doing it. Interpretation is a very good idea though. – David Feb 24 '12 at 9:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.