This page is a summary, expansion, and working example of the topic ‘Labeling equation terms’
from the
MathJax Users Group
in April 2011.
It includes solutions that were contributed by Davide P. Cervone.
There is a known bug that affects the positioning of the tooltips, which may be fixed soon.
There are four versions of tool tips:
\sum_{n=0}^\infty {\tooltip{x}{\text{converges for }|x|\lt 1 }}^n = \frac{1}{1-x}yields (hover over the ‘$x$’ in the expression $x^n$ below)
\sum_{n=0}^\infty {\tooltipc{x}{\text{converges for }|x|\lt 1 }}^n = \frac{1}{1-x}yields (hover over the green ‘$x$’ below)
\texttip{a}{the first term is an \(a\)} \texttip{+}{a binary operator} \texttip{b}{the second term}yields (hover over each part of the expression below)
\texttip{a}{the first term is an \(a\)} \mathbin{\texttip{+}{a binary operator}} \texttip{b}{the second term}yields (hover over each part of the expression below)
\mathbin
causes the texttipped plus sign to be treated as
a binary operator, which improves the spacing.
\frac{\texttipc{a+b}{numerator}}{\texttipc{2}{denominator}}yields (hover over each green part of the expression below)
Although this capability is not built into MathJax, it is easy to obtain by following the
instructions on this page
(and using the source code of this page as an example).
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { var TEX = MathJax.InputJax.TeX, MML = MathJax.ElementJax.mml; TEX.Definitions.macros.tooltip = "myToolTip"; TEX.Parse.Augment({ myToolTip: function (name) { var arg = this.ParseArg(name), tip = this.ParseArg(name); this.Push(MML.maction(arg,tip).With({actiontype: MML.ACTIONTYPE.TOOLTIP})); } }); });
MathJax.Hub.Config
.TeX: { Macros: { tooltipc: ["\\tooltip{\\color{green}{#1}}{#2}",2], texttip: ["\\tooltip{#1}{\\text{#2}}",2], texttipc: ["\\tooltip{\\color{green}{#1}}{\\text{#2}}",2] } }You need only include the line(s) for the macros you wish to implement.