2
$\begingroup$

The following compiles under LaTeX

\(\left.x\right|_{x\gets\colorbox{yellow}{\(\mathsmaller{+2+h}\)}}\)

but how do I modify it to render under MathJaX?

Note: \colorbox is listed at http://docs.mathjax.org/en/latest/tex.html#tex-commands

but not at http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm#C

P.S. I hope this is the right place to ask. If not, where?

$\endgroup$
9
$\begingroup$

That does not compile under LaTeX. This compiles under LaTeX:

\documentclass{article}
\usepackage{amsmath,color,relsize}
\begin{document}
\(\left.x\right|_{x\gets\colorbox{yellow}{\(\mathsmaller{+2+h}\)}}\)
\end{document}

The relevant point is that the commands \colorbox and \mathsmaller come from the packages color and relsize, respectively.

The \colorbox command is supported by MathJax because the color package has been implemented for MathJax, but you must use \require{color}, which is MathJax's method of loading a package.

The relsize package has not (currently) been implemented for MathJax, so that even writing \require{relsize} will not help, there is no way to use the \mathsmaller command.

The best you can do is something like

$$ \require{color} \left.x\right|_{x\gets\colorbox{yellow}{$+2+h$}} $$

which produces

$$ \require{color} \left.x\right|_{x\gets\colorbox{yellow}{$+2+h$}} $$

$\endgroup$
  • $\begingroup$ 1. Just to clarify: since I post very rarely, I do not really know how to make things show so for the code to show as I had it (the same as yours), I added a couple of \ in front of the parentheses. 2. How do I acknowledge a perfect answer? 3. I need to find a tutorial on how to operate on stackexchange. $\endgroup$ – schremmer Nov 18 '15 at 20:42
  • $\begingroup$ There is in fact no need for mathsmaller as your own post shows. So, the answer was not quire perfect. (But I am still very grateful.) $\endgroup$ – schremmer Nov 18 '15 at 21:12
  • $\begingroup$ There is no need to \require{color}, you can use the BBox extension which is automatically loaded on math.SE. You can do something like \left.x\right|_{x\gets\bbox[yellow]{+2+h}} to get $$\left.x\right|_{x\gets\bbox[yellow]{+2+h}}$$ $\endgroup$ – achille hui Nov 19 '15 at 7:51
  • $\begingroup$ I wanted to experiement a bit with bbox before saying anything and it is indeed very nice. The only problem is that bbox is not a LaTeX command which makes it tedious when bringing in LaTeX for MathJaxing. Maybe somebody will make a bbox package for LaTeX, though. $\endgroup$ – schremmer Nov 22 '15 at 20:45

You must log in to answer this question.

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