Combining asciimathml and mathjax

442 views
Skip to first unread message

David

unread,
Jun 17, 2012, 1:59:21 AM6/17/12
to mathja...@googlegroups.com
Still reading, still learning, but it seems you either configure for asciimathml or mathjax, i.e., one or the other. However, the sample page


does take asciimathml input and output it as mathjax. However, the coding of this page is very difficult to understand when you are just starting out. Could someone design a very basic page that contains a paragraph of mathjax, then a input text box where the user is expected to enter math in asciimathml form (I think there is an amath for that) and then the output shows up as mathjax. Real basic, minimum number of lines, so that a rookie like me can absorb it.

I would much appreciate an example like this.

Thanks.

David.

Murray

unread,
Jun 17, 2012, 4:31:17 AM6/17/12
to mathja...@googlegroups.com
Hi David

You actually either configure for LaTeX input, or ASCIIMathML input using the ?config parameter when calling MathJax. For ASCIIMathML input, you use ?config=AM_HTMLorMML.

Either way, you want MathJax output so it shows OK in (most) browsers.

Here is a bare-bones ASCIIMathML input example. The "amath" delimiter is not native, but I have added it in the configuration script. Hope it helps:


Regards
Murray

Davide P. Cervone

unread,
Jun 17, 2012, 9:23:59 AM6/17/12
to mathja...@googlegroups.com
You could try

http://cdn.mathjax.org/mathjax/latest/test/sample-dynamic.html

and change

config=TeX-AMS-MML_HTMLorMML

to

config=AM_HTMLorMML

and

$${}$$

to

` `

to convert it from taking TeX input to taking AsciiMath input.

Davide

dwarn...@suddenlink.net

unread,
Jun 17, 2012, 11:51:18 AM6/17/12
to mathja...@googlegroups.com
Davide and Murray,

Thanks for your replies. Let me try to be more specific. Let's start with this code.

<!DOCTYPE html>
<html>
<head>
<title>MathJax TeX Test Page</title>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
</script>
</head>
<body>
1. Given
\begin{equation*}
f(x)=\frac{x+1}{x-1}\quad\text{and}\quad g(x)=\frac{x-1}{x+1},
\end{equation*}
simplify $f(x)-g(x)$ as much as possible.
</body>
</html>

Now, after the question, I want an input text box. In the box, the student will type the answer, as in:

4x/((x-1)(x+1))

They won't use backticks, they won't use amath. That will all be set up by the code in the background. They will just enter 4x/((x-1)(x+1)) in the input text box. Now, as they type, I want the mathjax result to appear to the right of the text box.

This is my goal. Any help would be greatly appreciated.

Thanks.

David

Peter Krautzberger

unread,
Jun 17, 2012, 1:10:19 PM6/17/12
to mathja...@googlegroups.com
Hi,

Davide has already pointed you to the examples that come with MathJax -- you just need to look a bit further to find


Combined with Davide's comments, this should get you started, I think.
Peter.

dwarn...@suddenlink.net

unread,
Jun 17, 2012, 3:01:21 PM6/17/12
to mathja...@googlegroups.com
Peter,

Nope, this is not the answer I am looking for. Note that the file will be a MathJax file.

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
</script>

But I want the input box to use asciimathml. I want the student to type

4x/((x+1)(x-1))

in the input textbox, no backticks, and I want the output to look like the standard result in a latex document when you enter:

$$\frac{4x}{(x+1)(x-1)}$$.

David

Marc Grober

