# Problem displaying degrees celsius with siunitx and xelatex

I'm trying to discuss a temperature in a document where I'm using xelatex and siunitx.

       The temperature was further increased to \SI{200}{\degreeCelsius}.


When using xelatex this causes a hollow box to appear in place of the unit. When using pdflatex and a distribution supplied font it works fine. Is there a solution to this that I have missed?

This is a link to a character guide for the font -- ITC Baskerville Std Roman -- I'm using. http://store2.adobe.com/cfusion/store/html/index.cfm?store=OLS-UK&event=displayFont&code=BASQ10005000

I've also tried Times New Roman with no joy.

I'm using a fully updated texlive 2011.

Many thanks,

MWE

 \documentclass{article}

\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman}
%\usepackage{xkeyval}
%\usepackage{polyglossia}
%\setdefaultlanguage[variant=british]{english}
%\usepackage{etoolbox}
\usepackage{siunitx}

\begin{document}
The temperature was \SI{200}{\degreeCelsius}.
\end{document}


-
Please post a MWE. – Joseph Wright Jan 10 '12 at 20:54
Sorry, now edited. – Darling Jan 10 '12 at 21:05
Thanks for posting some example code. I've made it "more minimal" by commenting out all unneeded \usepackage commands, setting the document class to "article," and by shortening the sentence. In addition, I've added an image file to show the resulting output. – Mico Jan 10 '12 at 21:15
Thanks Mico. How do you add an image of the output? – Darling Jan 10 '12 at 21:24
@JosephWright: If this MWE is run under lualatex instead of xelatex, no hollow rectangle is displayed, but also no raised little circle followed by "C" either. (I.e., nothing at all shows.) :-( – Mico Jan 10 '12 at 21:24

Expanding on Joseph's answer, you can find a matching font that has the required symbol; for instance, if your Times New Roman hasn't the ℃ symbol, then you can do

\newfontfamily{\tgtermes}[Ligatures=TeX]{TeX Gyre Termes}

\usepackage{siunitx}

\usepackage{newunicodechar}
\newunicodechar{℃}{{\tgtermes ℃}}
\sisetup{text-celsius = ℃}


thereby using the different font only for the character you need. Alternatively, you can also try faking the symbol:

\sisetup{text-celsius = $^\circ\mkern-1mu$C}


-
Is there a simple way to adjust the kerning when doing it like this? \sisetup{text-celsius = °C} I tried your second suggestion but it wouldn't typeset. – Darling Jan 10 '12 at 22:20
@Darling Sorry for the typo! – egreg Jan 10 '12 at 22:32

The siunitx package has a set of basic symbol choices built in for working with standard LaTeX fonts. However, these may or may not work when loading system fonts with XeLaTeX or LuaLaTeX. Fonts do not cover all symbols, and it is simply not realistic to detect every possible combination. Thus when using non-standard fonts it is down to the end user to make an appropriate choice, using for example

\sisetup{text-celsius = <symbol or appropriate macro>}


The log file may show

LaTeX Font Warning: Some font shapes were not available, defaults substituted.


if the appropriate symbols are not available. (This will depend on the font in use.)

-

use the TeX Gyre Times font, is has a degree symbol:

\documentclass{article}
\usepackage{fontspec}
\fontspec[Extension=.otf,
BoldFont=texgyretermes-bold,
ItalicFont=texgyretermes-italic,
BoldItalicFont=texgyretermes-bolditalic]{texgyretermes-regular}

If you are using Linux, then pay attention, that xelatex finds the open type fonts of TeXLive, located at \$texmf-dist/fonts/opentype/public/texgyre/. With lualatex it is no problem.