9

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}
0

1 Answer 1

8

Some comments and observations:

  • It's a good idea to load math font packages such as amssymb, dsfont, mathrsfs and wasysym before loading unicode-math. For sure, if you follow this piece of advice, the

    ! LaTeX Error: Command `\eth' already defined.
    

    error messages will cease.

  • The unicode-math package works under both XeLaTeX and LuaLaTeX, and it loads fontspec automatically. AFAICT, though, unicode-math is not really compatible with the older, XeLaTeX-only mathspec package. My suggestion: don't load fontspec and mathspec.

    To wit, here's an excerpt from the user guide of the mathspec package:

enter image description here

  • I would attempt to provide a more rational structure on the preamble, maybe along the following lines. Whatever else you do, please do yourself a big favor and figure out which packages are truly needed -- and which ones are pure fluff and hence shouldn't be loaded.

%!TEX TS-program = xelatex
\documentclass{article} % any good reason for loading 'standalone'?

%% math and physics packages:
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{physics}
\usepackage{dsfont}
\usepackage{mathrsfs}
\usepackage{wasysym}

%% other packages
\usepackage[english]{babel}
\usepackage{calligra} % are you serious?!
\usepackage{setspace}
\usepackage{relsize}
%\usepackage{textcomp} % has recently become part of LaTeX 'core'
\usepackage{tipa} % are you absolutely sure you need this package?
\usepackage{ragged2e}
\usepackage{xcolor}
\usepackage{microtype}

%\usepackage{mathspec} % conflicts with 'unicode-math'
%\usepackage{fontspec} % is loaded automatically by 'unicode-math'

\RequirePackage{unicode-math}
\setmainfont{Latin Modern Roman} % I don't have 'Ubuntu' font
\setmathfont{Latin Modern Math}

\begin{document}
Hello World.
\end{document}

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 the mathspec package -- and don't load the unicode-math package.

11
  • Thanks @Mico. :) The LaTex document is part of a larger library and I am pretty new to LaTex so I did not know if there are any obsolete or extra packages in the file.
    – Real Noob
    May 31, 2020 at 5:21
  • I wanted to use fontspec and mathspec so that the font of regular text and the letters/digits in the Mathematical formulae looked the same. I followed the instructions in this question to do that: tex.stackexchange.com/questions/149565/….
    – Real Noob
    May 31, 2020 at 5:22
  • 1
    @RealNoob - Using the "regular", i.e., text-mode letters and numerals in math expressions is perfectly feasible under unicode-math. I'll post an addendum to show how that may be done. It'll have to be with Latin Modern,. though, as I don't have the 'Ubuntu' fonts on my system.
    – Mico
    May 31, 2020 at 5:25
  • 1
    @RealNoob - Since I don't have any information about the math material in your document, I'm afraid I'm not in a position to give meaningful advice as to "anything you should keep in mind".
    – Mico
    May 31, 2020 at 6:21
  • 2
    @RealNoob You have to keep in mind that mathspec is an extensive hack and you'll need several small adjustments after looking at the typeset output.
    – egreg
    May 31, 2020 at 10:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .