0

I was following a code given by Jens in the following Question and I want to improve the way my equation is displayed. The current code I'm using:

SetOptions[EvaluationNotebook[], 
CommonDefaultFormatTypes -> {"Output" -> TraditionalForm}]
Derivative /: 
MakeBoxes[Derivative[\[Alpha]__][f1_][vars__?AtomQ], 
TraditionalForm] := 
Module[{bb, dd, sp}, MakeBoxes[dd, _] ^= "\[PartialD]";  
MakeBoxes[sp, _] ^= "\[ThinSpace]";  
bb /: MakeBoxes[bb[x__], _] := RowBox[Map[ToBoxes[#] &, {x}]];
TemplateBox[{ToBoxes[bb[dd^Plus[\[Alpha]], f1]], 
ToBoxes[Apply[bb, 
Riffle[Map[
bb[dd, #] &, (Pick[{vars}, #]^Pick[{\[Alpha]}, #] &[ 
Thread[{\[Alpha]} > 0]])], sp]]], 
ToBoxes[Derivative[\[Alpha]][f1][vars]]}, "ShortFraction", 
DisplayFunction :> (FractionBox[#1, #2] &), 
InterpretationFunction :> (#3 &), Tooltip -> Automatic]]

and for the following equation

T[x, t] == ((h - y) (2 \[Mu] - x) D[p[x, t], t] + (x + y) D[    l[x, t], {t, 2}])/(2 h \[Mu] l[x, t])

I get this output:

enter image description here

and I want to display each derivative outside of the fraction, as in the following form: enter image description here

Meaning, I want to output each derivative as a coefficient times the derivative term.

I hope my question is clear enough and thanks for your time and effort.

Ofek Peretz
  • 397
  • 1
  • 8
  • Mathematica can be used to typeset formulas, Microsoft Word can be used to solve partial differential equations, and Nintendo Switch can be used to watch Youtube videos. But you will be better off by using the dedicated tool for each task. If your goal is to typeset an equation for a report, why not using LaTeX or overleaf? – yarchik Apr 29 '21 at 16:20
  • Currently I’m doing the analytic derivation in Latex and than copy the governing equation to Mathematica and solve it. Im trying to make a single document that will do it all together. So by using mathematica, for example, if I’m changing a boundary condition in the beginning of the analysis, it will be updated automatically in all the paper – Ofek Peretz Apr 29 '21 at 16:49

1 Answers1

3

If you wrap the factors in front of the derivatives in HoldForm, you can get the output you want:

RHS = ((h-y) (2 \[Mu]-x) D[p[x,t],t]+(x+y)D[l[x,t],{t,2}])/(2 h \[Mu] l[x,t]);

T[x,t] == Collect[RHS, Derivative[][__], HoldForm] //TraditionalForm

enter image description here

Carl Woll
  • 130,679
  • 6
  • 243
  • 355