Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've tried searching here and in the WRI documentation, but I haven't found what I'm looking for in either place.

I'm defining a dx operator to act as a shorthand for D[#,x], based on this question. In my case, I want Mathematica to produce an output form with the text d/dx expression = [...], where by [...] I mean the actual symbolic meaning of my dx operator (i.e., D[#, x]).

I have tried this:

Format[dx[a_] := "\!\(\*FractionBox[\(d\), \(dx\)]\)"  a  "="  D[a, x]]

I've also tried

Format[dx[#], TraditionalForm] := 
    RowBox[{FractionBox["\DifferentialD]", "\[DifferentialD]x"],
    #, "=", D[#, x]}]];

and various other similar things, none of which produce the correct expression.

I would appreciate help with getting this right.

share|improve this question
up vote 9 down vote accepted

You can use something like this

dx /: MakeBoxes[dx[a_], fmt_] := 
  RowBox[{FractionBox["\[PartialD]", "\[PartialD]x"], 
    MakeBoxes[a, fmt], "=", MakeBoxes[#, fmt] &@D[a, x]}];


enter image description here

dx[Sin[x]] // TraditionalForm

enter image description here

I prefer MakeBoxes but it also can be implemented with Format


Format[dx[a_]] := 
  DisplayForm@RowBox[{FractionBox["\[PartialD]", "\[PartialD]x"], MakeBoxes[a], 
     "=", MakeBoxes[#] &@D[a, x]}];


enter image description here

share|improve this answer
What does the MakeBoxes[#] refer to? Does it refer to the result supplied by the later @D function? – Trevor Oct 7 '13 at 13:33
@Trevor MakeBoxes[#]&@D[a, x] inserts evaluated D[a, x] into MakeBoxes. Evaluate doesn't work here because MakeBoxes has HoldAllComplete attribute. – ybeltukov Oct 7 '13 at 13:40
Thanks a lot. I will learn your answer. It has great value for me. – Trevor Oct 7 '13 at 14:10

Your Answer


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.