al-folio icon indicating copy to clipboard operation
al-folio copied to clipboard

Inline mathjax in image caption renders as display

Open TomClabault opened this issue 1 year ago • 1 comments

Have you checked that your issue isn't already filed?

  • [X] I read through FAQ and searched through the past issues, none of which addressed my issue.
  • [X] Yes, I have checked that this issue isn't already filed.

Bug description

Inline mathjax in image caption renders as display

How to reproduce the bug

<div class="caption">
    Inline $$Mathjax$$ isn't inline.
</div>

Error messages and logs

No response

What operating system are you using?

Windows

Where are you seeing the problem on?

Running locally with Docker

More info

Expected result: Should render all 4 words on the same line

Result observed: image

Note that this isn't really only related to image captions. Having the Mathjax code in a simple <div> with no class renders the same (although not centered within the page).

TomClabault avatar Jul 25 '24 14:07 TomClabault

@TomClabault From the mathjax documentation :

The default math delimiters are $$...$$ and \[...\] for displayed mathematics, and \(...\) for in-line mathematics. Note in particular that the $...$ in-line delimiters are not used by default. That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly.

The $$...$$ should be used for displayed mathematics, which are on separate lines. You should be able to use $...$ or \(...\) for the in-line mathematics. Can you try these instead?

m-julian avatar Oct 17 '24 11:10 m-julian

The issue you're encountering happens because $$ in MathJax is used for display math, not inline math. To render inline math in MathJax, you should use single dollar signs $...$ instead of double dollar signs $$...$$.

Here’s how to fix it:

<div class="caption">
    Inline $Mathjax$ isn't inline.
</div>

If you want to configure MathJax to recognize $$ for inline math as well, you'll need to adjust the MathJax configuration. Add the following configuration in your MathJax setup:

MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    displayMath: [['$$', '$$'], ['\\[', '\\]']]
  }
};

This config ensures that $...$ is used for inline math and $$...$$ for display math.

#hacktoberfest

CodeLikeAGirl29 avatar Oct 24 '24 09:10 CodeLikeAGirl29

Looks good and simple, waiting on #2795 to try this out!

TomClabault avatar Oct 27 '24 14:10 TomClabault

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 28 '24 12:12 stale[bot]

MathJax, you should use single dollar signs $...$ instead of double dollar signs $$...$$.

That did the trick, thanks!

TomClabault avatar Dec 28 '24 13:12 TomClabault