unread,
Jun 17, 2012, 5:20:03 PM6/17/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This discussion, however, does highlight the possible confusion of
configuring mathjax to handle both asciimathml and tex using different
tokens for each input jax (seems to me that Murray's comment while
accurate, possible adds a bit to the confusion in allowing the
inference that both can't be handled.) As the docs note, the
asciimathml included in the input jax is only "bare" asciimath (sans
the latex and asciisvg subsequently added by Peter, David and others),
so sites like intmath can be seen as confusing (though this point is
clearly noted in the discussion.)

The docs indicate that TeX, MathML, and AsciiMath preprocessors loads
the TeX, MathML, and AsciiMath preprocessors, which load the default
tokens. One could also of course load preprocessors or processors
manually to obtain more granular control. I would like to suggest an
addition to the docs that explores the consideration of such options
and an example of configuration considerations.... especially where
one wants to use TeX, MathML, and AsciiMath preprocessors with CDN
invocation but change the tokens.
> http://www.intmath.com/help/__asciimathml-input-mathjax-__output.php
>
>
>
<http://www.intmath.com/help/asciimathml-input-mathjax-output.php>
>
> does take asciimathml input and output it as mathjax. However, the
> coding of this page is very difficult to understand when you are
> just starting out. Could someone design a very basic page that
> contains a paragraph of mathjax, then a input text box where the
> user is expected to enter math in asciimathml form (I think there
> is an amath for that) and then the output shows up as mathjax.
> Real basic, minimum number of lines, so that a rookie like me can
> absorb it.
>
> I would much appreciate an example like this.
>
> Thanks.
>
> David.
>
>
> On Saturday, June 16, 2012 10:59:21 PM UTC-7, David wrote:
>
> Still reading, still learning, but it seems you either configure
> for asciimathml or mathjax, i.e., one or the other. However, the
> sample page
>
> http://www.intmath.com/help/__asciimathml-input-mathjax-__output.php
>
>
>
<http://www.intmath.com/help/asciimathml-input-mathjax-output.php>
>
> does take asciimathml input and output it as mathjax. However, the
> coding of this page is very difficult to understand when you are
> just starting out. Could someone design a very basic page that
> contains a paragraph of mathjax, then a input text box where the
> user is expected to enter math in asciimathml form (I think there
> is an amath for that) and then the output shows up as mathjax.
> Real basic, minimum number of lines, so that a rookie like me can
> absorb it.
>
> I would much appreciate an example like this.
>
> Thanks.
>
> David.
>
>
> On Saturday, June 16, 2012 10:59:21 PM UTC-7, David wrote:
>
> Still reading, still learning, but it seems you either configure
> for asciimathml or mathjax, i.e., one or the other. However, the
> sample page
>
> http://www.intmath.com/help/__asciimathml-input-mathjax-__output.php
>
>
>
<http://www.intmath.com/help/asciimathml-input-mathjax-output.php>
>
> does take asciimathml input and output it as mathjax. However, the
> coding of this page is very difficult to understand when you are
> just starting out. Could someone design a very basic page that
> contains a paragraph of mathjax, then a input text box where the
> user is expected to enter math in asciimathml form (I think there
> is an amath for that) and then the output shows up as mathjax.
> Real basic, minimum number of lines, so that a rookie like me can
> absorb it.
>
> I would much appreciate an example like this.
>
> Thanks.
>
> David.
>
>
> On Saturday, June 16, 2012 10:59:21 PM UTC-7, David wrote:
>
> Still reading, still learning, but it seems you either configure
> for asciimathml or mathjax, i.e., one or the other. However, the
> sample page
>
> http://www.intmath.com/help/__asciimathml-input-mathjax-__output.php
>
>
>
<http://www.intmath.com/help/asciimathml-input-mathjax-output.php>
>
> does take asciimathml input and output it as mathjax. However, the
> coding of this page is very difficult to understand when you are
> just starting out. Could someone design a very basic page that
> contains a paragraph of mathjax, then a input text box where the
> user is expected to enter math in asciimathml form (I think there
> is an amath for that) and then the output shows up as mathjax.
> Real basic, minimum number of lines, so that a rookie like me can
> absorb it.
>
> I would much appreciate an example like this.
>
> Thanks.
>
> David.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP3koCAAoJEMCi9wxDaNqEyJUH/RfPEdWSgktbPmnrwMTvT3KK
fDNiNETpmyF+jivhyHt9PDEOLzrjACkQuxRSF+3LE2D86APyfMfZH2MQ3PFkaQlv
Aow/xkxP8JxKQ6UlH7q7dRp6R8oq9pTPpSWQrzFAuWLPNByLewZmcFBOlOWkMS8R
VWOW9y1EthXP1bB/zzUqFDd/Rx78A/YBtQMiLMQJE98e+SXsnnPeGwsklYhZ+SNa
DOvTPpsCR0iGqy8HPLQXo4xVk4o0O6Ic5t5BFDJ0Yo7kodzAC6iiWyQ8y3M9Ha+5
KvHGWI7Pa4OjtteRcYg+U+a+De6lMAPTak+0iL3SDDXT3oawH3aujmE+JlCdulA=
=Ieom
-----END PGP SIGNATURE-----

Peter Krautzberger

unread,
Jun 17, 2012, 6:35:40 PM6/17/12
to mathja...@googlegroups.com
Thanks for your suggestion, Marc! Your message made me look at the initial post again and now I'm totally confused ;)

@David Arnold: could you clarify what you are actually looking for?

The way I understood you, you were asking for an example page that creates a live-preview for asciimath input (much like the intmath page): your students enter only asciimath code (no delimiters) in a text box and the preview-pane renders the equation.

Is that it or are you looking (as Marc suggests) at mixing TeX and asciimath input (in a live-preview or elsewhere)?

If I did understand you correctly, then you should have combined the examples Davide and I mentioned (and re-configured MathJax input options as Davide described, cf. also http://www.mathjax.org/docs/2.0/configuration.html). 

Anyway, maybe this helps: http://jsfiddle.net/6bLEr/2/ 

Peter.

dwarn...@suddenlink.net

unread,
Jun 17, 2012, 7:36:28 PM6/17/12
to mathja...@googlegroups.com
All,

I'd like to thank folks for their contributions on this discussion. Here is a sample quiz from our Optimath system at the College of the Redwoods.


When we survey our students at the end of they year, the biggest complaint that we get about the system is the lack of understanding of inline mathematical symbolism. They get frustrated when they work the problem correctly, but enter the answer incorrectly.

I always start my first class by asking the students to enter 

5 + 5
____
5 + 5

on their calculator. They know the answer is 1 (I ask them for the answer before they enter it in their calculators), but almost 50% of them get 11 when they enter the expression in their calculator, because they use the syntax  5+5/5+5 instead of (5+5)/(5+5). I am not exaggerating that 50% figure. Happens every semester.

To help the students with the syntax (but they don't always use it), we rewrote some asciimathml code:


The idea is the students can first enter their answer in this window and it will produce the standard math output, so they can check their answer before putting it into the text input box on their Optimath quiz. Yes, it would be a better system if the students could start typing their answer into the text input box in the pdf file and the output corresponding to what they are entering would appear in the pdf document right next to the input text box. We cannot figure out how to do this.

But it might be possible in the future with html5, javascript, etc.,  that's why I am exploring. First attempt:


So, yes, I need to use both mathjax and asciimathml in the same document. The asciimathml portion will only be used in the input text box when the student is entering their answer and the idea is that the corresponding mathjax output will appear next to the input text box as they enter their answer. 

Students struggle mightily already with something like 4x/((x+1)(x-1)), so using latex notation to enter their answer is out of the question. That would only increase their difficulties with syntax.

I hope this makes my thinking clear.

D.

On Saturday, June 16, 2012 10:59:21 PM UTC-7, David wrote:

Marc Grober

unread,
Jun 17, 2012, 8:17:56 PM6/17/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

LOL, I was not arguing that my suggestion would address David's
question, but that his question raised other issues that could be
addressed more comprehensively, as MathJax offers so many options
specific configurations can get confusing (especially where someone
want to use the core config I mentioned, but want to change the tokens),
BUT,
that being said, I do have to suggest to David there may be students
or teachers who already know some TeX and there is nothing lost by
offering to parse both backticks and dollar signs, lol.

To take a step back, what we see in this intmath URL
(http://www.intmath.com/help/send-math-email.php) is a configuration
that is a bit confusing in its discussion. in that some TeX appears to
work (eg, \cdot, \frac, \sqrt, though asciimath is simply ignoring the
leading slash), but constructs like the third root of 4 (\sqrt[3]{4}
in TeX , which must be done root(3)(4) in asciimathml, though curly
and square braces will work) might drive someone to distraction,
lol.....

Allowing both Tex and Asciimathml also means that your setup can be
used for more advanced students who may want to move to Tex as they
get more familiar with math notation. And teachers fluent in TeX need
not learn asciimathml to be able to communicate with students using
asciimathml

The object, I guess I have been harping as much on as anyone, is that
math notation should be transparent and universal like the babblefish
- - makes no diff what I use, you will see what I say in a manner you
can understand ;-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP3nO0AAoJEMCi9wxDaNqEfHYH/inIzERqvDbPXNOq3+seKPVI
4MMgneaiD6K2q3hDa3bgZUPYmaNAfUaXnDHD9ziGrmvZ0M6IY/yYj93klEXp9wwp
DXOGBCUQRGnv/1v+jzAt4lag++TlWrjRig3eW2k7iUQp6J/vlXvSg5V5QDYdixay
5opYYiQ272uHhUMmVje3jM7MiimroLFl2XVJsxQU+XkaXYAjzDoH3GQtwTklaPcp
y19mXuHdtDf9V+BoOHBdkPwTjWuLla9/wsLeYDpnlJhcrJReXQUKsl/bUzA+zifE
OybLBuynKoglCtPEFnBTYEih1CH882dUHTlinz47hMu9Ydzy8oZr3W2yhPofkIk=
=CUgj
-----END PGP SIGNATURE-----

Peter Krautzberger

unread,
Jun 17, 2012, 9:08:18 PM6/17/12
to mathja...@googlegroups.com
@David Arnold I'm still a bit puzzled, so let me ask more. You wrote

So, yes, I need to use both mathjax and asciimathml in the same document. 

I'm not sure what you mean with both. Do you mean you really need both javscript files to be loaded in a single document? (This seems bizarre, but hey) 

Or do you mean you would like to use asciimath's syntax as an input and get the rendering quality from MathJax? 

In that case, MathJax is enough on its own since it understands the asciimath syntax (when configured correctly).

If nothing of the above makes sense, could you tell me what is not working for your in the example I provided earlier?  http://jsfiddle.net/6bLEr/2/

Peter.

dwarn...@suddenlink.net

unread,
Jun 17, 2012, 11:02:28 PM6/17/12
to mathja...@googlegroups.com
Peter,

Your input box and the output on:


is exactly what I want. However, in all other parts of the document, I want to use MathJax, not Asciimathml. So, for example, if I replace your line 

Type text in the box below:<br/>

with:

Type text in the box below: $x^2$<br/>

Then the $x^2$ is not typeset. See the image at:

http://online.redwoods.edu/instruct/darnold/mathjax.jpg

David.

Marc Grober

unread,
Jun 18, 2012, 2:17:04 AM6/18/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

if you change the config at top to use TeX-MML-AM_HTMLorMML then you
can use double dollars and back ticks in the body, and your preview
will still work for asciimath

On 6/17/12 7:02 PM, dwarn...@suddenlink.net wrote:
> Peter,
>
> Your input box and the output on:
>
> http://jsfiddle.net/6bLEr/2/ <http://jsfiddle.net/6bLEr/2/>
>
> is exactly what I want. However, in all other parts of the
> document, I want to use MathJax, not Asciimathml. So, for example,
> if I replace your line
>
> Type text in the box below:<br/>
>
> with:
>
> Type text in the box below: $x^2$<br/>
>
> Then the $x^2$ is not typeset. See the image at:
>
> http://online.redwoods.edu/instruct/darnold/mathjax.jpg
>
> David.
>
> On Sunday, June 17, 2012 6:08:18 PM UTC-7, Peter Krautzberger
> wrote:
>
> @David Arnold I'm still a bit puzzled, so let me ask more. You
> wrote
>
>> So, yes, I need to use both mathjax and asciimathml in the same
> document.
>
> I'm not sure what you mean with both. Do you mean you really need
> both javscript files to be loaded in a single document? (This
> seems bizarre, but hey)
>
> Or do you mean you would like to use asciimath's *syntax* as an
> input and get the rendering quality from MathJax?
>
> In that case, MathJax is enough on its own since it understands
> the asciimath syntax (when configured correctly).
>
> If nothing of the above makes sense, could you tell me what is not
> working for your in the example I provided earlier?
> http://jsfiddle.net/6bLEr/2/ <http://jsfiddle.net/6bLEr/2/>
>
> Peter.
>
>
>
>
> On Sun, Jun 17, 2012 at 8:17 PM, Marc Grober
> <marc....@gmail.com <mailto:marc....@gmail.com>> wrote:
>
> LOL, I was not arguing that my suggestion would address David's
> question, but that his question raised other issues that could be
> addressed more comprehensively, as MathJax offers so many options
> specific configurations can get confusing (especially where
> someone want to use the core config I mentioned, but want to
> change the tokens), BUT, that being said, I do have to suggest to
> David there may be students or teachers who already know some TeX
> and there is nothing lost by offering to parse both backticks and
> dollar signs, lol.
>
> To take a step back, what we see in this intmath URL
> (http://www.intmath.com/help/send-math-email.php
> <http://www.intmath.com/help/send-math-email.php>) is a
> configuration that is a bit confusing in its discussion. in that
> some TeX appears to work (eg, \cdot, \frac, \sqrt, though asciimath
> is simply ignoring the leading slash), but constructs like the
> third root of 4 (\sqrt[3]{4} in TeX , which must be done
> root(3)(4) in asciimathml, though curly and square braces will
> work) might drive someone to distraction, lol.....
>
> Allowing both Tex and Asciimathml also means that your setup can
> be used for more advanced students who may want to move to Tex as
> they get more familiar with math notation. And teachers fluent in
> TeX need not learn asciimathml to be able to communicate with
> students using asciimathml
>
> The object, I guess I have been harping as much on as anyone, is
> that math notation should be transparent and universal like the
> babblefish - makes no diff what I use, you will see what I say in
> a manner you can understand ;-)
>
> On 6/17/12 3:36 PM, dwarn...@suddenlink.net
iQEcBAEBAgAGBQJP3sfgAAoJEMCi9wxDaNqECmsH/i7DWj6SDFv0be81mBbw87Zb
Sp7zg85N9vhgGORZlF6jpW5jtWA0KLikssfu2qvJ9KQGZw/1aOQdXiL+V6fenRlD
w57Uox/y5/4w03NCZR/z81PStWB7oe5/xxq3czVslUGbNSbdctXE3hc+I9MKhK53
o+gmPMrTqBZ6tt9STYRYDflk4gyytqcp8boDZlvcIGnfR/Dztm/ed12dSiZ2v6G4
kYh9xkzODPCGWwAK3e1o8IE5/TR9fJvxtcWu3RyaX/I4TyqFvxHutMZq/u/kHyUb
1otdYEffmg9u2PaOEfzv9DmJ6DnueuGX9hnL24dZR5/GAcr7XzBXY4kBuTv4kvU=
=K7sR
-----END PGP SIGNATURE-----

Marc Grober

unread,
Jun 18, 2012, 2:24:45 AM6/18/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://jsfiddle.net/netbuoy/n9har/3/

On 6/17/12 7:02 PM, dwarn...@suddenlink.net wrote:
> Peter,
>
> Your input box and the output on:
>
> http://jsfiddle.net/6bLEr/2/ <http://jsfiddle.net/6bLEr/2/>
>
> is exactly what I want. However, in all other parts of the
> document, I want to use MathJax, not Asciimathml. So, for example,
> if I replace your line
>
> Type text in the box below:<br/>
>
> with:
>
> Type text in the box below: $x^2$<br/>
>
> Then the $x^2$ is not typeset. See the image at:
>
> http://online.redwoods.edu/instruct/darnold/mathjax.jpg
>
> David.
>
> On Sunday, June 17, 2012 6:08:18 PM UTC-7, Peter Krautzberger
> wrote:
>
> @David Arnold I'm still a bit puzzled, so let me ask more. You
> wrote
>
>> So, yes, I need to use both mathjax and asciimathml in the same
> document.
>
> I'm not sure what you mean with both. Do you mean you really need
> both javscript files to be loaded in a single document? (This
> seems bizarre, but hey)
>
> Or do you mean you would like to use asciimath's *syntax* as an
> input and get the rendering quality from MathJax?
>
> In that case, MathJax is enough on its own since it understands
> the asciimath syntax (when configured correctly).
>
> If nothing of the above makes sense, could you tell me what is not
> working for your in the example I provided earlier?
> http://jsfiddle.net/6bLEr/2/ <http://jsfiddle.net/6bLEr/2/>
>
> Peter.
>
>
>
>
> On Sun, Jun 17, 2012 at 8:17 PM, Marc Grober
> <marc....@gmail.com <mailto:marc....@gmail.com>> wrote:
>
> LOL, I was not arguing that my suggestion would address David's
> question, but that his question raised other issues that could be
> addressed more comprehensively, as MathJax offers so many options
> specific configurations can get confusing (especially where
> someone want to use the core config I mentioned, but want to
> change the tokens), BUT, that being said, I do have to suggest to
> David there may be students or teachers who already know some TeX
> and there is nothing lost by offering to parse both backticks and
> dollar signs, lol.
>
> To take a step back, what we see in this intmath URL
> (http://www.intmath.com/help/send-math-email.php
> <http://www.intmath.com/help/send-math-email.php>) is a
> configuration that is a bit confusing in its discussion. in that
> some TeX appears to work (eg, \cdot, \frac, \sqrt, though asciimath
> is simply ignoring the leading slash), but constructs like the
> third root of 4 (\sqrt[3]{4} in TeX , which must be done
> root(3)(4) in asciimathml, though curly and square braces will
> work) might drive someone to distraction, lol.....
>
> Allowing both Tex and Asciimathml also means that your setup can
> be used for more advanced students who may want to move to Tex as
> they get more familiar with math notation. And teachers fluent in
> TeX need not learn asciimathml to be able to communicate with
> students using asciimathml
>
> The object, I guess I have been harping as much on as anyone, is
> that math notation should be transparent and universal like the
> babblefish - makes no diff what I use, you will see what I say in
> a manner you can understand ;-)
>
> On 6/17/12 3:36 PM, dwarn...@suddenlink.net
iQEcBAEBAgAGBQJP3smtAAoJEMCi9wxDaNqEhxMIAIPsU4u58ELT2GLJvT3FR2aq
FBxNOBTGFKlSf1xm4SXozq17+AozBe4yiQYGa4DbzDx0fyvan6SRt2tB00ar9+0z
xvfjdkA1BvG41LOP0TOT9ox2WbqSxT4af2LrJTxsnyZuKqWyAUQUfPGmgbOLdbEH
Fstjxi2kWDbmlvyGbYSIDLGM05FL7wfnJj7EfQkkqmhF23aHvtl8fcHVtPqyaUfP
lgoH2ickiMjizI/K9YoMES9sMfAPlAvEhlAaK1/yj+B0v2rOjBbLQLTzaHU+fXBE
P+rGeqAm5ToYjD+UeV8tmP8njXPV//w5WIdPoYJNqqJL9uFFhln0Djir6yE71Cg=
=ZYFj
-----END PGP SIGNATURE-----

dwarn...@suddenlink.net

unread,
Jun 18, 2012, 12:37:35 PM6/18/12
to mathja...@googlegroups.com
This worked! Wow!

I note this:


I searched the documentation for TeX-MML-AM_HTMLorMML, but could not find it. Is this something new?

D.

On Saturday, June 16, 2012 10:59:21 PM UTC-7, David wrote:

Marc-gmail

unread,
Jun 18, 2012, 1:00:27 PM6/18/12
to mathja...@googlegroups.com

Did you see the fiddle link I sent ;-)

The actual doc also provides info on default preprocessor settings. 

I am pretty sure you can manage this piecemeal, though, and that is why an exercise in how that would be managed as compared to using the combination  on figuration might be valuable

dwarn...@suddenlink.net

unread,
Jun 18, 2012, 1:58:51 PM6/18/12
to mathja...@googlegroups.com
I did get your example. I copied it and printed it out. I'll be readying it and studying it while we are on our trip to Montana.

Thanks so much.

D.

Marc-gmail

unread,
Jun 18, 2012, 3:24:12 PM6/18/12
to mathja...@googlegroups.com
Well, thank Peter or whomever who cobbled up the fiddle, but I do hope that a doc discussing in parallel these configs would be worthwhile <hint> ;-)


Peter Krautzberger

unread,
Jun 18, 2012, 7:03:36 PM6/18/12
to mathja...@googlegroups.com
Thanks @Marc -- and for the subtle hint re our docs  ;)

@David I think what confused me was that you kept using "MathJax" as if it was a specific input option. I think I would have understood sooner if you'd written "TeX" instead. 

With MathJax we usually mean the complete library -- so when you write about "using MathJax and asciimathml", I think of those two javascript libraries, not their input methods (of which MathJax currently has three).

Peter.

Marc Grober

unread,
Jun 18, 2012, 8:33:11 PM6/18/12
to mathja...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 6/18/12 3:03 PM, Peter Krautzberger wrote:
> Thanks @Marc -- and for the subtle hint re our docs ;)

