Set display style as the default style

1,630 views
Skip to first unread message

Huu Dien Khue LE

unread,
Jan 5, 2012, 1:13:16 PM1/5/12
to MathJax Users
Hello,

I would like to know if we can set the display style (\displaystyle)
as the default style for all MathJax formulas ?

Knowing we can do that in $\LaTeX$ by putting
\everymath{\displaystyle} command before \begin{document}.

Thank you for your help.

Huu Dien Khue LE

unread,
Jan 6, 2012, 1:54:59 PM1/6/12
to MathJax Users
Any ideas please?

Davide P. Cervone

unread,
Jan 6, 2012, 2:44:48 PM1/6/12
to mathja...@googlegroups.com
As I reminded another questioner earlier today, patience is a virtue.
You asked your original question only yesterday (a mere 25 hours ago),
and one day is too short a time to re-issue your request. We answer
questions as quickly as we can, and we haven't forgotten that you have
asked one. Asking again so soon simply takes more of our time, which
takes away from our ability to answer your question; it doesn't
encourage us to respond to you any faster. Indeed, I was just working
on some example code for you, and was just getting ready to reply, but
I am now going to wait until tomorrow, so your repeated request has
actually delayed your response.

Davide

Huu Dien Khue LE

unread,
Jan 7, 2012, 5:47:18 PM1/7/12
to MathJax Users
Oh, I am really sorry. I had not been very familiar with the use of
google groups and when I saw my discussion at the bottom of the page,
I just wanted to take it up.
Please excuse if I have bothered you.

Huu D. K. Le

Davide P. Cervone

unread,
Jan 7, 2012, 7:37:00 PM1/7/12
to mathja...@googlegroups.com
Thanks for your comments. Apology accepted.

When a topic gets a reply (like my answer), it gets moved to the top,
and since I try to answer approximately in the order they arrived, you
will see earlier topics move above yours as they are answered. But I
get all the messages in email, so I don't lose track of them even if
they aren't on the top of the Google listing.

As for your question, there currently is no official way to get the
\everymath effect. I have written an extension that provides it and
submitted it to the contributed extensions library being maintained by
Tom Leathrum. When he gets back from the Joint Mathematics Meetings
next week, he will add that to the library, and I'm sure will post how
to access it.

What you really want is not quite \everymath anyway, since
\everymath{\displaystyle} may not do what you expect. For example, it
will not properly handle $$ x \over y $$ since only the numerator will
be in display style. What you really want is to put \display{...}
around the math, and \everymath can't do that.

So I might suggest the following code instead. Add the following to
your page

<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var PREFILTER = TEX.prefilterMath;
TEX.Augment({
prefilterMath: function (math,displaymode,script) {
math = "\\displaystyle{"+math+"}";
return PREFILTER.call(TEX,math,displaymode,script);
}
});
});
</script>

before the <script> that loads MathJax.js and that should make all
your mathematics show up in display style.

Davide

Huu Dien Khue LE

unread,
Jan 9, 2012, 3:01:25 PM1/9/12
to MathJax Users
Hello Davide,

Thank you so much for your help. It works very well on my site.

Have a nice day !

leathrum

unread,
Jan 12, 2012, 11:45:18 AM1/12/12
to MathJax Users
The \everymath extension is now available on the contributed
extensions repository:

http://cs.jsu.edu/mathjax-ext/

Once you configure the extension in your page following the
instructions given at the above link, you should just be able to use \
(\everymath{\displaystyle}\) near the beginning of your document to
get all inline math to show up in display mode, as Davide described
earlier.

dbanet

unread,
Feb 16, 2016, 7:59:58 PM2/16/16
to MathJax Users
Davide Cervon:
I was just working  
on some example code for you, and was just getting ready to reply, but  
I am now going to wait until tomorrow, so your repeated request has  
actually delayed your response.

Davide


You, sir, are a complete douchebag.

Prof. Caju

unread,
May 16, 2024, 3:52:55 AMMay 16
to MathJax Users
Hello, Deivide.

Could this code be upgraded to v4?

I rely on it a lot in my v2 installation, and I would love to be able to use it with v4.

Kind regards,
Prof. Caju

Prof. Caju

unread,
May 16, 2024, 6:41:39 PMMay 16
to MathJax Users
Just found the solution to use DisplayStyle in all equations with MathJax v4:


:D

Davide Cervone

unread,
May 17, 2024, 2:29:07 PMMay 17
to mathja...@googlegroups.com
Note that the braces in the \displaystyle{...} will prevent any in-line line breaks, in case that is of concern to you.  Since \displaystyle is a switch, not a macro that takes an argument, they are really only there to make things work if you have an expression like `x \over y`.  Without the braces, only the numerator would be in display mode.  But if you aren't using \over (or \atop or any of the similar plain-TeX macros), then you should be OK with leaving off the braces.

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/40e31d64-a1ab-4cad-a47d-f41cc27611c1n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages