10

I am trying to typeset the symbol for empty set and using the answer of that question I chose \varnothing but when I used it I got the symbol that is described to be \emptyset and vice versa. Also when I use the amssymb package I get these errors:

Command `\eth' already defined.

Command `\digamma' already 

Command `\backepsilon' already 

If I don't useamssymb it still happens the same regarding those 2 symbols. What is happening? How can I get the right symbol? (Meaning the \varnothing)

\documentclass[12pt]{article}

\usepackage{fontspec}

\setmainfont
[
  Ligatures=TeX,
  Extension=.otf,
  UprightFont=*,
  BoldFont=*Bold,
  ItalicFont=*It,
  BoldItalicFont=*BoldIt,
  Mapping=tex-text
]{GFSArtemisia}

\setsansfont[Mapping=tex-text]{GFSArtemisia.otf}

\usepackage[english,greek]{babel}

\usepackage[fleqn]{amsmath}

\usepackage{unicode-math}

\begin{document}

This is the problem:

\vspace{1cm}

$\varnothing \quad \emptyset$

\end{document}
Adam
  • 4,684

2 Answers2

8

There are not two distinct Unicode points for the empty set and its variant symbol (they are just different forms of the same symbol). Find a font that has the circle form and use it.

\documentclass[12pt]{article}

\usepackage[fleqn]{amsmath}
\usepackage{unicode-math}
\usepackage[english,greek]{babel}

\setmainfont[
  Ligatures=TeX,
  Extension=.otf,
  UprightFont=*,
  BoldFont=*Bold,
  ItalicFont=*It,
  BoldItalicFont=*BoldIt,
]{GFSArtemisia}

%\setsansfontMapping=tex-text]{GFSArtemisia.otf} %%% it's not sans serif!

\setmathfont{Latin Modern Math}
\setmathfont[range=\varnothing]{Asana Math}
\setmathfont[range=\int]{Latin Modern Math}

\begin{document}

This is the problem: $\varnothing\subseteq A\times B$

\end{document}

enter image description here

By the way, Latin Modern Math together with GFS Artemisia doesn't seem too nice a combination. If your document is math intensive, Artemisia for the Latin characters is not recommendable, in my opinion, because there's no matching math font.

Loading Latin Modern Math explicitly is necessary if another math font is chosen for some range of characters (it's a bug of fontspec, I'd say).

Note that, depending on the host system (say ShareLaTeX or WriteLaTeX) or your own system, the font may have to be loaded by file name and not by font name; in this case, the math fonts should be loaded with

\setmathfont{latinmodern-math.otf}
\setmathfont[range=\varnothing]{Asana-Math.otf}
\setmathfont[range=\int]{latinmodern-math.otf}
egreg
  • 1,121,712
  • Another thing that annoys me is the necessity of calling range=\int (or whatever) to get the correct “dimensions”. Wouldn't it be more clear if range=\varnothing imported nothing else but \varnothing? – Manuel Oct 20 '14 at 08:15
  • @Manuel It's really annoying. Let's hope these bugs will be fixed soon. – egreg Oct 20 '14 at 08:45
  • @egreg thank you I will try it! Can you please explain to me why except the first \setmathfont there are two more? – Adam Oct 20 '14 at 11:24
  • 1
    @Adam The first and third \setmathfont shouldn't be necessary in an ideal world (Latin Modern Math is the default of unicode-math), but they're unfortunately needed if different fonts are used for some ranges. With only the second declaration, two bugs of unicode-math show, which are corrected with the other two declarations. The order matters. – egreg Oct 20 '14 at 11:35
  • @egreg I used these lines of code and I get errors: Undefined control sequence. l.37 \setmathfont {Latin Modern Math} LaTeX Error: Missing \begin{document}. Undefined control sequence. l.38 \setmathfont[range=\varnothing ]{Asana Math} Missing $ inserted. – Adam Oct 20 '14 at 19:53
  • @Adam Please, upgrade your TeX distribution. – egreg Oct 20 '14 at 20:04
  • @egreg I use ShareLatex so it is upgraded. :) – Adam Oct 20 '14 at 20:06
  • @Adam Not sure it is. Look in the log file for the version of unicode-math – egreg Oct 20 '14 at 20:07
  • @egreg where can I find it? – Adam Oct 20 '14 at 20:09
  • @Adam In the log file; look for unicode-math and the version number will be next to it. Sorry, but I won't register just for this. – egreg Oct 20 '14 at 20:11
  • @egreg It says unicode-math 2014/06/30 v0.7f – Adam Oct 20 '14 at 20:31
1

Another way is to use the "msb" (?) font which is what is being used when amssymb package is loaded without unicode-math.

Just open amssymb.sty and amsfonts.sty and copy the 2 lines, change \varnothing to \varnothingold.

%! TEX program = lualatex
\documentclass{article}
%\usepackage{amssymb}
\usepackage{unicode-math}
\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}  % not needed with \usepackage{amsfonts} or \usepackage{amssymb}
\DeclareMathSymbol{\varnothingold}     {\mathord}{AMSb}{"3F}
\begin{document}
$\varnothing$
$\varnothingold$
\end{document}

Output: Output image


Yet another way is to use the New Computer Modern font, which looks similar to the "default TeX math font", except that it has a cv01 character table (or CharacterVariant=1 option) that selects the rounded variant of the symbol.

\documentclass{article}
\usepackage{unicode-math}
\begin{document}

$\emptyset$ \setmathfont[CharacterVariant=1]{NewCMMath-Regular.otf} $\emptyset$

\end{document}

Output is same as the above.

user202729
  • 7,143