sample-autoload.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Example of defining a macro that autoloads an extension</title>
  5. <!-- Copyright (c) 2012-2017 The MathJax Consortium -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <!--
  10. |
  11. | This page shows how to define macros that autoloads an extension
  12. | where those macros are implemented.
  13. |
  14. | The \cancel, \bcancel, \xcancel, and \cancelto macros are
  15. | all defined within the cancel extension, so we tie these
  16. | macros to the function that loads an extension, passing it
  17. | the name of the extension to load.
  18. |
  19. |-->
  20. <script type="text/x-mathjax-config">
  21. MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  22. MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
  23. cancel: ["Extension","cancel"],
  24. bcancel: ["Extension","cancel"],
  25. xcancel: ["Extension","cancel"],
  26. cancelto: ["Extension","cancel"]
  27. });
  28. });
  29. </script>
  30. <script type="text/javascript" src="../MathJax.js?config=TeX-AMS_HTML-full"></script>
  31. </head>
  32. <body>
  33. <p>
  34. This page makes <code>\cancel</code>, <code>\bcancel</code>,
  35. <code>\xcancel</code>, and <code>\cancelto</code> all be defined so that
  36. they will load the <code>cancel.js</code> extension when first used.
  37. </p>
  38. <p>
  39. Here is the first usage: \(\cancel{x+1}\). It will cause the cancel
  40. package to be loaded automatically.
  41. </p>
  42. </body>
  43. </html>