Automatic numbering mixed labels/no-labels not working

170 views
Skip to first unread message

Pia Jensen

unread,
Mar 14, 2012, 9:33:53 AM3/14/12
to MathJax Users
I'm trying to make a wiki using MathJax for all the math typesetting,
and it's working pretty well so far. I want to use the AMSmath
equation, align and multline environments, with the automatic
numbering given by the autoNumber: "AMS" or autoNumber: "all"
configurations.

But I get into trouble on pages where I have equations both with and
without labels. It seems that the counter for labeled equations is
separate for the counter for un-labeled equations. A very simple
example showing the error is here:

http://tvnt.nmi3.org/wiki/index.php/Test_Page

This happens both with "AMS" and with "all". Any ideas?

I could of course always put a dummy label in each of my "un-labeled"
equations, but that would be a huge job, just because they all have to
be different.

Davide P. Cervone

unread,
Mar 14, 2012, 9:54:38 AM3/14/12
to mathja...@googlegroups.com
I think you may be mixing up the concept of tags and labels. If you
want to be able to refer to an equation using a symbol that will
translate to its equation number, you want to use \label, not \tag.
That is,

\begin{equation}\label{eq1}
0 = a x^2 + b x + c
\end{equation}

will make a numbered equation (with the number automatically assigned)
and define "eq1" as a name that can be used to refer to that
equation. So \eqref{eq1} would translate to whatever equation number
that equation had.

But

\begin{equation}\tag{1}
0 = a x^2 + b x + c
\end{equation}

says don't automatically number this equation, instead use "1" as the
equation number. This equation is outside of the normal numbering
sequence because you have forced a tag for the equation (usually you
don't use numbers for tags, but things like stars or bullets or other
symbols). So the first automatically numbered equation also is marked
with a "1". Later, you use \tag{2} which marks that equation with a
"2" even though there has already been one tagged with a "2".

This is entirely consistent with actual LaTeX usage. Here is your
code run through LaTeX:

tags.png

Davide P. Cervone

unread,
Mar 14, 2012, 10:14:22 AM3/14/12
to mathja...@googlegroups.com
PS, I see that you are inserting things like <span id="Eq-1">, but if
you use \label and \eqref (or \ref) then you don't need to do that by
hand, as MathJax will include the needed anchor for you.

Also, you have left out the </span> for these spans.

Davide

bozack....@gmail.com

unread,
Mar 14, 2012, 10:18:11 AM3/14/12
to mathja...@googlegroups.com
Oh, no - I haven't misunderstood the use of \tag and \label (I am an avid LaTeX user). I only use \label to label my equations. What I think you've seen is the \tag{some-number} that showns in the gray text before the math has been shown on the test page? I thought those were MathJax doing the automatic numbering?

No-where on the test page do I use \tag in what I write myself.

Any other ideas?

/Pia


You are allowed to force an equation to be tagged by whatever you  
want, including a tag that has already been used, or will be used  
later, as you have done here.

If you want the equations to be numbered 1 through 5, but want to be  
able to refer to the first and last of them, you want to use \label  
not \tag.

Hope that clears things up.

Davide

On Mar 14, 2012, at 9:33 AM, Pia Jensen wrote:

Davide P. Cervone

unread,
Mar 14, 2012, 10:23:26 AM3/14/12
to mathja...@googlegroups.com
Viewing the page source, I see

<h2> <span class="mw-headline" id="Problem_with_automatic_equation_numbering">Problem with automatic equation numbering</span></h2>
<p>First, an equation with a given label (written with <span class="tex2jax_ignore"><code>\begin{equation}\label{labelname...} math... \end{equation}</code></span>)
</p><p><span id="Eq-1"/>\begin{equation}\tag{1}
 0 = a x^2 + b x + c
\end{equation}
</p><p>then a couple of equations without labels (but because of AMS autonumbering, they still get numbers) (written with <span class="tex2jax_ignore"><code>\begin{equation} math... \end{equation}</code></span>)
</p><p>\begin{equation}
 a + b + c
\end{equation}
</p><p>\begin{equation}
 k^2 - c^2
\end{equation}
</p><p>\begin{equation}
 4 + 1 + 5
\end{equation}
</p><p>and then finally an equation with a label again:
</p><p><span id="Eq-2"/>\begin{equation}\tag{2}
 1 = k_1 x^2 + k_2 x + k_3
\end{equation}

which clearly has \tag{1} for the first equation and \tag{2} for the last one, and no labels.  If you use MathJax's "Show Math As... TeX commands" you will also see the \tag{1}.

Perhaps the plugin you are using handles equation numbers itself somehow?

Davide

Davide P. Cervone

