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

272 次查看(过去 30 天)
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: https://www.mathworks.com/matlabcentral/answers/42448-about-latex-command-in-the-title, 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')
Result:
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 个评论
Stephen23
Stephen23 2018-12-12
编辑:Stephen23 2020-8-25
LaTeX by itself cannot create an actual degree character, instead faking it with circles and the like. The actual solution when using LaTeX to generate documents is to use a package such as gensymb or textcomp:
But this approach does not work within MATLAB: sadly there does not seem to be a good solution.

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2018-12-11
编辑:Walter Roberson 2018-12-12
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}$$
  4 个评论
Zhangxi Feng
Zhangxi Feng 2018-12-12
Thanks guys for answering. What kind of code is \x2264 and \x03c6 for those symbols?
Cris LaPierre
Cris LaPierre 2018-12-12
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.

请先登录,再进行评论。

更多回答(2 个)

Erick Zind
Erick Zind 2019-9-4
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.
\documentclass{report}
\usepackage{siunitx}
  • Start the document.
\begin{document}
  • For example:
Degree symbol: 90\si{\degree}
\end{document}
  • 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.
\documentclass{report}
\usepackage{gensymb}
  • 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.
\documentclass{report}
\usepackage{textcomp}
  • We are again creating a new document.
\begin{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.
  2 个评论
Rik
Rik 2019-9-4
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.
Walter Roberson
Walter Roberson 2019-9-4
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.

请先登录,再进行评论。


Afzal khan
Afzal khan 2020-8-25
Yes there a degree symbol in LaTex
Why should I use Latex?
With other more conventional alternatives for producing documents, such as Microsoft’s Word, it is natural to wonder why one should take the trouble to learn to use Latex. On the surface, one of the advantages of Latex is the professional quality of the documents that you can generate. This is particularly true for documents that contain formulas or equations, but Latex has many applications beyond mathematics. Documents on chemistry, physics, computing, biology, law, literature, music, and any other topic you can think of can still take advantage of Latex’s excellent print quality. Below is Latex degree symbol code.
\ documentclass [10pt, a4paper] { article }
\ usepackage [utf8] { inputenc }
\ usepackage [francais] { babel }
\ usepackage [T1] { fontenc }
\ usepackage { textcomp }
\ usepackage { amssymb }
\ DeclareTextSymbol { \ deg } { T1 } { 6 }
\ DeclareTextSymbol { \ deg } { OT1 } { 23 }
\ usepackage[left = 4cm, right = 4cm, top = 4cm, bottom = 4cm] { geometry }
\ begin { document }
\ degre C et \ degres C et \ deg C
\ end { document }
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by