# Macro for degree symbol

I wanted to find a simple way to made degree symbol ° and have tried textcomp and gensymb, but none of them works. I wanted to avoid using ^{\circ}, which isn't nice when you have a long document. I thought may be something easy can be achievable, e.g. \degree?

• Have a look at “How to look up a math symbol?” for ideas how you can easily find a particular symbol. – Martin Scharrer Jul 1 '11 at 21:19

Anything wrong with textcomp's \textdegree?

• I updated yesterday (TexShop), and made sure my files were intact after that. In fact, even for the first time that I installed it didn't work. @ Martin - Do add the `\newcomand{}...' in the main '.cls' file? – BrettHarry Jul 1 '11 at 21:33
• @BrettHarry: textcomp is not only a package but also provides fonts (I presume) which complicates the installation. I recommend to install it over the package manager of your TeX distribution. – Martin Scharrer Jul 1 '11 at 21:37
• @Martin: OK! Did you mean I install the package first then add the files to folders of the main package? I only get about 4 .sty files of textcomp. Sometimes I'm do wonder how to install different products but end up piling them in folders when they contain the same suffix .e.g all .sty files. – BrettHarry Jul 1 '11 at 21:44
• @BrettHarry: Sorry, I can't help you. I never need to install any fonts by myself. – Martin Scharrer Jul 1 '11 at 22:25
• @BrettHarry You work on a mac, so do you install MacTex or BasicTeX? I recommend MacTeX if you begin with TeX. BasicTeX comes only with latin modern font. – Alain Matthes Jul 2 '11 at 5:39

Maybe it’s a good alternative to use siunitx

\documentclass{minimal}
\usepackage{siunitx}
\begin{document}
Works in text \ang{45} an in math $\ang{2.4}$.
Even with minutes and seconds: \ang{40;12;08}.
\end{document}

It also gives you the oportunity to set all numbers in the same style an change it globally if it’s requested, e. g. changing from period to comma: 1.234 --> 1,234

Edit: To type radians just use the \radian unit. One may likes to define an own macro.

\documentclass{scrartcl}
\usepackage{siunitx}
\begin{document}
\end{document}
• For the sake of completeness, is there a way to insert an angle in radians? – Dror Sep 16 '12 at 5:12
• @Dror: How do you mark radians? As far as I know they are simple decimal numbers (\num{3.14}) or multiples of π ($2\pi/3$), aren’t they? – Tobi Sep 16 '12 at 15:47
• Well, you would like to add the "unit" at the end of the number, as you could just as well have the notion of \pi degrees. Any number can measure either radians or degrees. A more or less standard notation for radians would be something like \mathrm{rad} I guess. – Dror Sep 18 '12 at 13:46
• @Dror: (Sorry for the late reply …) At my university we usually don’t mark radians we just write the number – normally the the context makes clear that an angle is meant. If you like to ad “rad” you may use siunitx’ \radian as shown in my edit. – Tobi Oct 3 '12 at 18:59
• +1, you could also add \SI{20}{\celsius} as an example if the OP is asking for temperature. – quinmars Oct 25 '12 at 21:55

I prefer this solution

\renewcommand{\deg}{\ensuremath{^{\circ}}\xspace}

because it also works in math mode. (At least for me, \textdegree does not work in math mode, i.e.

$> 30\textdegree$

does not work, but

$> 30\deg$

does.

Using answers from this question, I've had good results with the following code:

\usepackage[utf8]{inputenc} % interpret input as unicode
\usepackage[T1]{fontenc}    % choose main font encoding (Cork)
\usepackage{textcomp}       % additional symbols using companion encoding TS1
\usepackage{gensymb}        % provides macro \degree which works in text and math
\DeclareUnicodeCharacter{00B0}{\degree} % Allow entering ° instead of \degree

As your original question states that gensymb didn't work for you, I assume that either the fontenc or the textcomp lines were missing in your setup, or some part of your TeX installation was missing, as these packages are usually shipped with your TeX distribution. The gensymb package goes to great length to provide its symbols from various sources, so it will behave differently depending on which other packages are loaded. See its documentation for details.

You can cover math and text in one command using \ifmmode:

\DeclareDocumentCommand{\degC}{}{%
{\ifmmode\text{\textdegree C}%
\else\textdegree C\fi}\xspace%
}

where \textdegree could be instead be \symbol{"00B0} if you favor unicode.

It may be worth mentioning that \textdegree and $^\circ$ produce different glyphs. The first uses \textdegree (or \symbol{"00B0}) and the second $^\circ$.

## protected by Martin Scharrer♦Jan 14 '13 at 11:50

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).