16

Until I started diving into Mathematica, I was not using much computer software for symbolic computation. I did my analysis by hand on blank sheets, the calculations using Python or MATLAB, and the computer typesetting and presentations using LaTeX.

Mathematica could be (at least) a great supplement to each of these steps. However, I am frustrated by Mathematica's rendering of mathematical notation.


I got Mathematica (8 on Mac OS X) to automatically display unreadable variable names in a nicer mathematical notation, but the output in notebooks is quite bad:

Mathematica typesetting

I take as reference the equivalent in LaTeX:

LaTeX typesetting

  • I have difficulties to distinguish the Overbar of Mathematica from what is under, as it is often too close to the letters.
  • I find the monospace font inappropriate. The letters are too thick (they are not bold, but still disproportionately thick compared to lines in other mathematical elements, as seem in this screenshot). Or maybe it is the decorations and non-literal elements (integral sign, sqrt, overbars and fractions, brackets) that are not thick enough in comparison (particularly when increasing the font size, as seen in the linked example).
  • The spacing between tokens and symbols is unnaturally large, while it is slightly insufficient between two separate symbols (e.g., spacing between a and b in a b as compared to ab).
  • Also, maybe function names could benefit from having a slightly different style, although I am not certain of that.
  • The default font size is too small, but increasing the font size sufficiently to compensate for the poor typesetting makes information take more place than acceptable on the screen.

The official documentation on Math typesetting boasts Mathematica's "world most sophisticated tech", but it doesn't explain much about how to automatically adjust spacing or the fonts used.

Is there another typesetting guide I'm missing? Maybe downloadable stylesheets that redefine spacings and make use of Computer Modern or other high quality fonts? I would not have time to write my own stylesheet, I have no idea how to even begin, so a ready-made one would be preferable.


EDIT in response to answers: Here is an example of TraditionalForm side-by-side with the equivalent LaTeX output. There are clearly some differences in spacing, not all bad. The LaTeX version is more crowded around the fraction bar, while the Mathematica version is a bit too tight between the integral sign and its upper limit. Operators like $+$ are a bit smaller in the Mathematica version, too. enter image description here

agravier
  • 609
  • 4
  • 10
  • The monospace input is bold. The output is not by default, if you want the comparison. – David Jan 31 '12 at 17:16
  • Indeed. I probably failed at clearly explaining my point there, thanks for telling it to me. What I mean is that, in the output, the font weight is not balanced between letters/numbers and non-letters involving lines. I update the question to better show what I mean. (cf. this screenshot of a zoomed Mathematica output) – agravier Jan 31 '12 at 17:21
  • 1
    TraditionalForm is what you need. – faleichik Jan 31 '12 at 17:22
  • @faleichik : Thanks! Solves many of my issues! Two points: is there a way to make it a global default, without having to type it explicitly each time, and do you have a trick to make the Overbars higher than the default? – agravier Jan 31 '12 at 17:32
  • 3
    @agravier you could try MakeBoxes[OverBar[x_], TraditionalForm] := OverscriptBox[#, "_", DiacriticalPositioning -> False] &[ MakeBoxes[x, TraditionalForm]] – Rojo Jan 31 '12 at 17:45
  • @agravier I think it is possible, but actually don't know how. I'm sure people here do know. – faleichik Jan 31 '12 at 17:47
  • @Rojo Thanks! Now that I try your input and some more examples, I notice that the issue is in my definitions of math. symbols: I do stuff like MakeBoxes[Pmbar, form_] := InterpretationBox[OverscriptBox["Pm", "_"], Pmbar];, and I get the overbar problem when typing Pmbar; If I do OverBar["Pm"], it displays fine! Screenshot – agravier Jan 31 '12 at 18:03
  • 2
    @agravier Regarding your use of underscore, the reason that it is too close to the letters is because underscore by itself is set at the baseline, which doesn't leave much space. Try replacing it with \[HorizontalLine] or Esc-hline-Esc in your MakeBoxes[...]:= line. If that is satisfactory, I can edit it into my answer. – rm -rf Feb 01 '12 at 07:06
  • Yes @R.M, this is good for me. It's a thicker bar than the default OverBar, but I don't mix the default one with my symbols, so no problem. Thanks, I don't think editing your answer is necessary because this OverBar issue is kind of tangentially off-topic. Your call. And thanks again @Rojo, yours works great for the default OverBar :) – agravier Feb 01 '12 at 10:04
  • @agravier alright then, I'll leave my answer as it is :) but since the overbar issue is solved (temporarily, at least), perhaps it might be better to edit this post to only ask about typesetting your output similar to latex or something like that? If you then post your overbar problem as a second question, Rojo and I can post our approaches. I believe this might be a problem for someone else too, as using underscore for overbar seems like the right thing to do at first... – rm -rf Feb 01 '12 at 10:19
  • @R.M Good idea, I'll do that – agravier Feb 01 '12 at 15:35

2 Answers2

16

To format all your output expressions as TraditionalForm, you can set the $Post variable as:

$Post = TraditionalForm;

Here's how it would look:

Sin[x]/Cos[x + y]^3 + Integrate[Log[x], {x, 1, 2}] // HoldForm

Imagem1

Without HoldForm:

Sin[x]/Cos[x + y]^3 + Integrate[Log[x], {x, 1, 2}]

Imagem2

To clear the definition for $Post (if you need to), just evaluate $Post =. You can add this to your init.m if you'd like to make this apply to all notebooks henceforth, but I wouldn't suggest doing that.

LCarvalho
  • 9,233
  • 4
  • 40
  • 96
rm -rf
  • 88,781
  • 21
  • 293
  • 472
  • Thanks you @RM :) It seems that you have given the same answer in spirit as Arnoud, at the same time, but your way is more low-level, more Unixy. I am torn. Meta-question: how is one supposed to accept an answer when several good answers are present? – agravier Jan 31 '12 at 18:16
  • Thanks @RM. I accept yours because I'm more of a command-line type of guy and I like to understand the internals like $Post – agravier Jan 31 '12 at 18:59
15

Open the Edit -> Preferences menu and try setting the following:

enter image description here

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