question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rendering $..$ and macros not work

See original GitHub issue

Hi. I have followed all the instructions to render with $ .. $ and it does not work. And neither when creating my macros

<body> <script> $(document).ready(function() { katex.render(formula, element, { delimiters: [ {left: "$$", right: "$$", display: true}, {left: "\\[", right: "\\]", display: true}, {left: "$", right: "$", display: false}, {left: "\\(", right: "\\)", display: false} ], macros: { // Algebra-Precal "\\lcm": "\\mathop{\\mathrm{lcm}}", "\\sen" "\text{sen}\\", // Calculus "\\dd": "\\mathop{\\mathrm{d} #1}", "\\abs": "\\lvert#1\\rvert", } }); }); </script> </body>

the page with this problem is https://prob.matematicauniversitaria.com/

in the CSS I only have:

p{ font-family: times new roman; /*Latin Modern Math*/ font-size: 100% } .katex{ font-size: 1.10em; /*1.16em dicen q es el 100%*/ }

and in the head I have the same thing that it provides https://katex.org/docs/autorender.html

What should I correct? Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
MathSalomoncommented, Apr 24, 2019

Thank you. Now I can see that it renders perfectly with the macros.

capture

I used

  renderMathInElement(document.body, {
    delimiters: [
    {left: "$$", right: "$$", display: true},
    {left: "\\[", right: "\\]", display: true},
    {left: "$", right: "$", display: false},
    {left: "\\(", right: "\\)", display: false} ],
    macros: {
      // Algebra-Precal
      "\\lcm": "\\mathop{\\mathrm{lcm}}",
      "\\sen": '\\text{sen}\\,',
      // Calculus
      "\\dd": "\\mathop{\\mathrm{d} #1}",
      "\\abs": "\\lvert #1 \\rvert",
      }
  });
 }); </script>

in the <body>

Best regards!

1reaction
alexjbestcommented, Apr 24, 2019

You aren’t loading katex properly with your document.ready code, it looks like you aren’t loading jquery so you can’t use $(document).ready(. I have put a fixed version below. You should also remove onload="renderMathInElement(document.body);" or maybe even the whole katex auto-render load line, as currently you are loading katex twice.

  document.addEventListener("DOMContentLoaded", function() {
  renderMathInElement(document.body, {
    delimiters: [
    {left: "$$", right: "$$", display: true},
    {left: "\\[", right: "\\]", display: true},
    {left: "$", right: "$", display: false},
    {left: "\\(", right: "\\)", display: false} ],
    macros: {
      // Algebra-Precal
      "\\lcm": "\\mathop{\\mathrm{lcm}}",
      "\\sen": '\\text{sen}\\,',
      // Calculus
      "\\dd": "\\mathop{\\mathrm{d} #1}",
      "\\abs": "\\lvert #1 \\rvert",
      }
  });
 });
Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML macro not rendering - Confluence
Hi all, I have a Page with a HTML macro inside. The content of the macro is a simple text line. When I...
Read more >
macros not rendering in NVelocity
1 Answer 1 ... The macro doesn't work because NVelocity (and its ancestor Velocity) determine if #age is a directive or macro at...
Read more >
macros not rendering - Using Umbraco 7
The problem I'm having is that none of the macros are rendering on the blogroll. Macros are inserted using the richtext editor which...
Read more >
Troubleshooting - mkdocs-macros - Read the Docs
Any other cases (notably unknown attribute or function call) will cause the page to ... In principle a rendering error in a macro...
Read more >
Myxwiki: macros do not work - Help / Discuss
org.xwiki.rendering.macro.MacroExecutionException: The execution of the [velocity] script macro is not allowed. Check the rights of its last ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found