This is the part of my LaTeX file where I load all the packages:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
%\usepackage[UTF8]{ctex}
\documentclass[preview]{standalone}
\RequirePackage{unicode-math}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{dsfont}
\usepackage{setspace}
\usepackage{tipa}
\usepackage{relsize}
\usepackage{textcomp}
\usepackage{mathrsfs}
\usepackage{calligra}
\usepackage{wasysym}
\usepackage{ragged2e}
\usepackage{physics}
\usepackage{xcolor}
\usepackage{microtype}
\usepackage{mathspec}
\usepackage{fontspec}
\setmainfont{Ubuntu}
\setmathsfont(Digits,Latin,Greek){Ubuntu}
However, it gives me the error:
("C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amssymb.sty"
Package: amssymb 2013/01/14 v3.01 AMS font symbols
("C:\Program Files\MiKTeX 2.9\tex/latex/amsfonts\amsfonts.sty"
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info: Redeclaring math symbol \hbar on input line 98.
)
! LaTeX Error: Command `\eth' already defined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.240 ...ol{\eth} {\mathord}{AMSb}{"67}
The document contains the following lines:
\begin{document}
YourTextHere
\end{document}
Best Answer
Some comments and observations:
It's a good idea to load math font packages such as
amssymb
,dsfont
,mathrsfs
andwasysym
before loadingunicode-math
. For sure, if you follow this piece of advice, theerror messages will cease.
The
unicode-math
package works under both XeLaTeX and LuaLaTeX, and it loadsfontspec
automatically. AFAICT, though,unicode-math
is not really compatible with the older, XeLaTeX-onlymathspec
package. My suggestion: don't loadfontspec
andmathspec
.To wit, here's an excerpt from the user guide of the
mathspec
package:Addendum to address the OP's follow-up comment. Thanks for clarifying the purpose of the
\setmathsfont(Digits,Latin,Greek){Ubuntu}
statement. Let me thus reformulate one the suggestions given above: Do load themathspec
package -- and don't load theunicode-math
package.