math.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <script setup lang="ts">
  2. import LiveExample from "~/components/LiveExample.vue"
  3. </script>
  4. <template>
  5. <UPage>
  6. <UPageHeader title="Math" description="Inline $...$ and display $$...$$ math with KaTeX rendering." />
  7. <UPageBody>
  8. <div class="space-y-8">
  9. <section>
  10. <h2 class="text-lg font-semibold text-highlighted mb-3">Inline Math</h2>
  11. <div class="space-y-6">
  12. <LiveExample
  13. title="Basic Inline"
  14. description="Use single $ delimiters for inline math."
  15. :content="`The formula $E = mc^2$ is famous.`"
  16. />
  17. <LiveExample
  18. title="Complex Expressions"
  19. description="Inline math handles complex LaTeX."
  20. :content="`The sum $\\sum_{i=1}^n i = \\frac{n(n+1)}{2}$ converges nicely.`"
  21. />
  22. <LiveExample
  23. title="Greek Letters"
  24. description="Standard LaTeX Greek letters work inline."
  25. :content="`Angles: $\\alpha$, $\\beta$, $\\gamma$ are common variables.`"
  26. />
  27. </div>
  28. </section>
  29. <USeparator />
  30. <section>
  31. <h2 class="text-lg font-semibold text-highlighted mb-3">Block Math</h2>
  32. <div class="space-y-6">
  33. <LiveExample
  34. title="Display Math"
  35. description="Use $$...$$ for display math blocks. Type $$ at the start of an empty paragraph."
  36. :content="`Here is a displayed equation:\n\n$$\n\\int_{-\\infty}^{\\infty} e^{-x^2} \\, dx = \\sqrt{\\pi}\n$$`"
  37. />
  38. <LiveExample
  39. title="Matrices"
  40. description="Block math supports matrices and arrays."
  41. :content="`A 2x2 matrix:\n\n$$\n\\begin{bmatrix}\na & b \\\\\nc & d\n\\end{bmatrix}\n$$`"
  42. />
  43. <LiveExample
  44. title="Piecewise Functions"
  45. description="Block math handles cases and piecewise definitions."
  46. :content="`Piecewise function:\n\n$$\nf(x) = \\begin{cases}\nx^2 & \\text{if } x > 0 \\\\\n0 & \\text{otherwise}\n\\end{cases}\n$$`"
  47. />
  48. </div>
  49. </section>
  50. <USeparator />
  51. <section>
  52. <h2 class="text-lg font-semibold text-highlighted mb-3">Mixed Content</h2>
  53. <div class="space-y-6">
  54. <LiveExample
  55. title="Math with Other Syntax"
  56. description="Math works alongside formatting, callouts, refs, and tasks."
  57. :content="`## Math Document\n\nYou can use **bold** and $x$ inline math together.\n\n> [!NOTE] Callouts with math: $E = mc^2$\n\n[[Physics Notes]] with $\\theta$ angle.\n\nTODO Review $\\Delta$ formula`"
  58. />
  59. </div>
  60. </section>
  61. </div>
  62. </UPageBody>
  63. </UPage>
  64. </template>