LOL, the docs are actually very comprehensive, but for people who
learn by doing (yes, there are some who would suggest that an entire
gender of homo sapiens is incapable of reading all the instructions
first - "I am a man, But I can change, If I have to, I guess....")
or are willing to put in some time for a quick fix but don't have
several hours to work through the docs, RTFM is not an appropriate
response ;-) [if it ever is, though one's patience may be tried.)

A colleague and I tried to do a case analysis with some Moodle docs
and I thought it was helpful. We took a couple of the most common
configurations and tried to step through how they worked, why they
worked that way, and how we did the configuration. In other words, we
did enough to demonstrate the process behind the configuration and
illustrated a common configuration that we could expect might produce
possible confusion.

The kitchen sink common configs are GREAT solutions, but for a user
who needs to change the tokens (not unusual), he needs to understand
how to effect the default where he is using the CDN, and the possible
tradeoffs between using the common config, and using his own full
config. To manage that he would eventually have worked through at
least a dozen doc pages (at least twice, lol)

While I don't know that that would be an unreasonable burden (it would
certainly be less trouble than the constant hassles with the Moodle
TeX filter, lol) there is of course a trade off in facilitating the
use of such tools; after all, the whole idea is to make this
technology available :-)

Wearing my designing hat I have suggested that the best way to develop
functional user documentation is to actually observe persons with
almost no background try to work through deployment of a technology
uing the interface or docs. While David spends an incredible amount of
time "in the trenches" as do others in the project, we so often see
web interfaces and documentation that are in fact grossly inaccurate,
inconsistent with the supposedly supported product, etc., such that a
user has to wonder if anyone has actually had to use the docs, lol.
While MathJax is far ahead of such Maroons, such an "explore" might
address the kinds of question we saw here.

