Solution found
Use of \usepackage{textcomp}
allows for \textdegree
macro, thanks to @Mico.
I use TeXmaker as an editor and I use Mendeley to generate my .bib
file. One entry has a degree symbol in the title. Mendeley encodes into UTF-8 and I therefore use
\usepackage[utf8]{inputenc}
however the degree symbols do not seem to work. I have also tried including
\usepackage[T1]{fontenc}
as per some suggestions on the stackexchange and the error changes from OT1 to T1.
How can I get the degree symbol to work?
Thanks.
Edit – MWE (which causes the error):
\documentclass[a4paper,12pt]{article}
% Text and Maths
\usepackage[utf8]{inputenc} % Input accented characters from keyboard input
%References and page interlinking
\usepackage[numbers,sort&compress,super]{natbib} % References - [numbers,sort&compress,super]
\bibliographystyle{unsrt} % BibStyle - unsrt keeps 1,2,3 instead of 2,1,3 (?)
\usepackage[final]{hyperref} % adds hyper links inside the generated pdf file
\hypersetup{
colorlinks=true, % false: boxed links; true: colored links
linkcolor=blue, % color of internal links
citecolor=blue, % color of links to bibliography
filecolor=magenta, % color of file links
urlcolor=blue % colour of url link
}
\usepackage{cleveref} % Clever ref - loaded AFTER hyperref!
\begin{document}
test
\citep{Zimmermann2009}
\bibliography{/Users/me/Documents/library.bib}
\end{document}
.bib
entry, error caused by degree symbol in title, I believe.
@article{Zimmermann2009,
abstract = {An unusual variety of magnetic, magnetoelectric and ferrotoroidic properties was observed in the lithium-orthophosphates LiMPO(4) with M = Fe, Co, Ni by optical second harmonic generation. In spite of a largely similar magnetic and crystallographic structure the compounds exhibit pronounced differences in the topology of antiferromagnetic 180A degrees domains. In LiCoPO(4) the antiferromagnetic domains coexist with ferrotoroidic, i.e., magnetic vortex domains. For LiNiPO(4) it was shown that the weak ferrimagnetic moment of the LiMPO(4) compounds along the spin direction is rigidly coupled to the AFM order parameter so that the sign of the magnetoelectric effect is reversed by a magnetic field only. Further effects of a static magnetic field on the system are discussed.},
author = {Zimmermann, A. S. and {Van Aken}, B. B. and Schmid, H. and Rivera, J. P. and Li, J. and Vaknin, D. and Fiebig, M.},
doi = {10.1140/epjb/e2009-00223-3},
file = {:Users/matt/Documents/Mendeley Desktop/Zimmermann et al. - 2009 - Anisotropy of antiferromagnetic 180° domains in magnetoelectric LiMPO 4 (M = Fe, Co, Ni).pdf:pdf},
isbn = {1434-6028},
issn = {14346028},
journal = {European Physical Journal B},
number = {3},
pages = {355--360},
title = {{Anisotropy of antiferromagnetic 180° domains in magnetoelectric LiMPO 4 (M = Fe, Co, Ni)}},
volume = {71},
year = {2009}
}
Best Answer
If you want to keep using the
natbib
package and theunsrt
bibliography style, all you need to do is (a) replace the symbol°
in thetitle
field with "\textdegree\
" and (b) load thetextcomp
package, as it provides the macrotextdegree
.The following code should compile just fine. (I've simplified the bib entry by deleting fields that are disregarded by the
unsrt
bibliography style.)Addendum: Instead of using pdfLaTeX with the
fontenc
,inputenc
, andtextcomp
packages, you may want to look into using LuaLaTeX along with thefontspec
package. If you can make this switch, you'll have native support for utf8-encode symbols.