Thanks to Davide I have been able to use mathtips in my website. However, I want to do some CSS formatting for my math tips.
I want to make so it is possible to put a mathtip on the top (horizontally centered around the mathtip first argument (the text that will show the mathtip if you hover over it), not the whole equation), bottom (horizontally centered around the mathtip first argument), left (vertically centered around the mathtip first argument), and right (vertically centered around the mathtip first argument).
I also want there to be a little arrow-like extension pointing towards the mathtip first argument, background color, and colored text. I got the CSS to work for the above case but there are a few issues:
1. There is a little white rectangle with a black border that I want to get rid of
2. The above text starts at the right edge of the first argument of the mathtip instead of being horizontally centered and above the first argument.
3. I don't know how to do the CSS arrow-like extension and positioning for the other combinations (left, right, and below)
4. I want to make the tooltip appear more quickly.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
MathJax = {
loader: {},
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
packages: { '[+]': ['bold-chars'] },
macros: {
recip: ['\\frac{1}{#1}', 1],
h: ['\\frac{#1}{2}', 1],
eps: '\\varepsilon',
R: '\\mathbb{R}',
a: ['\left\vert #1 \right\vert}', 1],
p: ['\\left( #1 \\right)', 1],
iff: '\\Longleftrightarrow',
b: ['\\textcolor{bluee}{#1}', 1],
r: ['\\textcolor{redd}{#1}', 1],
pu: ['\\textcolor{purplee}{#1}', 1],
go: ['\\textcolor{goldd}{#1}', 1],
pi: ['\\textcolor{pinkk}{#1}', 1],
lb: ['\\textcolor{lightbluee}{#1}', 1],
g: ['\\textcolor{greenn}{#1}', 1],
frac: ['\\genfrac{} {} {2} {0} {#1}{#2}', 2],
beq: '\\mathrel{\\vcenter{\\rlap{\\Rule{2ex}{3px}{0px}}\\raise9px{\\Rule{2ex}{3px}{0px}}}}',
bm: '\\mathrel{\\vcenter{\\Rule{1.5ex}{2px}{0px}}}',
bp: '\\boldsymbol{+}'
}
},
startup: {
ready() {
const { MacroMap } = MathJax._.input.tex.SymbolMap;
const { Configuration } = MathJax._.input.tex.Configuration;
const BaseMethods = MathJax._.input.tex.base.BaseMethods.default;
new MacroMap('bold-chars', {
'=': ['Macro', String.raw`\mathrel{\vcenter{\rlap{\Rule{2ex}{3px}{0px}}\raise9px{\Rule{2ex}{3px}{0px}}}}`],
'-': ['Macro', String.raw`\mathrel{\vcenter{\Rule{20px}{2px}{0px}}}`],
'+': ['Macro', String.raw`\mathrel{\vcenter{\rlap{\kern7px\Rule{2px}{9px}{7px}}\Rule{16px}{2px}{0px}}}`]
}, BaseMethods);
Configuration.create('bold-chars', { handler: { character: ['bold-chars'] } });
MathJax.startup.defaultReady();
}
}
};
</script>
<script type="text/javascript" src="path-to-MathJax/MathJax.js?config=TeX-AMS_HTML">
</script>
<script type="text/javascript" id="MathJax-script" async
</script>
<link rel="stylesheet" href="style.css">
\(\definecolor{redd}{RGB}{232,9,0}\)
\(\definecolor{bluee}{RGB}{0,77,255}\)
\(\definecolor{purplee}{RGB}{152,102,255}\)
\(\definecolor{goldd}{RGB}{204, 153, 0}\)
\(\definecolor{pinkk}{RGB}{244, 136, 189}\)
\(\definecolor{lightbluee}{RGB}{0, 176, 240}\)
\(\definecolor{greenn}{RGB}{114, 221, 0}\)
</head>
<body>
<script>document.documentElement.className += ' spoiler-js';</script>
<div class="spoiler spoiler-state-expanded" text="Introduction">
<div class="spoiler-content">
<div class="row">
<div class="column_left">
The slope of the line through the points $(\r{x_1},\g{y_1})$ and
$(\lb{x_2},\pu{y_2})$ is given below:
$$\begin{aligned}
\text{slope}&=\frac{\b{\text{vertical change}}}{\go{\text{horizontal change}}}\\[10pt]
&=\frac{\b{\mathtip{\text{change in }y}{\class{mathtipabove}{hi}}}}{\go{\text{change in
}x}}\\[10pt]
&=\frac{\b{\Delta y}}{\go{\Delta x}}\\[10pt]
&=\frac{\pu{y_2}- \g{y_1}}{\lb{x_2} + \r{x_1}}
\end{aligned}$$
</div>
<div class="column_right">
style="border: 1px solid #ccc" frameborder=0></iframe>
</div>
</div>
</div>
</div>
<div class="tooltip">Hover over me
<span class="tooltiptext">Tooltip text</span>
</div>
<script src="spoiler.js"></script>
</body>
</html>
If it is helpful I can send the full CSS but it is very long and I didn't want to make the message too long to read.