8
$\begingroup$

Is there a way to put a green check mark in the body of my text using MathJax/mhchem Syntax? Or a red X to indicate that this thinking is wrong?

Something like this:

enter image description here

I want to use it while double checking my work and indicate whether or not the math checks out.

Closest I found was here hBy2Py shares how to highlight text

$\require{enclose}\enclose{actuarial}[mathbackground="#6ad898"]{2x}$ $\require{enclose}\enclose{actuarial}[mathbackground="#6ad898"]{2x}$

$\endgroup$
13
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ seconds.... only seconds... :D $\endgroup$ – Martin - マーチン Feb 6 '17 at 4:18
  • $\begingroup$ @Martin-マーチン I went straight for the Unicode jugular; you took the time to lay out the various options. :-) $\endgroup$ – hBy2Py Feb 6 '17 at 4:19
  • $\begingroup$ Well, you boxed it, so together we have all the options ;) Also, this gets me one step closer to sportsmanship. $\endgroup$ – Martin - マーチン Feb 6 '17 at 4:22
  • $\begingroup$ @Martin-マーチン Hehe, bored with the main site badges, are we? Too easy, are they? ;-) $\endgroup$ – hBy2Py Feb 6 '17 at 4:23
  • $\begingroup$ No, not really, I just noticed I am very, very close. Also you can use boxed versions without enclose, might not look as pretty though: $\Large\color{\navy}{\unicode{x2611}\unicode{x2612}}$ $\Large\color{\navy}{\unicode{x2611}\unicode{x2612}}$ $\endgroup$ – Martin - マーチン Feb 6 '17 at 4:28
  • $\begingroup$ @Martin-マーチン I think \bbox is probably the best way to go. No \require needed, and there's a lot more flexibility on the formatting. Eventually I'll get \bbox written up on that other post.... $\endgroup$ – hBy2Py Feb 6 '17 at 4:38
  • 1
    $\begingroup$ Be advised that not all of that renders the same on different devices. On mobile you run into even more trouble. It just is very dependent on the fonts that are available... $\endgroup$ – Martin - マーチン Feb 10 '17 at 16:49
12
$\begingroup$

You can use the following for a green check mark since it is implemented in amssymb:

  • $\Large\color{\green}{\checkmark}$ $\Large\color{\green}{\checkmark}$
  • $\Large\color{\green}{\unicode{10004}}$ $\Large\color{\green}{\unicode{10004}}$ (matches last entry from below)
  • $\Large\color{\green}{\unicode{10003}}$ $\Large\color{\green}{\unicode{10003}}$ (should also match the above)

Unfortunately the cross is not as simple and the solution outlined at TeX.SX doesn't work for MathJax as pifont is not defined. You can use the following an intermediate solutions:

  • Poor man's bold times: $\Large\color{\red}{\pmb\times}$ $\Large\color{\red}{\pmb\times}$
  • Sans serif X: $\Large\color{\red}{\pmb{\mathsf{X}}}$ $\Large\color{\red}{\pmb{\mathsf{X}}}$
  • Plain unicode: $\Large\color{\red}{✘✗}$ $\Large\color{\red}{✘✗}$
  • Unicode via macro: $\Large\color{\red}{\unicode{10007}}$ $\Large\color{\red}{\unicode{10007}}$ (should match \checkmark above)
  • Unicode via macro (bold): $\Large\color{\red}{\unicode{10008}}$ $\Large\color{\red}{\unicode{10008}}$ (see also: MathJax Unicode support)
$\endgroup$
  • $\begingroup$ I thought your answer was very useful too, thank you. Decided to let the voting system to choose the accepted answer. $\endgroup$ – eromod Feb 10 '17 at 16:21
  • $\begingroup$ Fun fact: doesn't really work on mobile. $\endgroup$ – Martin - マーチン Feb 10 '17 at 16:47
10
$\begingroup$

A meta answer to a meta question, making it meta². Be careful with conventions like this. They are not as intuitive and universal as you might think.

  • I've seen

    ✘ Artificial Flavours

    written on products in the UK, meaning "without artificial flavours". In Germany, for instance, this would be interpreted as the opposite. There, in votes, you do not tick your preferred candidate, you cross them. The older guys might remember times, when (computer) checkboxes contained x's before they removed this ambiguity.

  • Red is a lucky color in China.

However, your combinations (red cross and green tickmark, if they appear as opposites) should be universally understood by all users who come here to SE.

$\endgroup$
  • 6
    $\begingroup$ Perhaps $\bbox[border:3px solid red;color:red]{\Huge \,\unicode{x2620}\,}~~$? :-) (\unicode{x2620}) $\endgroup$ – hBy2Py Feb 6 '17 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .