Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How can I place the \, _, or ^ characters in a text command?

Asked by MathWorks Support Team on 21 Nov 2011

I am using text commands: text, title, xlabel and ylabel, to label my plot. I want the ' \ ' (backslash) , ' _ ' (underscore) and ' ^ ' (caret) symbols to appear in the text, but whenever I place them in, it alters the text.

For example, typing ^t makes the "t" a superscript, _w makes "w" a subscript, and \theta makes a Greek character.

For instance, if I try to label my graph Experiment_6, the 6 is subscripted:




1 Answer

Answer by MathWorks Support Team on 21 Nov 2011
Accepted answer

MATLAB 5 introduced TeX characters for formatting text objects. The underscore character " _ " is interpreted by MATLAB as a subscript command. The backslash command " \" is interpreted by MATLAB to indicate that a TeX command is next. The caret character " ^" is interpreted by MATLAB as a superscript command.

In these examples, the interpreter is formatting the w as subscript, the t as superscript, and the \theta as a TeX command (which happens to draw the Greek letter Theta).

One way to bypass the interpreter and have the characters appear as typed, is to use the backslash character ( \ ) before the LaTeX command. For example:

\_w will make _w appear in your text

\^t will make ^t appear in your text

\\theta will make \theta appear in your text

Alternatively, you can set the "Interpreter" property of the text object to 'none'. For example:



t = title('Experiment_6')

To set the default Text 'Interpreter' property to 'none' so that no TeX character in a text string is interpreted at the root level, issue the following command:


For more information on TeX characters, refer to the following URL:


Contact us