I am manipulating partial differential equations symbolically, and would like to get the easily readable form $\rho \frac{\partial v}{\partial t}$, leaving variables implicit.

Based on suggestions from How to make traditional output for derivatives I started out with

Derivative /: 
  MakeBoxes[Derivative[α__][f1_][vars__Symbol], TraditionalForm] := 
    Module[{bb, dd, sp},
      MakeBoxes[dd, _] ^= 
      If[Length[{α}] == 1, "\[DifferentialD]", "∂"];
      MakeBoxes[sp, _] ^= "\[ThinSpace]";
      bb /: MakeBoxes[bb[x__], _] := RowBox[Map[ToBoxes[#] &, {x}]];
      TemplateBox[{ToBoxes[bb[dd^Plus[α], f1]], 
        Riffle[Map[bb[dd, #] &, 
        Select[({vars}^{α}), (# =!= 1 &)]], sp]]], 
        ToBoxes[Derivative[α][f1][vars]]}, "ShortFraction", 
        DisplayFunction :> (FractionBox[#1, #2] &), 
        InterpretationFunction :> (#3 &), 
        Tooltip -> Automatic]]

When functions appear outside of partial derivatives, they still appear as $v(t,x)$. Trying to fix this, I tried

supressVariable[f_Symbol] := 
  f /: MakeBoxes[f[t, x], TraditionalForm] :=
    InterpretationBox[ToBoxes[f], f[t, x]]
SetAttributes[supressVariable, Listable]
supressVariable[{v, ρ, p, f}];

This works fine for both

f[t, x] v[t, x] == 0 // TraditionalForm


ρ[t, x]*Derivative[0, 1][v][t, x] + 
   v[t, x]*Derivative[0, 1][ρ][t, x] + 
   Derivative[1, 0][ρ][t, x] == 0 // TraditionalForm

producing nicely readable equations. However, the simple

f[t, x] == 0 // TraditionalForm

gives error message

An unknown box name (ToBoxes) was sent as the BoxForm for the expression. Check the format rules for the expression

and I don't know what to do with this. Can anybody help me out?

  • $\begingroup$ I can't resist pointing out that suppress is written with two p... $\endgroup$
    – Jens
    Aug 24, 2014 at 19:26

2 Answers 2


It seems to me that using MakeBoxes in this case is overkill. How about this simpler definition?

supressVariable[f_Symbol] := 
 Format[f[t, x], TraditionalForm] := Interpretation[f, f[t, x]]

SetAttributes[supressVariable, Listable]
supressVariable[{v, ρ, p, f}];

This doesn't encounter the issue you faced, because the symbol f is passed directly to Interpretation (no need to wrap it in ToBoxes at all).

  • $\begingroup$ Be aware that MakeBoxes can have superior behavior to Format in some ways. See this Q&A: (4112299) $\endgroup$
    – Mr.Wizard
    Aug 25, 2014 at 19:06
  • $\begingroup$ @Mr.Wizard Are you saying that there is anything wrong with Format in the context of this question? Note that the question is only about formatting for TraditionalForm. $\endgroup$
    – Jens
    Aug 25, 2014 at 20:39
  • $\begingroup$ You're right; since TraditionalForm is not for editing anyway I guess my concern is baseless. I merely got in the habit of using MakeBoxes preferentially to Format most of the time. +1 $\endgroup$
    – Mr.Wizard
    Aug 25, 2014 at 21:07

InterpretationBox holds its arguments (it has HoldAllComplete). You must evaluate ToBoxes[f] outside of this head, easily accomplished with Function as follows:

supressVariable[f_Symbol] := 
  f /: MakeBoxes[f[t, x], TraditionalForm] :=
    InterpretationBox[#, f[t, x]] & @ ToBoxes[f]
  • $\begingroup$ Could you please be a bit more explicit on how it works? $\endgroup$
    – chris
    Aug 24, 2014 at 12:34
  • $\begingroup$ Actually I think it needs to be made listable $\endgroup$
    – chris
    Aug 24, 2014 at 12:38
  • $\begingroup$ @chris This isn't complete code; it is to replace only that one "line" in the OP's code. By default a Function will evaluate its arguments; consider: Hold[#, 2 + 2] &[1 + 1] $\endgroup$
    – Mr.Wizard
    Aug 24, 2014 at 18:59
  • $\begingroup$ Yes, this solution works well. Seeing this, I don't understand how my original attempt worked at all, though. $\endgroup$
    – Åsmund Hj
    Aug 25, 2014 at 13:23

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.