Looking for up-to-date methods for LaTeX typesetting in surveys | XM Community
Skip to main content

I have looked into all of the existing forum posts regarding adding MathJax/KaTeX/other to a Qualtrics survey, but none have been able to work for a single equation. I’ve tried putting the script code in the header as source code, in the questions as body HTML, and in the footer in case the entire page needed to be read before scanning for the equations. I’ve read that there’s a problem with MathJax only working on the first page of the survey, but I haven’t even been able to achieve that. I’ve also tried various different styles for marking code that is to be converted ($x$, $$x$$, \begin{equation} x \end{equation}, etc.).

For context, the survey will then be embedded in an edX webpage using iFrame for students to answer. It’s preferable that instructors can just type in their equations in questions instead of manually uploading an image of it into Qualtrics. This edX page with the iFrame already has MathJax built in.

  1. Does anyone have currently active and functional code to do this within Qualtrics? 
  2. If not, could it be done elsewhere such as in the iFrame HTML?

Thank you so much!

KaTeX solution with no gaps:

 

  1. Survey → Look and Feel → General → Header → Edit → Source (between underline symbol and “More...”). Copy and paste the starter template from https://katex.org/docs/browser.html
     
  2. Add your equation to the question inside the following brackets:
    <span class=”katex”> f(x) = e^x </span>
     
  3. Survey → Builder → Question Behaviour → JavaScript. Replace with the following:

 

Qualtrics.SurveyEngine.addOnload(function() {
jQuery(".katex").each(function() {
katex.render(this.innerHTML, this, { throwOnError: false });
});
});

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

 

  1. Preview to verify

Leave a Reply