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.

Math in line with the text using $ .. $ instead of \ (.. \)

See original GitHub issue

Hi.

I have a website in html5 where I put the rendering code of KaTeX v0.10.1 between the <head> .. </ head> tags

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous"> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script> <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>

And it displays the mathematical symbols delimited with $$ .. $$ and with \ [ .. \], but it does not work when I want to put mathematics in line with the text, that is, mathematical symbols inside a paragraph with simple dollar $ .. $, instead only works \( .. \)

I’ve already tried putting the following in the <body>..>/body> :

<script>
    renderMathInElement(document.body,{delimiters: [
    					{left: "$", right: "$", display: false},
					  {left: "$$", right: "$$", display: true}
]});

</script>

but nothing.

The website where I am doing this testing is:

https://matematicauniversitaria.com/matlai/ (notice the $y^2$ that appears there)

Any suggestions?

How do I make the mathematical symbols appear in line with the text using $ … $?

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
ronkokcommented, Apr 7, 2019

Ah yes, silly mistake. The \ character needs an escape.

<script>
    renderMathInElement(document.body,{delimiters: [
      {left: "$$", right: "$$", display: true},
      {left: "$", right: "$", display: false},
      {left: "\\[", right: "\\]", display: true},
      {left: "\\(", right: "\\)", display: false}
    ]});
</script>
1reaction
ronkokcommented, Apr 6, 2019

I do not pretend to be an expert in security issues. I don’t really know the intended effect of declarations like integrity="sha384-... or how defer might interact with that sort of thing. I do that if I strip that out and move the renderMathInElement script to the end of the body, then the page loads fine. To be specific, my <head> includes:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css">
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" crossorigin="anonymous"></script>

and the renderMathInElement comes after the math.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline equation in latex with text - TeX - LaTeX Stack Exchange
Text text text $ \some \math \commands $ more text text text. Note that if you use double $$ instead, the formula will...
Read more >
Insert Inline Math in Text - Wolfram Language Documentation
You can put typeset mathematical expressions directly inline in text in Wolfram notebooks. Type to start typing math in text and to stop:...
Read more >
Display style in math mode - Overleaf, Online LaTeX Editor
This article explains how to manually adjust the style of typeset mathematics—but we'll start with a quick reminder of the visible differences between...
Read more >
Formatting Math as Text: Common Algebraic Notation
Demonstrates formatting for common algebraic expressions, and explains how to avoid common formatting errors and confusion.
Read more >
Create math equations using ink or text with Math Assistant in ...
Learn how to create math equations by drawing or typing an equation, then using Math Assistant.
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