How do I integrate KaTeX into Qualtrics? | XM Community
Skip to main content

How do I integrate KaTeX into Qualtrics?

  • October 12, 2022
  • 5 replies
  • 228 views

Forum|alt.badge.img+1

I am trying to put together a survey based on math formulae using KaTeX. I can add the JavaScript to a question following the guidance on an old forum post but am struggling to add the Katex style sheet (css) and JavaScript to my header as suggested.
Can someone please walk me through this? Thanks!
For reference I am trying to follow this old post:
https://community.qualtrics.com/XMcommunity/discussion/comment/32547#Comment_32547

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 12, 2022

Add this to the survey header. Make sure you click on <> to put it in source mode first.



Forum|alt.badge.img+1
  • Author
  • October 12, 2022

Thanks TomG. I can see how you would do this for individual questions via the rich content editor in each individual element of the survey. Is there a way to do it for the entire survey globally?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 13, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/50761#Comment_50761Put it in the survey header. Look & Feel -> General -> Header (edit). Then click the <> icon.


Forum|alt.badge.img+1
  • Author
  • October 13, 2022

Thanks. I put the info. you posted here in the header. I also have the style sheet in Look & Feel -> Style -> External CSS. Is this required?
Is there a way to enable the JavaScript globally as well or does this need to be done in each question individually? i.e. this piece...
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*/
});


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • October 13, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/50784#Comment_50784You don't need external css because you already have a link to the katex stylesheet in the header.
Yes, you can make the script global, by putting it in the header inside a