And now, I will shut up, as I noticed that someone got the hint and
the room is running out of oxygen ;-)

Thanks folks!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.16 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP38jHAAoJEMCi9wxDaNqE4IQH/3kVKVHG2dtLMb2z4RXTXFnx
O0MSRzsItVmTf+FQlLZzXgc1I8vaXjw2+TeMeI5vyYEsZTrk7BbXFLcqAH0BJp+B
SrAaMCJ1hqSJ6eYRpf8Z74T79In7b8qw+hfiVoW/hz+oTrns2kws8VoXSVQp9N2b
kxG+SUX3EYVfne627nL8byVm3Kwc1kJpexYegoa9csv01b2JKAntBz72Mp4I02/b
ra5o6IN2dipB9EKXjyS/hTDCXFDqILqhHJKzP/lYZaiCdykkl8Wb9zkDoQnX5Z52
XBPCmbm1NHbPb1UF+G3gF7Nd6ZKeRVvIclIlefeQOj6dsCXoNwy5BK2hs7rMU2Q=
=YZCY
-----END PGP SIGNATURE-----

Marc-gmail

unread,
Jun 18, 2012, 9:02:08 PM6/18/12
to Marc-gmail, mathja...@googlegroups.com
Whoops, that should have been Davide (not David)

Davide P. Cervone

