(*^

::[paletteColors = 128; 
	fontset = title, "New York", 24, L3, center, bold, nohscroll;
	fontset = subtitle, "New York", 18, L2, center, bold, nohscroll;
	fontset = subsubtitle, "New York", 14, L2, center, bold, nohscroll;
	fontset = section, "New York", 14, L2, bold, nohscroll, grayBox;
	fontset = subsection, "New York", 12, L2, bold, nohscroll, blackBox;
	fontset = subsubsection, "New York", 10, L2, bold, nohscroll, whiteBox;
	fontset = text, "New York", 12, L2, nohscroll;
	fontset = smalltext, "New York", 10, L2, nohscroll;
	fontset = input, "Courier", 12, L2, bold, nowordwrap;
	fontset = output, "Courier", 12, L2, nowordwrap;
	fontset = message, "Courier", 12, L2, R65535, nowordwrap;
	fontset = print, "Courier", 12, L2, nowordwrap;
	fontset = info, "Courier", 12, L2, nowordwrap;
	fontset = postscript, "Courier", 12, L2, nowordwrap;
	fontset = name, "Geneva", 10, L2, italic, B65535, nowordwrap, nohscroll;
	fontset = header, "Times", 10, L2;
	fontset = footer, "Times", 12, L2, center;
	fontset = help, "Geneva", 10, L2, nohscroll;
	fontset = clipboard, "New York", 12, L2;
	fontset = completions, "New York", 12, L2, nowordwrap;
	fontset = network, "Courier", 10, L2, nowordwrap;
	fontset = graphlabel, "Courier", 12, L2, nowordwrap;
	fontset = special1, "New York", 12, L2, nowordwrap;
	fontset = special2, "New York", 12, L2, center, nowordwrap;
	fontset = special3, "New York", 12, L2, right, nowordwrap;
	fontset = special4, "New York", 12, L2, nowordwrap;
	fontset = special5, "New York", 12, L2, nowordwrap;]
:[font = input; initialization; ]
*)
(*
    Package:       DFormat
    Function:      Fancy formatting of partial derivatives
    Written:       by Pekka Janhunen, Finnish Meteorological Institute,
                   Geophysics Dept., email: pjanbune@finsun.csc.fi
    Copyright:     this is public domain software
*)

BeginPackage["DFormat`"]

DFormat::usage =
"DFormat lets you control the appearance of partial derivatives
within expressions. DFormat[On] turns formatting on, DFormat[NoVars]
turns formatting on but with no variables explicitly displayed,
DFormat[Off] restores the original Mathematica behavior.
DFormat[On] is the default after loading this package."

On::usage = "DFormat[On] sets derivative formatting on."
Off::usage = "DFormat[Off] sets derivative formatting off."
NoVars::usage ="DFormat[NoVars] sets derivative formatting on
but with no variables."

Begin["`Private`"]

denomList[nn_List,vars_List]:=
  Block[{i,result = {}},
        For[i=1,i<=Length[nn],i++,
            If[nn[[i]] > 0,
               AppendTo[result,"¶"];
               AppendTo[result,vars[[i]]];
               If[nn[[i]] > 1, AppendTo[result,Superscript[nn[[i]]]]] ] ];
        result]

DFormat[Off]:=
(Unprotect[Derivative];
Format[Literal[Derivative[nn__][ff_][vars__]]]=.;
Protect[Derivative])

DFormat[On]:=
(Unprotect[Derivative];
Format[Literal[Derivative[nn__][ff_][vars__]]]:=
  If[Plus@@{nn} == 1,
     SequenceForm["¶",ff[vars]],
     SequenceForm["¶",Superscript[Plus@@{nn}],ff[vars]]]/
  SequenceForm @@ denomList[{nn},{vars}];
Protect[Derivative])

DFormat[NoVars]:=
(Unprotect[Derivative];
Format[Literal[Derivative[nn__][ff_][vars__]]]:=
  If[Plus@@{nn} == 1,
     SequenceForm["¶",ff(*[vars]*)],
     SequenceForm["¶",Superscript[Plus@@{nn}],ff(*[vars]*)]]/
  SequenceForm @@ denomList[{nn},{vars}];
Protect[Derivative])

End[]

EndPackage[]

DFormat[On]
Print["{DFormat}"]

Null


(*
;[s]
3:0,0;557,1;568,0;1862,-1;
3:2,14,10,Courier,1,12,0,0,0;1,12,10,Courier,3,12,0,0,0;0,12,10,Courier,0,12,0,0,0;
^*)