configure.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* global MathJax */
  2. import { mathJaxLoaded } from './util'
  3. import getMeta from '../../utils/meta'
  4. let configured = false
  5. export function configureMathJax() {
  6. if (configured) return
  7. if (!mathJaxLoaded()) return
  8. const inlineMath = [['\\(', '\\)']]
  9. if (!getMeta('ol-no-single-dollar')) {
  10. inlineMath.push(['$', '$'])
  11. }
  12. MathJax.Hub.Config({
  13. messageStyle: 'none',
  14. imageFont: null,
  15. // Fast preview, introduced in 2.5, is unhelpful due to extra codemirror refresh
  16. // and disabling it avoids issues with math processing errors
  17. // github.com/overleaf/write_latex/pull/1375
  18. 'fast-preview': { disabled: true },
  19. 'HTML-CSS': {
  20. availableFonts: ['TeX'],
  21. // MathJax's automatic font scaling does not work well when we render math
  22. // that isn't yet on the page, so we disable it and set a global font
  23. // scale factor
  24. scale: 110,
  25. matchFontHeight: false,
  26. },
  27. TeX: {
  28. equationNumbers: { autoNumber: 'AMS' },
  29. useLabelIDs: false,
  30. },
  31. skipStartupTypeset: true,
  32. tex2jax: {
  33. processEscapes: true,
  34. inlineMath,
  35. displayMath: [
  36. ['$$', '$$'],
  37. ['\\[', '\\]'],
  38. ],
  39. },
  40. })
  41. configured = true
  42. }