Katex doesn't work when used in more than one question? How to resolve this? | XM Community
Skip to main content
Question

Katex doesn't work when used in more than one question? How to resolve this?

  • January 9, 2024
  • 3 replies
  • 82 views

Forum|alt.badge.img+4

Hi Everyone,

 

I am using Katex to write some math questions that involves algebraic expressions like x squared and etc. I used this forum to incorporate the Katex: 

The solution provided there worked but works only if there is one question with Katex. I tried to use the same steps for a second question and now in the preview all i get is some weird long text that is filled with some code. Can anyone help how to resolve this?

3 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • January 9, 2024

@Lrudman,

Are the questions on the same page or different pages?  What JS are you using?  Have you added it to each question?


Forum|alt.badge.img+4
  • Author
  • Level 1 ●
  • 6 replies
  • January 22, 2024

Using page breaks between the questions fixed the problem.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • January 22, 2024

@Lrudman,

If you put the script from the other post in the survey header, then you don’t need to add it to every question and you don’t have to worry about page breaks:

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