unread,
Mar 14, 2012, 10:31:35 AM3/14/12
to mathja...@googlegroups.com
A quick look at


shows that the extension is messing with your labels and tags:

/**
 * MathJax_parser_stage2(&$parser, &$text, &$strip_state)
 *
 * The stage 2 math parser will "strip" (replace by place holders) all math 
 * environments, adding them to the $strip_state->nowiki ReplacementArray.
 * Additionally we register the \label{}, if present, of the math environment and 
 * replace it by an auto numbered \tag{} and then replace all occurrences of 
 * \eqref{} by the correct formula number. Existing \tag{} commands are also 
 * registered such that they can be referenced using \eqref{}.

So you would need to modify the MathJax extension to disable this if you want MathJax to handle the labels and references.  MathJax is properly handling the TeX that it receives, but that TeX has been modified from what you typed by the MediaWiki MathJax extension.

Davide

bozack....@gmail.com

unread,
Mar 14, 2012, 10:35:58 AM3/14/12
to mathja...@googlegroups.com
Ah, well that would explain it. I will have to take a look at the extension then. Thank you so much for your amazingly quick help! :)

Pia



Den onsdag den 14. marts 2012 15.31.35 UTC+1 skrev Davide Cervone:
A quick look at


shows that the extension is messing with your labels and tags:

/**
 * MathJax_parser_stage2(&$parser, &$text, &$strip_state)
 *
 * The stage 2 math parser will "strip" (replace by place holders) all math 
 * environments, adding them to the $strip_state->nowiki ReplacementArray.
 * Additionally we register the \label{}, if present, of the math environment and 
 * replace it by an auto numbered \tag{} and then replace all occurrences of 
 * \eqref{} by the correct formula number. Existing \tag{} commands are also 
 * registered such that they can be referenced using \eqref{}.

So you would need to modify the MathJax extension to disable this if you want MathJax to handle the labels and references.  MathJax is properly handling the TeX that it receives, but that TeX has been modified from what you typed by the MediaWiki MathJax extension.

Davide


elim...@gmail.com

unread,
Dec 6, 2012, 12:25:40 PM12/6/12
to mathja...@googlegroups.com, bozack....@gmail.com
I used \tag{*} for some equation in proof for late referring as (*) within the proof. It worked in on MathJax installation (win2003) but not working in Snow Leopard.  It says "Missing argument for \tag"
Missing argument for \tag

I noticed that you cannot put latex code inside of \tag{}, but is there a way to use *? 

Davide Cervone

unread,
Dec 6, 2012, 12:40:21 PM12/6/12
to mathja...@googlegroups.com
Use the Show Math As menu item to check that the tag actually does have its argument (it could be that your CMS is using * for bold or italics or something and it is being removed).

If that's not it, then please provide the actual equation you are using.  I am not able to reproduce your results.  A URL to a page the shows the problem would be even better.

The contents of \tag{} are in text mode (as is the case with LaTeX), and so you need to use something like \tag{$\bullet$} to get math mode within the tag.

Davide

elim...@gmail.com

unread,
Dec 6, 2012, 2:05:01 PM12/6/12
to mathja...@googlegroups.com
I updated MathJax on my SnowLeopard, set a subdomain and re-configured vhost to associate the subdomain to my SL laptop, in order to show you the problem.


BUT, THEN the problem is gone!

On the real server, I have the same content
where \tag{*} always working, (Still using old version of MathJax)

Anyway, thank you Davide a lot to convince me that \tag{*} should be working.

Should I modify my MathJax configuration in order to use v2.1 correctly?

Many document links are broken. e.g. In this thread...

Davide Cervone

unread,
Dec 18, 2012, 9:01:32 PM12/18/12
to mathja...@googlegroups.com
Should I modify my MathJax configuration in order to use v2.1 correctly?

I just got the chance to look into this, and there is a configuration issue.  Your line

extensions: ["tex2jax.js","TeX/AMSsymbols.js","AMSmath.js"], // use the tex2jax preprocessor

should be

extensions: ["tex2jax.js","TeX/AMSsymbols.js","TeX/AMSmath.js"], // use the tex2jax preprocessor

(note the missing "TeX/" in the AMSmath specification).  It is probably better to use

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [['$','$'],['\\(','\\)']],
    processEscapes: 1
  }
});
</script>
<script type="text/javascript" src="/MathJax/MathJax.js?config=TeX-AMS_HTML-full"></script>
instead.  This uses a combined configuration file which will mean that MathJax won't have to make so many network requests, and also means that you are sure that the extensions are loaded properly.  :-)

Davide
Reply all
Reply to author
Forward
0 new messages