sample-macros.html 1.6 KB

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