CAVEAT: Due to the use of Unicode, the below may not render properly on all systems, especially mobile devices. (Thanks, Martin!)
Green boxed checkmark
\require{enclose}
\enclose{box}[mathcolor="green"]{\unicode{x2714}}
$
\require{enclose}
\enclose{box}[mathcolor="green"]{\unicode{x2714}}
$
Red boxed stylized 'X'
\require{enclose}
\enclose{box}[mathcolor="red"]{\unicode{x2718}}
$
\require{enclose}
\enclose{box}[mathcolor="red"]{\unicode{x2718}}
$
Unicode values taken from the Wikipedia webpages for check mark and X mark.
If you want thicker borders on the boxes, you could go with \bbox
instead, e.g.:
\bbox[border:3px solid green;color:green,2pt]{\unicode{x2714}}
$
\bbox[border:3px solid green;color:green,2pt]{\unicode{x2714}}
$
FWIW, this also has the advantage of not requiring \require{...}
.
Also, as Martin notes in his answer to the linked formatting question/post, you can use \begingroup
and \newcommand
to define handy-dandy macros for including these puppies in your MathJax:
\require{begingroup}
\begingroup
\newcommand{checkbox}{\bbox[border:3px solid green;color:green,1px]{\Large \unicode{x2714}}~~}
\newcommand{xbox}{\bbox[border:3px solid red;color:red]{\Large \,\unicode{x2718}\,}~~}
\checkbox\text{This statement is correct!} \\
\xbox\text{This statement is not.}
\endgroup
$
\require{begingroup}
\begingroup
\newcommand{checkbox}{\bbox[border:3px solid green;color:green,1px]{\Large \unicode{x2714}}~~}
\newcommand{xbox}{\bbox[border:3px solid red;color:red]{\Large \,\unicode{x2718}\,}~~}
\checkbox\text{This statement is correct!} \\
\xbox\text{This statement is not.}
\endgroup
$
I shamelessly stole Mart's use of \Large
in his answer here. Note also that the formatting went a little sideways, and I had to use some extra regular (~
) and narrow (\,
) spaces in the new command definitions to make everything look right (in my browser, at least). Feel free to shamelessly steal these macros, if they'll be useful to you!