- Code: Select all
`f[x_]=x^2;`

g[x_]=x^3;

h[x_]=Sqrt[x];

k[x_]=Abs[x];

j[x_]=Sin[x];

s[x_]=Floor[x];

t[x_]=Log[x];

n[x_]=x;

m[x_]=Sign[x];

r[x_]=1/x;

q[x_]=x/;x<0;

q[x_]=(x-1)^2-1/;x>=0;Manipulate[Grid[{{TraditionalForm[A func[B x+W]+G]},{Plot[A*func[B*x+W]+G,{x,-6,6},PlotRange->{-6,6},PlotStyle->Thick,ImageSize->550]}},Alignment->Center,Spacings->{4,3}],{{func,n,"Function"},{

n->"f(x) = x",f->"f(x) = x^2", g->"f(x) = x^3", h->"f(x) = Sqrt[x]",k->"f(x) = |x|",j->"f(x) = sin(x)",

s->"f(x) = [x]",t->"f(x) = ln(x)",m->"f(x) = sgn (x)",r->"f(x) = 1/x",q->"f(x) = special"},PopupMenu},{{A,1},-3,3,1/4},{{B,1},-3,3,1/4},{{W,0,"C"},-5,5,.5},{{G,0,"D"},-5,5,.5}]

The problem is that if I take the labels in the PopupMenu (ex "f(x) = x^2"), and I format it within the quotation marks to how I want it to appear in the demonstration with the superscript, using a particular font, font face, and size). When I reopen the file containing the demonstration, the code is all messed up and won't evaluate. I get the following code.

- Code: Select all
`"f(x) =\!\(\*`

StyleBox[SuperscriptBox["x", "2"],

FontFamily->"Times New Roman",

FontSize->16,

FontSlant->"Italic"]\)"

Where the f(x) retains its formatting, but then I get the " \!\(\*..." and it won't evaluate correctly, unless I go back and change everything back. I really like the demonstration, and I have used it a few times in class. However like the previous topic I have no idea why formatting is so hard. If you have any suggestions for improving the code, please let me know.

Andrew Bayliss