How can make a formula left alignment? Thanks!

1,486 views
Skip to first unread message

Jack

unread,
Dec 28, 2011, 8:48:24 PM12/28/11
to MathJax Users
I have set style="text-align:left", but the formula is still displayed
the center of the page, why?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
"HTML-CSS": { imageFont: null },
jax: ["input/TeX","output/HTML-CSS"],
});
</script>

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/
latest/MathJax.js"></script>

</head>
<body>
<h1>New Sample</h1>
<div style="text-align:left">
\[ \frac{-b\pm\sqrt{b^2-4ac}}{2a} \]
</div>

<p style="text-align: left">
\[ \frac{-b\pm\sqrt{b^2-4ac}}{2a} \]
</p>
</body>
</html>








Jack

unread,
Dec 29, 2011, 1:59:48 AM12/29/11
to MathJax Users
I know to use displayAlign: "left" to make all formulas as left
alignment, but I hope to make different formula as different alignment.

Davide P. Cervone

unread,
Dec 29, 2011, 8:06:16 AM12/29/11
to mathja...@googlegroups.com
If you were using MathML as your input format rather than TeX, you
could specify indentalign and indentshift on the <math> element itself
to control this. In TeX, however, there is no mechanism for
specifying the alignment.

If you want to control this individually, one approach would be to use

<div style="margin: 1em 0; text-align:left">
\(\displaystyle{ ... math ... }\)
</div>

which makes an in-line equation using the displaystyle typesetting
rules, and the surrounding div controls the alignment. That should
work provided you aren't using \tag.

If you really need to have two different types of alignment, you can
typeset the first set of equations, then change displayAlign and
typeset the second set. Of they all appear together in one group, you
can set the element array in your configuration file to include the
names of the containers for the centered equations (see http://www.mathjax.org/docs/1.1/options/hub.html)q
, and then

<script>
MathJax.Hub.Queue(function () {
MathJax.Hub.Configure({displayAlign:"left"});
MathJax.Hub.Typeset(["div1","div2","div3"]);
});
</script>

to typeset the contents of the elements with ids div1, div2, and div3
aligned to the left.

Davide

Jack

unread,
Dec 29, 2011, 7:47:30 PM12/29/11
to MathJax Users
Thank you!

Is the keyword \displaystyle the grammar of MathJax, do you have a
help document about the keyword?



On 12月29日, 下午9时06分, "Davide P. Cervone" <d...@union.edu> wrote:
> If you were using MathML as your input format rather than TeX, you
> could specify indentalign and indentshift on the <math> element itself
> to control this. In TeX, however, there is no mechanism for
> specifying the alignment.
>
> If you want to control this individually, one approach would be to use
>
> <div style="margin: 1em 0; text-align:left">
> \(\displaystyle{ ... math ... }\)
> </div>
>
> which makes an in-line equation using the displaystyle typesetting
> rules, and the surrounding div controls the alignment. That should
> work provided you aren't using \tag.
>
> If you really need to have two different types of alignment, you can
> typeset the first set of equations, then change displayAlign and
> typeset the second set. Of they all appear together in one group, you
> can set the element array in your configuration file to include the
> names of the containers for the centered equations (seehttp://www.mathjax.org/docs/1.1/options/hub.html)q

leathrum

unread,
Dec 29, 2011, 8:17:11 PM12/29/11
to MathJax Users
\displaystyle is standard TeX/LaTeX -- it makes an inline expression
$...$ render as though it was in display mode $$...$$. So some
symbols (like \int) will be bigger, some things will be positioned
differently (like the limits on \sum), etc. Probably the biggest
difference is that it does not automatically use smaller characters in
the numerator and denominator of a \frac. The MathJax documentation
doesn't provide additional documentation for standard TeX macros, it
just lists the macros compatible with MathJax.
Reply all
Reply to author
Forward
0 new messages