# \xmark gives out 7 rather than a cross mark

I defined \xmark and \cmark as follow but when I run it, the number 7 (for \xmark) and 3 (for \cmakr) is presented on my file. I have no idea with this.

\documentclass{article}
\usepackage{pifont}
\newcommand{\cmark}{\ding{51}}
\newcommand{\xmark}{\ding{55}}
\begin{document}
\begin{eqnarray*}
\xmark E(L^2) &=& E(L\cdot L)\\\
&=& E(L)\cdot E(L)\\\
&=& \mu_l \cdot \mu_l\\\
&=& \mu_l^2
\\\
\cmark E(L \cdot K) &=& E(L) \cdot E(K) \text{ \small{if $L$ and $K$ are stochastic independent}}
\end{eqnarray*}
\end{document}

• (1) your do does not compile (needs amsmath for the \text command. (2) never use eqnarray, it is horribly broken, here is a survey: tug.org/pracjourn/2012-1/madsen.html, (3) pifont is a text font, thus may behave strangely in math. Try wrapping the \ding{...} in \text... – daleif Nov 12 '14 at 10:34
• \xmark is a text command and its behavior in math is unpredictable. If you need it in math, just do \newcommand{\xmark}{\text{\ding{55}}} with \usepackage{amsmath}. – egreg Nov 12 '14 at 11:39

There are other similar questions on the site, for different symbol fonts. The main problem is that \ding{51} acts by

1. opening a group;
2. selecting the pi font;
3. typesetting character number 51;
4. closing the group.

However, step 2 is completely ineffective when TeX is in math mode, so step 3 tells the program to typeset the math character corresponding to 51, which is a 3.

Solution: enclose the call in \text.

\documentclass{article}
\usepackage{amsmath}
\usepackage{pifont}
\newcommand{\cmark}{\text{\ding{51}}}
\newcommand{\xmark}{\text{\ding{55}}}

\begin{document}
\begin{align*}
\xmark
E(L^2)       &= E(L\cdot L) \\
&= E(L)\cdot E(L) \\
&= \mu_l \cdot \mu_l \\
&= \mu_l^2 \\
\cmark
E(L \cdot K) &= E(L) \cdot E(K) \text{ if $L$ and $K$ are stochastic independent}
\end{align*}
\end{document}


Notes: eqnarray should never be used; \small` doesn't take an argument, and in this case it's not needed (and it would unbalance the display).