Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
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
3  
You could define your own \degree using \newcommand{\degree}{$^{\circ}$} or better (using packages xspace and amsmath) \newcommand{\degree}{\ensuremath{{}^{\circ}}\xspace}. However, lockstep's answer might still be preferable. –  Martin Scharrer Jul 1 '11 at 21:24
add comment

4 Answers

up vote 17 down vote accepted

Anything wrong with textcomp's \textdegree?

share|improve this answer
    
I'm not sure,...I got the files randomly online and dropped them into my .sty folders. I then invoked \usepackage{textcomp}, but that didn't help. –  BrettHarry Jul 1 '11 at 21:25
3  
Sounds like a potentially messed-up installation. At the very least, you have to update your filename database after adding files. –  lockstep Jul 1 '11 at 21:28
    
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
2  
@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
show 3 more comments

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}
\newcommand{\rad}[1]{\SI{#1}{\radian}}
\begin{document}
    \SI{\pi}{\radian}
    \rad{\pi/2}
\end{document}
share|improve this answer
    
For the sake of completeness, is there a way to insert an angle in radians? –  Dror Sep 16 '12 at 5:12
1  
@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  
+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
show 2 more comments

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.

share|improve this answer
1  
Related : tex.stackexchange.com/questions/34830/… –  percusse Oct 25 '12 at 14:55
add comment

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.

share|improve this answer
add comment

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

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.