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:

CommonDefaultFormatTypes -> {"Output" -> TraditionalForm}]
Derivative /: 
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]], 
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.

  • $\begingroup$ 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? $\endgroup$
    – yarchik
    Apr 29, 2021 at 16:20
  • $\begingroup$ 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 $\endgroup$ Apr 29, 2021 at 16:49

1 Answer 1


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

  • $\begingroup$ Thanks for your comment Carl, is there any way I can plug it into the general definition (provided in my question) so it will automatically do it for every output? $\endgroup$ Apr 29, 2021 at 17:22
  • $\begingroup$ @OfekPeretz I'm not aware of any way to do that. $\endgroup$
    – Carl Woll
    Apr 29, 2021 at 17:52
  • $\begingroup$ Ok, thanks Carl, I’ll update here if I’ll find a way $\endgroup$ Apr 29, 2021 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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