Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I find that the equations I write in Mathematica are not always publication quality. Here is a typical example:

in-cell equation from a notebook

If I copy as Latex, then I get the following code:

\frac{\sum _{i=1}^N \frac{(k|k) \tilde{x}_j^i}{\sqrt{P_{\text{jj}} (k|k)}}}{N}

This code is actually kind of messed up and does not reproduce the equation correctly, but it is easy to manually edit it to create the right Latex code:

\frac{1}{N}{\sum _{i=1}^N \frac{ \tilde{x}_j^i(k|k)}{\sqrt{P_{\text{jj}} (k|k)}}}

Now, if we render this Latex code we get a much nicer looking version of the same equation:

Latex version of the same equation

The sigma looks better, variables are italicized, the vertical line (not sure what it is called) looks much better. The runt vertical line in Mathematica just looks really bad. Also, the coloring is removed, which for my purposes is better because I am including the equation in black and white text and do not want randomly colored symbols.

My question is: how can I make the equation look better in the notebook? For example, if I am using Mathematica to make a slide show or presentation, I want the equation to look as professional as possible, but still be an editable cell. What are my options?

Note that using TraditionalForm has the following consequences:

TraditionForm of Summation

Update

If we really torture it with both Defer and HoldForm, looks like we can get the typeset equation:

Typeset equation using TraditionalForm and HoldForm and Defer

share|improve this question
3  
If you want publication quality does this mean you want these equations for display rather than for evaluation? If so then begin by using text cells rather than input cells and start with Control - 9. Alternatively you could use TraditionalForm in your input cell Cell > Convert to > TraditionalForm –  Mike Honeychurch Nov 9 '13 at 20:47
    
This is related to e.g. How to make traditional output for derivatives there you can find another links. –  Artes Nov 9 '13 at 20:48
2  
re: your update. You need to be clear about what you are asking. Your update renders traditional looking output. Yet elsewhere in your question you have said "but still be an editable cell" which based on your comments below where you ask for the stuff to be "calcuable" presumes you mean evaluatable. Do you want a traditional looking rendering that you can evaluate or not? –  Mike Honeychurch Nov 9 '13 at 23:17
    
I guess the main use case is that it is easily modifiable, not necessarily editable. For example, in a presentation you can hide the input cell so the presentable form is visible, then if you need to edit the equation you can unhide, edit the input cell, then hide it again. The main objective is to make a publishable/presentable notebook without hacks like pasting images of equations, and is calcuable (so pure text equations will not be possible in some cases, unless you hide the "real" equation and create a duplicate text equation). –  Tyler Durden Nov 9 '13 at 23:23
1  
Then use TraditionalForm input cells. –  Mike Honeychurch Nov 9 '13 at 23:33

1 Answer 1

up vote 12 down vote accepted

Typesetting in Text cells

Cell[TextData[Cell[BoxData[
 FormBox[
  RowBox[{
   FractionBox["1", "N"], 
   RowBox[{
    UnderoverscriptBox["\[Sum]", 
     RowBox[{"i", "=", "1"}], "N"], 
    FractionBox[
     RowBox[{
      SubsuperscriptBox[
       OverscriptBox["x","~"], 
       "j", "i"],
       "(", 
      RowBox[{"k", "|", "k"}], ")"}], 
     SqrtBox[
      RowBox[{
       SubscriptBox["P", "jj"], "(", 
       RowBox[{"k", "|", "k"}], ")"}]]]}]}], 
  TraditionalForm]]]], "Text",
 UnderoverscriptBoxOptions->{LimitsPositioning->False},
 OverscriptBoxOptions->{DiacriticalPositioning->True},
 FractionBoxOptions->{AllowScriptLevelChange->False}]

gives

enter image description here

This was typeset in a text cell by starting with Ctrl-9 and then typing

enter image description here

The default ScriptLevel for inline cells is 1 so I set that to 0 in a private style (Format > Edit Stylesheet):

enter image description here

The additional UnderoverscriptBox, OverscriptBox and FractionBox options were set via the option inspector. You can do additional tweeking by nudging terms around via Insert > Typesetting.

Typesetting in Input cells

Wrapping TraditionalForm around your expression, as per your updated question, is intended to render the output as traditional form. However your question seems to be framed around having traditional looking equations that -- based on your update -- can be evaluated.

If you want all you input and output to appear like this then set this globally in your preferences:

enter image description here

Then in your input cells you can type the equation and it will appear in traditional form:

enter image description here

If you only want to convert certain cells then either make the changes via the menu Cell > Convert To or via a right click:

enter image description here

which produces:

enter image description here

share|improve this answer
    
Ok, that seems to be a way to typeset an equation in the notebook, but in that case its not a calcuable equation is it, its just text right, or not? –  Tyler Durden Nov 9 '13 at 22:54
    
Well you can't evaluate LaTeX either. If you want textbook looking stuff but you want to evaluate then use TraditionalForm –  Mike Honeychurch Nov 9 '13 at 22:55
    
That seems like a good direction, but as shown above in the updated question when I use TraditionalForm it changes the equation. Is there a way to use TraditionalForm and maintain the same equation? Even if I use Defer, it still changes the order of terms. –  Tyler Durden Nov 9 '13 at 22:57
    
You could do TraditionalForm @ HoldForm @ Sum[i,{i,1,n}] –  Rolf Mertig Nov 9 '13 at 23:06
    
That does indeed work if you use a combination of Defer on the 1/N, then use an outer HoldForm –  Tyler Durden Nov 9 '13 at 23:09

Your Answer

 
discard

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.