0

With XeLaTeX, I can obtain check and ballot x marks with pifont:

With pifont:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%

\begin{document}
\begin{tabular}{ccc}
\cmark & Yes
\\
\xmark & No
\end{tabular}
\end{document}

pifont's check mark and ballot x mark

Goal: To use only Unicode characters in my XeLaTeX document to match those, by doing something like this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase, Ligatures=TeX }
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setmathfont{TeX Gyre Termes Math}
\setmathfont{STIX Two Math}[range={\checkmark,\ballotx}]
\newcommand{\cmark}{\checkmark}
\newcommand{\xmark}{\ballotx}

\begin{document}

\begin{tabular}{ccc}
\cmark & Yes
\\
\xmark & No
\end{tabular}
\end{document}

That's OK for \checkmark, but I get an "Undefined control sequence" error for \ballotx.

I do realize that any given Unicode font might not have a particular symbol I want; that is not the real issue here.

Question: How does one find out the correct name to use for a "heavy ballot x" — or for that matter, any other particular symbol — to use with the \setmathfont{...}[range[{...}]? That is, a name akin to \checkmark (which does work if the font has it).

Whenever I try to identify a symbol by looking in descriptions of a Unicode characters, I see often multi-word names, e.g., "Unicode Character 'BALLOT X' (U+2717)". But that does not tell me what name to use for the character!

Solution to \cmark and \xmark with XeLaTeX and OTF font:

Thanks to help from https://tex.stackexchange.com/a/553109/13492, https://tex.stackexchange.com/a/553095/13492, and use of both the UnicodeChecker app and the otfinfo -g command, I have the following resolution:

% !TeX program =xelatexmk
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{TeX Gyre Termes Math}

\usepackage{graphicx}
\newfontfamily{\xcheckmarkfont}{LibertinusSerif-Regular.otf}
\newcommand{\cmark}{\scalebox{1.2}[1.4]{\rotatebox{-8}{\xcheckmarkfont\char"2714}}}
\newcommand{\xmark}{\scalebox{1.2}[1.42]{\raisebox{-.1ex}{\xcheckmarkfont\char"2718}}}

\RequirePackage[names]{xcolor}
\newcommand{\greencheck}{\color{green!70!brown}{\cmark}}
\newcommand{\redx}{\color{red}{\xmark}}

\begin{document}

\begin{tabular}{lc}
\cmark &  Yes
\\
\xmark & No
\end{tabular}

\end{document}

The result:

LibertinusSerif-Regular.otf check mark and ballot x mark

Request:

Suggestions for improvement of the results, so as to more closely match the pifont output, will be very welcome!

8
  • The ballot x symbol isn't defined in unicode-math. See mirror.las.iastate.edu/tex-archive/macros/latex/contrib/… for a complete list of symbols which are defined. See this answer for accessing the symbol by its hexcode: stackoverflow.com/questions/3779234/…
    – Don Hosek
    Jul 10, 2020 at 21:15
  • @DonaldHosek: So then how, e.g., do I specify a particular Unicode font to use with \char"2718?
    – murray
    Jul 10, 2020 at 21:24
  • You can use newunicodechar to set the Unicode character active: \newunicodechar{^^^^2718}{\xmark}
    – Davislor
    Jul 12, 2020 at 4:43
  • If you’re scaling the marks, you probably want to load the font with a Scale= option rather than wrap it in a \scalebox.
    – Davislor
    Jul 12, 2020 at 4:44
  • You also want to enclose commands to set the font and color within a group, so they don’t bleed through and set the font and color of the text after it. Just add another set of outer braces around the body of the command. Or use \textcolor instead of \color.
    – Davislor
    Jul 12, 2020 at 4:45

0

You must log in to answer this question.

Browse other questions tagged .