unread,
Jun 19, 2012, 9:27:18 AM6/19/12
to mathja...@googlegroups.com
The documentation is at


Not sure why the search doesn't locate this.

Davide

Davide P. Cervone

unread,
Jun 19, 2012, 9:43:48 AM6/19/12
to mathja...@googlegroups.com
The example that Peter put together may be more complicated than what you need.  The double-buffering that it uses is not really needed when you have a single expression that is being typeset.  You could simply have changed the "onchange" to "onkeyup" in the original example I suggested in order to get the typesetting to occur for each letter typed.  Here is a complete example:

<!DOCTYPE html>
<html>
<head>
<title>MathJax Dynamic Math Test Page with ASCIIMath Input</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style>
input {margin-top: .7em}
.output {
  border: 1px solid black;
  padding: 1em;
  width: auto;
  position: absolute; top: 0; left: 2em;
  min-width: 20em;
}
.box {position: relative}
</style>
</head>
<body>
<script>
  //
  //  Use a closure to hide the local variables from the
  //  global namespace
  //
  (function () {
    var QUEUE = MathJax.Hub.queue;  // shorthand for the queue
    var math = null, box = null;    // the element jax for the math output, and the box it's in
    //
    //  Hide and show the box (so it doesn't flicker as much)
    //
    var HIDEBOX = function () {box.style.visibility = "hidden"}
    var SHOWBOX = function () {box.style.visibility = "visible"}
    //
    //  Get the element jax when MathJax has produced it.
    //
    QUEUE.Push(function () {
      math = MathJax.Hub.getAllJax("MathOutput")[0];
      box = document.getElementById("box");
      SHOWBOX(); // box is initially hidden so the braces don't show
    });
    //
    //  The onchange event handler that typesets the math entered
    //  by the user.  Hide the box, then typeset, then show it again
    //  so we don't see a flash as the math is cleared and replaced.
    //
    window.UpdateMath = function (amath) {
      QUEUE.Push(HIDEBOX,["Text",math,amath],SHOWBOX);
    }
  })();
