The source below, when processed with pdflatex
produces the math symbol shown here:
But if I process the source with xelatex
, I get error:
./unitsquare.tex:26: LaTeX Error: Command \Box not provided in base LaTeX2e.
Question: How can I get that symbol with xelatex
with the fonts in use for that?
\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage{amsmath} % avoid \dddot clash
\usepackage{mathtools} % avoid unicode-math clash
\usepackage{amsthm} % avoid openbox clash
\usepackage{iftex}
\ifTUTeX
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX}
\setmathfont{TeX Gyre Termes Math}
\else
\usepackage{newtxtext}
\usepackage{newtxmath}
\fi
\usepackage{scalerel}
\newcommand{\unitsq}{\mathord{\scalerel*{\Box}{X}}}
\begin{document}
The unit square is denoted by $\unitsq$.
\end{document}
fontenc
with XeLaTeX, unless for very special situations. Preparing a document that works in bothpdflatex
andxelatex
with no change is, unfortunately, just a dream.\Box
command is provided by thelatexsym
package, or\square
in thenewtxmath
packagexelatex
, I'm not usingnewtxmath
. I don't know how to uselatexsym
withTeX Gyre Termes Math
underxelatex
.