AMS-LaTeX support

194 views
Skip to first unread message

Casey W. Stark

unread,
Oct 28, 2010, 9:40:56 PM10/28/10
to MathJax Users
[Previously posted at https://sourceforge.net/projects/mathjax/forums/forum/948700/topic/3572967]

Stuart Anderson
2010-03-02 02:50:48 PST

Hi there,

Thanks as ever for all the work you are doing on this. I've been
doing quite a bit of testing of MathJax and also for comparison
ASCIIMathML/LatexMathML and jsMath. MathJax seems to perform very
well indeed. As part of my evaluation, I put together a set of pages
to test support for AMS-LaTeX. Within the large higher education
institute that I work for (University of Manchester, UK), it has been
suggested that amsmath support will remove quite a few niggles from
the hard to please audience that I support. My rather thrown together
set of tests can be viewed here:

http://aiss-007-066.csist.manchester.ac.uk/~stuart/web-maths/further-testing/notation-general-ams.html
(link may change in distant future)

All tests are based on the ams user's guide at
ftp://ftp.ams.org/pub/tex/doc/amsmath/amsldoc.pdf

Can you comment on the future of MathJax and amsmath support? How far
do you intend to go in supporting it?

Thanks,

Stuart.

----------

dpvc
2010-03-02 08:09:58 PST

I think you will find that if you include "TeX/AMSmath.js" in your
extensions array in the MathJax.Hub.Config call on your pages, it will
clear up many of the problems you are seeing. The AMS extensions are
not part of the core MathJax TeX interpreter, and this extension
defines most of the macros that are part of the AMS-LaTeX package. A
number of the macros and environments are set up to autoload
AMSmath.js, but not all of them are, so you may want to include this
file on pages where AMS macros might be used. A few of the macros you
include in your test suite are not included, but it is possible to
define them yourself in a local customization file. I can help you
with that if you are interested in going that way. For example, the
\nonumber tag could be defined as an empty macro that does nothing.
That could be done by including


TEX.Macro("nonumber","");


in your MathJax/config/local/local.js file and adding


config: ["local/local.js"],


to your MathJax.Hub.Config call. Other aditional macros could be
defined there as well.

It would also be possible to set up the rest of the AMS macros and
environments to autoload the AMSmath package using the local.js file
(so you would not need to include AMSmath.js in the extensions
explicitly). If you want to go that route, let me know, and I'll give
you instructions.

Finally, you might want to include AMSsymbols.js in your extensions
array. This defines the AMS symbols like \square, etc. that are not
part of the base MathJax definitions.

In terms of the table of test results, for row 1, the \nonumber
definition I give above should handle that for you (your note 10).
For row 3, you could define the equivalent of \def\label#1{} using a
similar definition in local.js (your note 9). For row 4, you are
right, MathJax does not support \emph, as it does not handle any of
the text-mode macros; as you point out in note 6, using HTML instead
will be a work-around for that. For row 5, loading AMSmath.js will
take care of the \tfrac issue from your note 8. For row 7, it's true
that MathJax does not support the \xymatrix macro and is unlikely to
any time soon. Finally, for row 8, the \mathscr macro does not fall
back on \mathcal, as you claim in note 12, but rather uses the eusm10
font, which is similar, but not identical to \mathcal. Try


\displaylines{
\mathscr{H}\text{ and }\cal H\cr
\mathscr{L}\text{ and }\cal L
}


to see the difference. This is what \mathscr would produce with the
euscript package with the mathscr option in LaTeX. MathJax does not
have access to the rsfs font that you display in your example (which
is what \mathscr produces with the mathrsfs package in LaTeX). Other
fonts, like rsfs, might be made available in MathJax in the future.

Finally, you may want to update your copy of MathJax to the latest SVN
version, if you haven't already. Some of the AMS math macros have
been added since the original beta1 ZIP file, so to take full
advantage of them, you need a more recent version.

Davide

PS. I noticed that the test results for jsMath could also be improved
by adjusting the configuration file. For example, you should set
processLaTeXenvironments to 1 and adding "AMSmath.js" to the loadFiles
array in your jsMath/easy/load.js would clean up a number of the
problems that you are experiencing. You should get comparable results
for the two, though MathJax implements a bit more of the AMS macros
(and a bit better, too).

----------

Stuart Anderson
2010-03-03 06:16:45 PST

Thanks you have been an enormous help to me. I should have worked out
the extensions part myself really! Still getting to grips with lots
of new things I've discovered thanks to you. If it's not too much
trouble, could you explain the syntax for defining the equivalent of
"\def\label#1{}" so that \label elements are handled. I had a go, but
I must be getting something wrong.

Finally. just out of interest, are you planning on adding the
equivalent of the jsMath "eqn-number.js" extension?

Many thanks,

Stuart

----------

dpvc
2010-03-03 14:52:02 PST

For the \label macro, use

TEX.Macro("nolabel","",1);

(the final 1 says how many parameters are expected) in your local.js
file.

For the equivalent of the eqn-number extension, yes, that is planned,
but may not be in the 1.0 release. The infrastructure is there, but I
haven't implemented the top-level commands yet. You can use \tag to
get specific equations labeled, however. E.g.

$$E=mc^2\tag{2.1}$$

should get you a displayed equation with a label of "(2.1)" at the
right. You can control the side using MathJax.Hub.Config values (see
the MathJax/config/MathJax.js file for a list of all the paramaters
you can set, and comments that explain them).

I have looked at your examples again, now that you have included
AMSmath.js, and want to point out that some of the missing features
have been implemented, but you will need to get the most recent SVN
copy. For example, the "alignat" environment was added some time ago,
while the missing \injlim and \projlim were an oversight that I have
just rectified.

The flaign* environment is not available, and neither are the
\framebox and \intertext macros. You could get a work around for
\framebox in the example you have given by adding

TEX.Macro("framebox","\\def\\framebox[.#1\\columnwidth]#2{\\boxed{\
\rlap{\\ \\ #2}{\\kern #1ex}}}\\framebox");

to your local.js file. (The reason the definition includes \def is
that the definition includes a template, rather than just numbered
arguments, and that is implemented in an extension, so this will cause
that extension to be autoloaded when needed. Otherwise, you would
need to load the newcommand extension, and synchronize the definition
with the loading of that file, which is a bit more complicated.)

I also noticed that some of your examples use "smart quote" single
quotes rather than actual single quotes (ASCII 0x27) where you want
primes. MathJax will not recognize the smart quote as the prime
character, but simply inserts it as a plain character, so it will not
look quite right. You might want to change those.

On your second page of examples, \hdotsfor is not defined,
\negmedspace, \negthickspace, dotso have been added, as have \leftroot
and \uproot (not used on your test page). The \boxed macro was added
a few weeks back. The \sphat and \sptilde macros are rare, but can be
obtained by adding

TEX.Macro("sphat","^{\\mathchoice{}{}" +
"{\\raise.3ex\\widehat{\\kern 3.5pt}}" +
"{\\!\\lower.3ex\\hbox{^}}"+
"}\\mathchoice{\\!\\!}{\\!\\!}{}{}");
TEX.Macro("sptilde","^{\\mathchoice{}{}" +
"{\\raise.3ex\\widetilde{\\kern 4pt}}" +
"{\\!\\hbox{^}}"+
"}\\mathchoice{\\!\\!}{\\!\\!}{}{}");

to your local.js file.

For your third page of examples, the \injlim and \projlim macros have
been added, and the \varinjlim and \varprojlim examples were updated
some time ago to avoid the errors you are seeing. The errors you are
getting from \operatorname are, I think, due to incorrect usage. They
do not produce macros, but simply typeset the name as an operator, so
\operatorname{abc} produces the equivalent of \mathop{\rm abc}. You
seem to be using it as \DeclateMathOperator, which would define a new
macro for the operator. Similarly for \operatorname*.

Finally, the CD environment is not implemented. It is possible that
it will me, but not for a while.

Hope that helps.

Davide

----------

Stuart Anderson
2010-03-05 08:56:49 PST

Many thanks yet again for your help! Things are looking very good now
with the vast majority working. The framebox Macro didn't quite work,
but everything else you suggested to try did. I also created a
rendering speed test. See Second Debye Media for FDTD. I was amazed
how much quicker jsMath was which is promising for MathJax since it
gives me an impression of how MathJax will be when you get on to
addressing this issue.

At some point I shall revisit the cross-domain font loading issue and
also the detrimental effect of the Blackboard VLE on the scripts. I'm
confident both can be resolved and will post up the results here to
share with others.

Thanks again,

Stuart.

----------

robertminer
2010-03-05 09:09:36 PST

Stuart,

I presume it would be okay if we point to your test page from
mathjax.org? I'm thinking a number of people would be interested.

Also, I am very interested in taking advantage of all the work you
have been doing to get MathJax running in Blackboard, and I'm sure
many others will be too. I realize you aren't quite there yet, but
when we are, I'd love to put up a "How to use MathJax with Blackboard"
article on mathjax.org, either pointing to a page of yours, or based
on yours. I guess my point here is that if you don't want to take on
maintaining such a page over the long term, feel free to hand off the
bits you don't want to do to us. We now have a new webmaster, Casey
Stark, who will be helping out with preparing just this kind of
thing,

--Robert

----------

dpvc
2010-03-05 11:45:58 PST

The \framebox macro actually does appear to be working, it is the
split environment that is getting things wrong. That is probably due
to it's being in a cell of a larger table. The split environment is
quite delicate, and is intended for use in the main body of the text,
not in a small area like a table cell. I suspect the centering of the
cell is interfering with the alignment within the split environment.
If you try it outside a table, I think you'll fine it works. I'll see
if I can get it to work better in such cases, but it is not a high
priority.

Two other things I noticed: you have a typo in your configuration and
are loading "TEX/AMSymbols.js" rather than "TeX/AMSsymbols.js" (note
capitalization of "TeX"). That file doesn't exist, so MathJax is left
waiting for it and it never arrives, so (in some browsers) there is a
substantial delay while MathJax times out before going on. You should
fix that typo for best performance. Second: you still have "smart
quotes" in the example page for substack.

In terms of performance, the test page is not really an accurate test
of the speed of MathJax versus jsMath, because it includes the same
equation over and over. JsMath keeps an equation cache so that if the
same equation occurs more than once, it already knows how to typeset
it (this has turned out not to be much of a help, but it was a big win
in this case). Having so many large but identical equations is not
really very realistic, and gave jsMath a real advantage that it will
not have in practice. It will be more difficult to do caching for
MathJax (due to the different internal structure), so I'm not sure if
MathJax will meet that speed for this example, even in the long run.
We'll see.

Davide

----------

Stuart Anderson
2010-03-05 14:36:06 PST

Thanks as ever for your feedback.

Not sure what the problem is, but the \frame still appears incorrect
out side the HTML table or even on a completely different page. Happy
to log anything as a bug if you feel it is appropriate.

I can't believe I goofed over the typo in the path to AMSsymbols.js -
thanks for point that out.

I take your point over a performance test. A better test would be to
make the examples radically different. If I get time, I'll construct
one for my own needs. As it happens, the equations included in that
example are very slightly different in each case, but not drastically
so. They are from a longer paper written by a colleague so it's a
real world example. It seemed a convenient source at the time.

Thanks,

Stuart.

----------

Stuart Anderson
2010-03-05 15:23:00 PST

Hi Robert,

I'm happy for any links to be made to it, but I would say it might be
risky to do so on the basis that it is hosted on cheap development box
sat in the corner of the office which may potentially be taken off
line at any point. Also, I've been tending to refactor the layout of
my HTML pages fairly regularly which would of course break any cross
links. Maybe it would be safer to say that you are welcome to any
physical files from my site to host/change/edit yourselves. I can zip
up the lot at any point and send it across.

One thing I am conscious of is my background. I am not a
mathematician, nor a javascript programmer, nor an expect in LaTeX (as
is probably obvious to Davide). I've done a fair bit of Java and PHP
programming in the past and have a conversion Masters degree in
Computer Science. I work for the University of Manchester as an e-
learning technologist. If you think the materials will be of use to
others then that's great, but I'm aware I have not exactly taken the
most scientific approach to my evaluation, but I have attempted to be
fairly methodical. I don't wish to get shot down too much by the wider
on-line community! I decided to spend some time looking at the issue
of display of non-trivial mathematical notation on the web after a
colleague from the School of Mathematics was fed up at other poor
solutions suggested to him. I've found it all very interesting and
have been glad to work on it.

I haven't actually spent that much time of getting MathJax to work
with Blackboard, but from what has been done, the solution seems easy
(though a bit of a hack). If I get time next week I'll do some more
testing just in Blackboard and confirm the solution we found works
universally throughout Blackboard and then share the knowledge.

I also hope to talk to a few colleagues next week about taking my work
forwards in the Uni. But I'll want to review my options based on your
comments here. If I get to a position where we offer a centrally
hosted MathJax service to Uni staff then I imagine I would
incorporate my testing into it for demo purposes and provide a set of
clear and well presented pages to describe how to use MathJax both in
general web pages and from within the Blackboard version we use.

On a different note, I noticed this evening that the moodle community
are a little stand-backish over MathJax, but maybe this is because
their efforts are focused on the upcoming moodle 2.0 release.

--Stuart.

----------

dpvc
2010-03-05 15:59:21 PST

Stuart:

I have checked your page that uses \framebox, and it works for me if I
use my copy of MathJax, but not if I use yours. It looks like you
have a pretty up-to-date copy, but there were some significant changes
over the last day or so, and some things were broken for a while, so
I'd recommend getting the latest copy (again) and try that to see if
it works. It does for me, so I hope it will for you, too. BTW, you
might want to change the .5\columnwidth to .50\columnwidth to make
that box appear larger (I forgot to mention that before; the method I
use is a real hack, but it does the job for this specific case. If
course, you would not want to use that definition in a production
system).

I didn't look too closely at the specific equations, but I did notice
some differences. In addition to the global equation cache, jsMath
uses a subexpression cache as well, so if there are significant pieces
that are the same, it could be that that is the reason for the extra
speed (the measuring of the various components is the main bottleneck
for jsMath, and so not having to remeasure the same subexpression over
and over would be a big win -- one that MathJax doesn't yet have).

Anyway, thanks for your efforts in checking MathJax out. Best of luck
with the project.

Davide

----------

Stuart Anderson
2010-03-08 02:29:10 PST

Hi Davide,

That seems much better, thanks! I did note however that the rendering
in MathJax was not identical to that in the "User’s Guide for the
amsmath Package". However, the MathJax rendering was almost identical
to my own rendering using MikTeX. Not sure what to make of that! The
only notable difference was that the content of the boxes - the
letters A, B, C and D - were not centrally aligned inside the boxes.
MathJaX has left alignment whist MikTeX and the AMS guide has it
centred. Very low priority I think, but thought I should pass it one
none-the-less.

Thanks as ever,

Stuart.

----------

dpvc
2010-03-08 03:22:04 PST

I noticed two differences myself. One is the non centered letters,
which you point out. This is due to the fact that MathJax doesn't do
the stretchable glue necessary to manage the centering. It could have
been done by implementing the framebox macro in JavaScript (and that
would have been able to take care of the width argument better as
well), but since \framebox is really just for making the
documentation, I didn't think it was worth the effort.

The second difference is the placement of box B, which is farther to
the left in the example. That is probably a combination of two
things: the smaller horizontal width and the treatment of the
margins. The split macro reserves some space (on the right, by
default, as I recall) for possible equation numbers, and since that is
a fixed amount, it is a larger proportion of the column when the
column is small, as in the documentation file. That means centering B
means centering in the column minus the equation width, though the
sizes of the boxes are computed against the complete column width. In
MathJax, the label space is removed from BOTH sides, so that changes
the centering. Also, the macro as given uses FIXED size boxes, not
ones proportional to the width, and so you would have to have the
window size just right to duplicate the exact spacing of the boxes.
Since your page layout uses a fixes size inner panel that doesn't
change with the width of the page, you can't actually see it, but on a
simpler page, changing the window size would cause the boxes to
recenter, and you could probably achieve the desired configuration.

Davide

----------

Stuart Anderson
2010-03-09 02:39:06 PST

Thanks Davide, I decided it makes sense to tweak my CSS to set a fixed
max-width rather than just a fixed width. This way it means that
netbook users viewing my pages on really low resolutions don't have to
contend with horizontal scroll bars. It also means I can resize the
window and see the box centring effect better that you describe above.

--Stuart
Reply all
Reply to author
Forward
0 new messages