MATLAB: How to draw an en dash in MATLAB using the TeX interpreter

handle graphicsMATLABtex

I am trying to write text within a figure, and I need to be able to differentiate between a hyphen and an en dash (hyphen being slightly shorter).

Best Answer

You can use the ASCII codes for the specific type of dash you would like to display in the call to the TEXT function. For example,
plot(1:10); % This will draw a hyphen
h1 = text(2,2,['Test-example']); % This will draw an en dash
h1 = text(2,4,['Test' char(8211) 'example']); % This will draw an em dash
h1 = text(2,6,['Test' char(8212) 'example']);
Please refer to the following page to see numeric codes for the common dashes: