# How to fix a legend with TraditionalForm

Let this code

f[x_]:=Piecewise[{{Sin[x],x>0},{Exp[x], x<=0}}];
Plot[f[x],{x,-5,5}, PlotLegends-> {"f(x)=" TraditionalForm[f[x]]}]


Then the part of the TraditionalForm in the legend appear braced, as it would be an array. How I can quit the braces? Morover: there is a way that the legend appear with more beautiful fonts (as it would be LaTeX)?

Plot[f[x], {x, -5, 5}, PlotLegends-> {Row[{"f(x) = ", TraditionalForm[f[x]]}]}]


Note: To see why you get TraditionalForm[f[x]] parenthesized check

 "f(x)=" TraditionalForm[f[x]] // FullForm


Times["f(x)=", TraditionalForm[Piecewise[List[List[Sin[x], Greater[x, 0]], List[Power[E, x], LessEqual[x, 0]]], 0]]]

that is, "f(x)=" is multiplied by TraditionalForm[f[x]].

• one more question: when I evaluate just TraditionalForm[f[x]] the output is written using more beautiful fonts than when I did the same inside the legend of a plot. There is a way to put the same fonts in the legend? – Masacroso Jul 29 '19 at 12:15
• @Masacroso, If you know the font family you can use Style[TraditionalForm[f[x]], FontFamily -> fontfamily] to get the same style in the legend. For best labeling you might want to try Szabolcs's MaTeX package – kglr Jul 29 '19 at 12:43