Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
¿Actualizar dinámicamente un elemento matemático específico de MathJax?

¿Cómo cambio dinámicamente la cadena matemática de un elemento matemático particular de MathJax (v3.2.0) y actualizo su representación?

El siguiente enfoque parece funcionar, pero se siente de un nivel demasiado bajo. Me preocupa que haya errores con este enfoque, o que exista una mejor manera.

 (async() => { await MathJax.typesetPromise(); const mathDiv = document.getElementById('math'); const [mathItem] = MathJax.startup.document.getMathItemsWithin(mathDiv); const mathStrings = [ 'e^{jx} = \\cos x + j \\sin x', '\\hat{f}(\\omega) \\stackrel{\\mathrm{def}}{=} \\frac{1}{\\sqrt{2\\pi}} \\int_{-\\infty}^{\\infty} f(t)e^{-j\\omega t} dt', ]; for (let i = 1; true; ++i) { await new Promise((resolve) => setTimeout(resolve, 2000)); mathItem.reset(); mathItem.math = mathStrings[i % mathStrings.length]; mathItem.render(MathJax.startup.document); document.getElementById('intro').textContent = `After update #${i}:`; } })();
 <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script> <span id="intro">Before update:</span><div id="math">\[\text{placeholder}\]</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Diría que la documentación es bastante clara aquí: https://docs.mathjax.org/en/latest/web/typeset.html#updating-previously-typeset-content

Para la solución más simple posible y más concisa, vaya con:

 const mathDiv = document.getElementById('math'); await MathJax.startup.promise // make sure initial typesetting has taken place MathJax.typesetClear([mathDiv]) // clear MathJax awareness of this element await MathJax.typesetPromise([mathDiv]) // typeset anew

Cambie await por manejo de estilo Promise si lo desea y agregue try , catch según lo desee para manejar los errores.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!