sample-macros.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 in your configuration, or as part
  12. | of the body of the page itself.
  13. |
  14. |-->
  15. <script type="text/x-mathjax-config">
  16. MathJax.Hub.Config({
  17. TeX: {
  18. Macros: {
  19. RR: '{\\bf R}', // a simple string replacement
  20. bold: ['\\boldsymbol{#1}',1] // this macro has one parameter
  21. }
  22. }
  23. });
  24. </script>
  25. <script type="text/javascript" src="../MathJax.js?config=TeX-AMS_HTML-full"></script>
  26. </head>
  27. <body>
  28. <!--
  29. |
  30. | Here we use a math block that contains nothing but definitions in
  31. | standard TeX format. It is enclosed in a DIV that doesn't display, so
  32. | that there are no extra spaces generated by having the extra
  33. | mathematics in the text.
  34. |
  35. | The first macro makes it easy to display vectors using \<x,y,z>
  36. | the second uses \newcommand to create a macro
  37. |
  38. |-->
  39. <div style="display:none">
  40. \(
  41. \def\<#1>{\left<#1\right>}
  42. \newcommand{\CC}{\mathbf{C}}
  43. \)
  44. </div>
  45. <p>
  46. This page uses two different methods to define macros: either putting them
  47. in JavaScript notation in the MathJax configuration, or in TeX notation in
  48. the body of the document.
  49. </p>
  50. <p>Some math that used the definitions:
  51. \[
  52. f\colon\RR\to\RR^3 \hbox{ by } f(t)=\< t+1,{1\over 1+t^2}, \sqrt{t^2+1} >
  53. \]
  54. and
  55. \[
  56. \{\,z\in\CC \mid z^2 = \bold{\alpha}\,\}
  57. \]
  58. </body>
  59. </html>