Avoid line breaking for each latex fragment

52 views
Skip to first unread message

Peace Keeper

unread,
Apr 21, 2024, 12:25:25 AMApr 21
to MathJax Users
Hello! Is it possible to prevent mathjax from creating a newline for each latex fragment? 

For example: This is a variable $ x $ and another variable $ y $.
Would create a total of 5 lines in the HTML rather than one whole complete line.
Message has been deleted

Peace Keeper

unread,
Apr 21, 2024, 12:28:59 AMApr 21
to MathJax Users
For more context, this is what I'm referring to:
20240421-122717.png

Murray

unread,
Apr 21, 2024, 3:48:59 AMApr 21
to MathJax Users
It looks to me that one of the following is happening. Either

(a) Inline math is not configured properly so that your $ signs work as you wish. It should be like this

MathJax = { tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] }... };(where you might have other things where I have "...")

OR

(b) You have conflicting CSS on your page which is setting the inline math to actually display as "block", thus getting the effect you're seeing.

It's not possible to tell without a minimal example page showing the problem.

If your configuration seems OK, you could try stripping out ALL the CSS on the page (and the math should work properly), then add in the CSS rules until it breaks.

If you have no joy, post your minimal example and we'll take a look.

Regards
Murray

Peace Keeper

unread,
Apr 21, 2024, 8:12:45 AMApr 21
to MathJax Users
20240421-201210.png
I looked through the HTML and I found that somehow something added the line display: block to all the MathJax outputs. Unselecting the display: block in my browser makes everything normal. What option should I added to turn this off by default?

Davide Cervone

unread,
Apr 21, 2024, 8:18:41 AMApr 21
to mathja...@googlegroups.com
Murray is right, it looks like your configuration is set to make single dollars produce display-style math.  You need to check your configuration to make sure that the displayMath array doesn't include single dollar signs.

If you post your MathJax configuration, we can probably tell you what is wrong.  But you should not try to adjust MathJax's CSS on your own.

Davide


-- 
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/99fddf6f-a21c-489a-ac47-5a3c42b8ec30n%40googlegroups.com.
<20240421-201210.png>

Peace Keeper

unread,
Apr 21, 2024, 8:18:49 AMApr 21
to MathJax Users
Digging around for a bit made me realise that the path to the script was gotten from here: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

Are there any alternative scripts I could use?

Davide Cervone

unread,
Apr 21, 2024, 8:21:29 AMApr 21
to mathja...@googlegroups.com
This is not about the script, it is about your configuration.  Can you post your configuration (the MathJax = { ... } script that is in your page)? Or post a link to a page where we can see what is happening?  We can't give you the proper advice.  You are asking for things that are not the correct solution.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.

Peace Keeper

unread,
Apr 21, 2024, 8:41:47 AMApr 21
to MathJax Users
Alright, I'll start from the beginning. I'm currently using org-mode (on Emacs) to write my notes and I use org-publish to export them to HTML. Here's the configuration in Emacs Lisp.

<script>
  window.MathJax = {
    tex: {
      ams: {
        multlineWidth: '%MULTLINEWIDTH'
      },
      tags: '%TAGS',
      tagSide: '%TAGSIDE',
      tagIndent: '%TAGINDENT'
    },
    chtml: {
      scale: %SCALE,
      displayAlign: '%ALIGN',
      displayIndent: '%INDENT'
    },
    svg: {
      scale: %SCALE,
      displayAlign: '%ALIGN',
      displayIndent: '%INDENT'
    },
    output: {
      font: '%FONT',
      displayOverflow: '%OVERFLOW'
    }
  };
</script>

<script
  id=\"MathJax-script\"
  async
  src=\"%PATH\">
</script>

and

((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js")
 (scale 1.0)
 (align "center")
 (font "mathjax-modern")
 (overflow "overflow")
 (tags "ams")
 (indent "0em")
 (multlinewidth "85%")
 (tagindent ".8em")
 (tagside "right"))

Davide Cervone

unread,
Apr 21, 2024, 8:50:21 AMApr 21
to mathja...@googlegroups.com
OK, thanks, the context helps.  Here are some more questions:

What version of org-mode are you using?  The current version seems to be 9.6.

Can you provide a sample page that is the output from your nodes?

Davide



Peace Keeper

unread,
Apr 21, 2024, 8:54:46 AMApr 21
to MathJax Users
Ah, a fellow org-mode user. I've attached the file below.
projectile_motion.html

Peace Keeper

unread,
Apr 21, 2024, 8:57:37 AMApr 21
to MathJax Users
And yes, I'm using org-mode 9.6

Davide Cervone

unread,
Apr 21, 2024, 9:04:43 AMApr 21
to mathja...@googlegroups.com
Ah, a fellow org-mode user. I've attached the file below.

Actually, no, but I did look up some documentation on MathJax in org-mode and checked the current version number.

In any case the file you sent gives the explanation.  You are using \[...\] around your math, which are delimiters for display-style math, not in-line math.  That is why the math is on a separate line, because that is what display mode is.  You want to use \(...\) around the in-line math (or $...$, but see the restrictions in the second bullet point in the documentation).

Give that a try and see if that doesn't fix the problem.

Davide



Peace Keeper

unread,
Apr 21, 2024, 9:34:33 AMApr 21
to MathJax Users
I see, thank you so much for figuring it out. Really appreciate it!

Davide Cervone

unread,
Apr 21, 2024, 10:02:35 AMApr 21
to mathja...@googlegroups.com
You're welcome.  We were thrown off by your original post where you said you were using "This is a variable $ x $ and another variable $ y $"; since this should have produced in-line math, we went to a configuration problem as the likely problem.  It was only when you gave the file you were looking at that we could determine the problem.  That's why providing an actual example is always best, not just a screen shot of the result.  Also, according to the org-mode documentation, "$ x $" would not work for dollar sign delimiters, as they restrict them to having no space after the initial delimiter and none before the final one, so you would have to do either "\( x \)" or "$x$".  So knowing this was from org-mode originally would have helped get to the real problem quicker as well.

Good luck with your notes.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages