# How to make traditional output of derivatives display like an equation

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],
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:

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

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.

• 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? Apr 29, 2021 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 Apr 29, 2021 at 16:49

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


• 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? Apr 29, 2021 at 17:22
• @OfekPeretz I'm not aware of any way to do that. Apr 29, 2021 at 17:52
• Ok, thanks Carl, I’ll update here if I’ll find a way Apr 29, 2021 at 20:39