9

In a document I need to use Cambria Math but at the same time be able to use \checkmark for an itemize environment. But as soon as I load unicode-math the checkmark disappears. Is there a work around for this?

I am compiling the following MWE with lualatex (TeX Live 2013/dev):

\documentclass{article}
\usepackage{amsfonts} % for the \checkmark command 
\usepackage{unicode-math} % hides \checkmark? 
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
%\setmathfont{Cambria Math}


\begin{document} 
$a + b$
\begin{itemize}
\item[\checkmark] a
\item[\checkmark] b 
\item[\checkmark] c
\end{itemize}

\end{document}
6
  • 1
    What about using \usepackage{fontawesome} and then \item[\faOk]? The package relies on fontspec (and requires XeTeX or LuaTeX), so there should be no incompatibility.
    – jon
    Apr 14 '13 at 5:49
  • @jon, thanks for the suggestion, \faOk looks quite different than the expected output of \checkmark.
    – alfC
    Apr 14 '13 at 6:06
  • Yeah, I didn't think it really mattered, but everyone has their own taste. It is still a checkmark at least. In any case, this might deserve to be reported to the unicode-math people since it is still, I think, an experimental package.
    – jon
    Apr 14 '13 at 6:22
  • This seems like a bug in unicode-math, I had other problems with it, for example, when using Cambria in the document Evince PDF viewer refuses to print!
    – alfC
    Apr 14 '13 at 7:14
  • Just guessing: I can't find a checkmark in (the copy of) Cambria Math (I have here), so this might be due to switching to OpenType completely and not being able to find the appropriate glyph.
    – topskip
    Apr 14 '13 at 7:38
8

enter image description here

If you want the AMS tick back you can just load the font, simplest to do it as a text font. Also unicode-math delays some of its definitions until begin{document} so you need to delay the (re)definition until after that.

\documentclass{article}

\usepackage{unicode-math} 
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\setmathfont{Cambria Math}


%%\DeclareFixedFont\amsa{U}{msa}{m}{n}{10}
%%\AtBeginDocument{\renewcommand\checkmark{{\amsa \char"58}}}

\AtBeginDocument{\renewcommand\checkmark{\usefont{U}{msa}{m}{n}X}}

\begin{document} 


$a + b$
\begin{itemize}
\item[\checkmark] a
\item[\checkmark] b 
\item[\checkmark] c
\end{itemize}

\end{document}
6
  • Mildly involved, but definitely a work around.
    – alfC
    Apr 14 '13 at 9:48
  • 3
    @alfC You load ten million lines of fontspec and unicode-math setup and yet you call a 2 line definition correcting one aspect "mildly involved" :-) Apr 14 '13 at 9:55
  • good point, I was talking from a "user's perspective". Since this is a perfect workaround for amsfonts's \checkmark, I'll mark this as accepted.
    – alfC
    Apr 14 '13 at 10:06
  • @alfC Unfortunately the green tick isn't from AMS fonts:-) Note that while this answers the question as asked (and implied by your self-answer) that you wanted to look like the AMS one, note that egreg's solution has an advantage that might be important in other contexts that it preserves the Unicode encoding so if you cut and paste the text as plain text from the typeset version then you have a chance of it still being the U+2713 CHECK MARK, but the AMS fonts are a legacy 7bit encoding so the tick there is actually character hex 58 which is an X in Unicode (and any sensible encoding). Apr 14 '13 at 10:17
  • good to know, I think I started from the assumption that there was a simple (and even unicode-copy friendly solution) but all the mess starts from Cambria/Cambria Math lacking a checkmark.
    – alfC
    Apr 14 '13 at 10:22
10

I don't have Cambria, but the symptoms point to a missing glyph. Using amsfonts is not recommended: its symbols should be already available in a good Unicode math font.

You can select a different font for the symbol by saying, for instance,

\setmathfont[range=\checkmark]{Asana Math}

but this will provide the symbol only when in math, because \checkmark simply prints the character ✓ (Unicode U+2713).

So you can also add

\AtBeginDocument{%
  \renewcommand\checkmark{\ensuremath{\char\string"2713}}%
}

and then the redefinition would work.

Here's an example:

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\setmathfont[range=\checkmark]{Asana Math}

\AtBeginDocument{%
  \renewcommand\checkmark{\ensuremath{\char\string"2713}}%
}

\begin{document}

A checkmark in the main font, just to show the difference: \char"2713 
\begin{itemize}
\item[\checkmark] a
\item[\checkmark] b
\item[\checkmark] c
\end{itemize}

\end{document}

enter image description here

As you see, \checkmark uses a different font (Asana Math, in this case).

4
  • I am not sure if I know what I am asking, but isn't Cambria a "unicode" font? Shouldn't it have a some kind of checkmark?
    – alfC
    Apr 14 '13 at 9:51
  • @alfC OpenType fonts are not required to cover the entire range.
    – egreg
    Apr 14 '13 at 9:51
  • +1 as I note in a comment on my answer this preserves the Unicode encoding in the generated pdf which may have advantages over using the AMS encoded checkmark which is really an X (but makes the tick look different until someone makes a Unicode encode version of the AMS glyphs) Apr 14 '13 at 10:49
  • Besides, why the check mark is taken from math font? It is just an artifact of TeX fonts :). Apr 14 '13 at 12:27
3

I found these three workarounds, on top of the other answers:

1) Simple Workaround (using package and a different command)

As a workaround I am using the \Checkmark from the bbding package as from this answer https://tex.stackexchange.com/a/10194/1871. Unfortunately it is not exactly equal to the checkmark from amsfonts.

bbding

\documentclass{article}
\usepackage{bbding} % for the \Checkmark command 
\usepackage{unicode-math} 
\usepackage{fontspec}
\setmainfont{Cambria}
\setsansfont{Calibri}
\setmathfont{Cambria Math}


\begin{document} 
$a + b$
\begin{itemize}
\item[\Checkmark] a
\item[\Checkmark] b 
\item[\Checkmark] c
\end{itemize}

\end{document}

2) "MSWord"-consistent answer (use Wingdings font)

Itemize in MSWord use the Wingdings font for check marks, therefore this gives a consistent look (look for David's answer for the rest of the code).

\newfontfamily\wingdingsfont{Wingdings}
\newcommand\wingdings[1]{{\wingdingsfont\symbol{#1}}}
\AtBeginDocument{\renewcommand\checkmark{\wingdings{252}}}

wing

3) Poor's man (use existing unicode glyphs within Cambria)

Another pure-Cambria (but horrible) workaround is to use a different symbol for checkmark (which naturally looks more like a square root):

\begin{itemize}
\item[$⎷$] a
\item[√] b 
\item[\checkmark] c (for comparison) %using solution #2
\end{itemize}

poorman

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.