MATLAB: How to fix broken LaTeX commands where it fails to render ‘\pm’ in MATLAB 7.14 (R2012a)

interpreterlatexmacosMATLABtexutf-8

I am unable to execute latex command properly in MATLAB 7.14 (R2012a).
An example of LaTeX code is as follows:
figure; axis;
title('This is a \pm ± test')
LaTeX command '\pm' fails to render.

Best Answer

This issue can be resolved by setting interpreter to TeX.
To find the interpreter settings, execute the GET command as shown in example below:
h = title('This is a \pm ± test');
get(h,'interpreter')
The ouput should show 'latex', 'tex' or none. The output of above command should be ‘tex’ to render properly. If not, use the SET command to change interpreter setting to TeX as shown in example below:
set(h,interpreter,tex)
Note that the output of LaTeX command '\pm' under MacOS environment with UTF-8 setting does not render properly.
As a workaround, execute following code:
pm = char (177);
figure;axes;
h = title (['This is a ' pm ' ± test');
Related Question