Hi, until now I was using the eqnarray command, but the wrong spacing forced me to try something else, such as the gather command: I prefer this one over any other alignment command (for spacing reasons), but now there are some problems with equations' numbers:
no number is shown next to the equation;
there is only one label for all the lines (despite I'm not using *)
references to the numbers show something like (3.4), which is the number of the chapter, instead of (13), for example.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Thanks, I copied your example into a new document and it worked fine, but unfortunately it gave me the same errors written above if inserted into the one I am working on: the reason is that, for some strange reason, at a certain point equations are labelled with a negative number using eqnarray while, if I use gather, it's the chapter number.
I know, I must replace every single eqnarray with gather into the document but there are tons of formulas and, when I tried to replace them all using the proper command, many equations where messed up, so I was planning to do it at last, with a lot of patience.
Now I am checking when the first negative number appears in the document (it's -11) but there is nothing wrong neither with that equation, nor with the previous. What do you think?
Magnolis wrote:[…] for some strange reason, at a certain point equations are labelled with a negative number using eqnarray while, if I use gather, it's the chapter number. […]
So you've got a critical point in your source that you can isolate. Hence it should be no problem to prepare a properminimal example.
Magnolis wrote:[…] I know, I must replace every single eqnarray with gather into the document but there are tons of formulas and, when I tried to replace them all using the proper command, many equations where messed up, so I was planning to do it at last, with a lot of patience. […]
It's better to replace {eqnarray} by the align environment.
localghost wrote:
So you've got a critical point in your source that you can isolate. Hence it should be no problem to prepare a properminimal example.
It's not so easy: actually the document is quite long and I put a lot of \nonumber command, in order to hide numbers, so I don't know where the critical point is. I tried by counting equations backward, -11, -10, -9 etc. until I get to 0, but suddenly numbers became positive. I was expecting some kind of hint, such as "usually negative numbering appears because..." (also internet does not mention this problem) but, if you didn't, it means that it must be solved the hard way.
localghost wrote:
It's better to replace {eqnarray} by the align environment.
I also tried this one but some formulas overlapped figures, because of "wrapfigure" command. "gather" is not my final choice, I will try again your suggestion.
The problem seems to be more complicated than expected: I have searched and found equation (0), by backward counting equations: this one has nothing wrong and, if I erase \nonumber both in this and in the previous one, they are labelled as (1) and (2), so numbering starts again from a new point.
At last I have tried something different, deleting all \nonumber commands: numbering seems to work properly, except for the fact that I don't want to see all those numbers.
My opinion is that there is no equation (0), but somehow the very first formulas I wrote work properly, so it may exists.
I must mention one strange thing: at a certain point, two equations have their numbers slightly back respect to the others (again, syntax is correct). Some lines above, is located the last equation whose number works properly.
If no more suggestions are given, as a final attempt I could substitute manually every single "eqnarray" with "gather" (or "align")... hard work, I am afraid to do it for nothing.
The document is finally fixed! It took around 2-3 hours but now all the equations work properly. I will share my experience. My method was erasing "*" into "gather*", in order to show numbers, until I find the last working equation and the first not working one, then searching for what is wrong.
There were 2 problems:
1. the main problem was a single \nonumber outside any equation environment: starting from that point, numbering stopped working: pdf didn't show it, so it was hidden;
2. the secondary problem was where I inserted the \label{equation} command. If an equation takes more than 1 line, you have to write \label{equation} next to the numbered line, like this
otherwise the reference will be something like (2.6) (chapter's number) instead of (14), for example.
I think that the "eqnarray" environment does not have the second problem, but anyway I highly recommend to avoid it and choose "gather" (or "align") instead. That's it, thanks to localghost anyway.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p