</script>
<p>
The page can include \(\rm\TeX\) code as well as ASCIIMath: `root(3)(x+1)`.
<p>
Type some ASCIIMath code and press RETURN:<br /> 
<input id="MathInput" size="80" onkeyup="UpdateMath(this.value)" />
</p>
<p>You typed:</p>
<div class="box" id="box" style="visibility:hidden">
<div id="MathOutput" class="output">` `</div>
</div>
</body>
</html>

Hope that helps.

Davide


On Jun 18, 2012, at 12:37 PM, <dwarn...@suddenlink.net> <dwarn...@suddenlink.net> wrote:

dwarn...@suddenlink.net

unread,
Jun 21, 2012, 8:29:29 AM6/21/12
to mathja...@googlegroups.com
Davide,

This is terrific. Meanwhile, it's pretty clear to me that I am such a novice with Javascript that I have a very difficulty time reading the documentation. So, these examples that have been shared are an invaluable source for me, as they point out the directions I need to study.

Can I ask for one more example. Consider my slides:


Suppose that I wanted to put a textbox on each page where the students would enter their answer in asciimathml, while just below the textbox their answer is produced using mathjax?

Thanks,

David.

Davide P. Cervone

unread,
Jul 1, 2012, 12:08:40 PM7/1/12
to mathja...@googlegroups.com
OK, here is one that shows how to handle two separate input and output areas.  I'll let you work out how to incorporate it into your slides.

