MATLAB Answers


Is there a degree symbol in LaTex or is ^{\circ} the best it can do?

Asked by Zhangxi Feng on 11 Dec 2018
Latest activity Commented on by Walter Roberson
on 4 Sep 2019
I have searched quite a bit for examples of displaying titles in latex. My goal is to show the following:
Bin 0° <= \varphi_2 <= 5°
Where \varphi is the variation of phi that normal TeX does not offer. I do not mind if the less than or equal to stays like that or becomes the fancy LaTeX form.
The example I found so far that does not give me any warning is from:, where the example is:
title('$$Q \geq \frac{I_h H}{I_h H+I_z C}, b_1 \geq b_2$$','interpreter','latex')
And it works as expected when I tried it.
I tried many things and eventually the following worked:
title('Bin $$0^{\circ} \leq \varphi_2 \leq 5^{\circ}$$','interpreter','latex')
Bin 0° <= \varphi_2 <= 5°
But as this post [link] pointed out, using the circle seems less sophisticated than being able to use the proper degrees symbol. So is there a way to add a degrees symbol into my line? I have tried typing the symbol directly or try a concat string with char(176), but I couldn't make either work.

  1 Comment

LaTeX by itself cannot create an actual degree character, instead faking it with circles and the like. The actual solution when using LaTeX is to use a package such as gensymb or textcomp:

Sign in to comment.

2 Answers

Answer by Cris LaPierre
on 11 Dec 2018
Edited by Walter Roberson
on 12 Dec 2018
 Accepted Answer

I don't think it's possible to have both the degree symbol and LaTeX. Playing around with the title in the property inspector, I can combine strings with LaTeX, and can add \char126 or ^^7a and see the changes. However, if I add \char176 or ^^b0 it does not display the inserted character (though the LaTeX formatting remains).
The final thing I can do is copy and paste the degree symbol into the title string. It appears, but kills the ability to use the LaTeX interpreter, even if I put it outside the $$ flagged LaTeX expression
Bin 0° $$ \leq \varphi_2 \leq 5^{\circ}$$
displays as
Bin 0° $$ \leq \varphi_2 \leq 5^{\circ}$$


Show 1 older comment
Thanks guys for answering. What kind of code is \x2264 and \x03c6 for those symbols?
They are the unicode values for what you see in the title (the \leq and \phi).
You can see more about why the \x here.

Sign in to comment.

Answer by Erick Zind on 4 Sep 2019

Many people use many mathematical symbols on LaTeX. One of them is the symbol of degree. Now in this article we will explain how to use the degree symbol on LaTeX. You will be able to add the degree symbol with various packages via LaTeX. Let's start!
Three different LaTeX packages:
1- Using Siunitx package
  • We add this package first to our service. Then follow the steps below.
  • Start the document.
  • For example:
Degree symbol: 90\si{\degree}
  • We give a like request.
We print out 90°.2- Using gensymb package
  • We will print the degree symbol using another package, gensymb.
  • First of all, we are loading our package again.
  • Then begin the new document.
  • Then type your sentence. For instance,
The right angle is \ang{90}.
  • It will give us such a result.
The right angle is 90°.
3- Using textcomp package
  • As another method, let's get to know the last textcomp.
  • As in the examples above, we load our package first.
  • We are again creating a new document.
  • And we write the result in the format of the degree we want, for example
The round angle is \ang{360}.
  • It will give us such a result.
The round angle is 360.


Adding packages to the LaTeX interpreter in Matlab is so far from trivial that it demands some instructions.What you have provided would be a good answer on a LaTeX forum, but it doesn't explain how to use this information in Matlab.
I will leave the choice to you, but I would suggest a major edit of your answer or a deletion.
I gather that the Report Generator provides a way to insert arbitrary latex including adding packages, but MATLAB itself makes it pretty rough, with a binary encoded configuration file that no-one seems to know how to decompile.

Sign in to comment.