# LegendFunction and MaTeX

I have started using MaTeX (excellent package to integrate Latex in your wonderful Mathematica generated plots).

I am getting a warning in generating the following plot

<< MaTeX
texStyle = {FontFamily -> "Latin Modern Roman", FontSize -> 18};
SetOptions[MaTeX,
"Preamble" -> {"\\usepackage{wasysym}\\usepackage[dvipsnames]{xcolor}"}];
f[x_] := ScientificForm[
N[x /. {NumberForm[y_, {w_, z_}] :> ScientificForm[y, 2]}], 2]
DensityPlot[Sin[x y], {x, -2, 2}, {y, -2, 2},
ColorFunction -> ColorData[{"RedBlueTones", "Reverse"}],
ImageSize -> {500, Automatic}, PlotRange -> All,
PlotLegends ->
Placed[BarLegend[Automatic, LegendFunction -> f,
LegendMarkerSize -> 350,
LegendLabel ->
MaTeX["\\mathrm{Re}(\\mathrm{i}\,I_{\\overline{\\mathrm{D}3}}/L^\
3 T)", Magnification -> 2], LabelStyle -> texStyle], {After, Top}],
BaseStyle -> texStyle]
Clear[f]


I know that the problem is in using the LegendFunction and the "\\overline" (when I remove one of the two, no warning is issued).

• This is due to f (the LegendFunction) corrupting the Graphics expression returned by MaTeX. Since this function does not seem to do anything here anyway, remove it. Mar 15 at 13:00
• Thanks for the reply Szabolcs, however the function f` is indeed doing something there. It is ensuring that the legend comes out in Scientific form, and I would like to keep that. Mar 16 at 15:00
• This is a very crude way to try to change tick marks that affects all numbers within the expression, not just ticks (and is very likely to break something). I suggest you use this way instead: mathematica.stackexchange.com/a/149416/12 Mar 16 at 15:27