MATLAB: How to put an em-dash in a text object within a figure in MATLAB

en-dashendashMATLABtex

I would like to put an em-dash (long dash with no spaces) in a title or other text object within a figure in MATLAB.

Best Answer

As of MATLAB 7.0 (R14), "LaTeX" has been added as an optional interpreter for text objects in a figure.
In order to have an em-dash displayed within a figure, the "Interpreter" property of the text should to be set to "LaTeX" and the equivalent LaTeX command "\---" should be typed.
For example, to have "x-hat" displayed in the X-Label, do the following:
plot(1:10)
%An example to have "emdash" displayed as title is:
title(['This is an example for emdash' '---'],'Interpreter','Latex')
%Another example to have "emdash" displayed as text is:
text(5,5,'---','Interpreter','Latex')