texhtml
Normally, MathJax will not process math that includes HTML tags, other
than a few exceptions like <br> and HTML comments. The texhtml
extension provides a method of including HTML tags within TeX
expressions. For example, this can allow you to include form inputs
(like answer blanks or drop-down menus) in your expressions.
Warning
Because the HTML within TeX expressions is not filtered in any way by MathJax, you should not use this extension in settings where your readers can enter expressions that are shown to other users. That would allow them to enter maliceous code (including script tags) that could compromise the security of your site.
For this reason, you must not only load the texhtml extension,
but must set the allowTexHTML option in the tex
block of your MathJax configuration, as described in the
configuration example below.
To include HTML tags within your expressions, enclose the HTML within
the special <tex-html>...</tex-html> tags. For example,
when \(x=3\), \(x^2 + 3x + 1 =
<tex-html><input type="text" id="answer" size="5"/></tex-html>\).
renders as follows:
You could then use javascript to retrieve the value of the input
element with id="answer" and test if the solution is correct.
See the Specifying the size of HTML in Expressions section for information about how MathJax determines the size of HTML embedded in TeX expressions.
This package is not autoloaded, so you must request it explicitly if
you want to use it. To load the texhtml extension explicitly, add
'[tex]/texhtml' to the load array of the loader
block of your MathJax configuration, and add 'texhtml' to the
packages array of the tex block.
window.MathJax = {
loader: {load: ['[tex]/texhtml']},
tex: {
packages: {'[+]': ['texhtml']},
allowTexHTML: true
},
};
Note that the texhtml extension is not allowed to be loaded with
\require{texhtml}.
texhtml Commands
The texhtml extension implements the following macros:
<