<!DOCTYPE html>
<html>
<head>
<title>MathJax Dynamic Math Test Page with ASCIIMath Input</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<style>
input {margin-top: .7em}
.box {position: relative}
        .container {
          border: 1px solid black;
          padding: 10px;
        }
</style>
</head>
<body>
<script>
 //
 //  Use a closure to hide the local variables from the
 //  global namespace
 //
 (function () {
            var slides = 2;                 // number of slides
   var QUEUE = MathJax.Hub.queue;  // shorthand for the queue
            var math = [], box = [];
   //
   //  Hide and show the box (so it doesn't flicker as much)
   //
   var HIDEBOX = function (i) {box[i].style.visibility = "hidden"}
   var SHOWBOX = function (i) {box[i].style.visibility = "visible"}
   //
   //  Get the element jax when MathJax has produced it.
   //
   QUEUE.Push(function () {
              for (var i = 1; i <= slides; i++) {
                math[i] = MathJax.Hub.getAllJax("MathOutput"+i)[0];
                box[i]  = document.getElementById("box"+i);
                SHOWBOX(i); // box is initially hidden so the braces don't show
              }
   });
   //
   //  The onchange event handler that typesets the math entered
   //  by the user.  Hide the box, then typeset, then show it again
   //  so we don't see a flash as the math is cleared and replaced.
   //
   window.UpdateMath = function (i,amath) {
              QUEUE.Push([HIDEBOX,i],["Text",math[i],amath],[SHOWBOX,i]);
   }
 })();
</script>
<p>
The page can include \(\rm\TeX\) code as well as ASCIIMath: `root(3)(x+1)`.

        <div class="container">
<p>
Type some ASCIIMath code and press RETURN:<br /> 
<input id="MathInput1" size="80" onkeyup="UpdateMath(1,this.value)" />
</p>
<p>You typed:</p>
<div class="box" id="box1" style="visibility:hidden">
<div id="MathOutput1" class="output">` `</div>
</div>
        </div>

        <div class="container">
<p>
Type some ASCIIMath code and press RETURN:<br /> 
<input id="MathInput2" size="80" onkeyup="UpdateMath(2,this.value)" />
</p>
<p>You typed:</p>
<div class="box" id="box2" style="visibility:hidden">
<div id="MathOutput2" class="output">` `</div>
</div>
        </div>

</body>
</html>

Davide
Reply all
Reply to author
Forward
0 new messages