2

I’m trying to typeset the unicode dice character in LaTeX. I’m using emacs, on Ubuntu 18.04. I’ve tried manually setting my TeX-engine to xelatex and lualatex, and I get the same thing.

\usepackage{fontspec}                                      
%\setmainfonta{TeX Gyre Termes}                            
\usepackage{unicode-math}                                  
%\usepackage{unixode}                                      
\begin{document}                                           
\symbol{"2680}                                             
A                                                          
⚀                                                          
B                                                          
$\dicei$                                                   
C                                                          
\dicei                                                     
D                                                          
$\clubsuit$                                                  
E                                                          
$\varclubsuit$                                               
F                                                          
\end{document}                                             


%%% Local Variables:                                       
%%% mode: xelatex                                          
%%% TeX-master:                                            
%%% End:                                                   

This compiles to enter image description here

  • You can, but you need to use a font that contains that glyph. – Phelype Oleinik Sep 22 at 2:52
4

The default math font, Latin Modern Math, does not have those characters. You must load them from another font that does, such as XITS Math. There are slightly different commands to do this in math mode, in text mode, and to make the Unicode character work in both modes:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{newunicodechar}

\defaultfontfeatures{Scale=MatchLowercase}

\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setmathfont{TeX Gyre Termes Math}
\setmathfont{XITS Math}[range={"2680-"2685}]

\newfontfamily\symbolfont{XITS}
\newcommand\textdicei{{\symbolfont\symbol{"2680}}}

\newunicodechar{^^^^2680}{\ifmmode\dicei\else\textdicei\fi}

\begin{document}                                           
^^^^2680                            
A                                                          
⚀                                                          
B                                                          
$\dicei$                                                   
C                                                          
\textdicei                                                     
D                                                          
$\clubsuit$                                                  
E                                                          
$\varclubsuit$                                               
F
$⚀$                                                      
\end{document}

XITS font sample

1

I used the epsdice package, which allowed me to include unicode die faces without worrying about what font family I was using. I could generate faces easily then by calling \epsdice{1}, \epsdice{2}, and so forth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.