Math & ScienceNumbering macro

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
PJH
Posts: 2
Joined: Sat Apr 02, 2011 2:01 pm

Numbering macro

Post by PJH »

LaTeX lets you \label an equation then later \ref it.

I want to write two macros, \mylabel and \myref which do the following:

\mylabel behaves like \label if the equation is actually referred to in the document (using \myref). If not it behaves like \nonumber.

I did this a long time ago in TeX. It required TeX to be run three times and worked as follows:

Sweep 1: \myref{eq1} outputs to a file the fact that eq1 is referenced.
Sweep 2: \mylabel labels eq1 and any others that are referenced - it knows this from the output of Sweep 1.
Sweep 3: \myref acts like \ref.

I dont know how to do this in LaTeX. Anyone know how?
Thanks

Phil
Last edited by PJH on Sun Apr 10, 2011 10:12 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Numbering macro

Post by Juanjo »

I think what you pretend has already been implemented in the mathtools package. Check section 3.2 of the manual.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
PJH
Posts: 2
Joined: Sat Apr 02, 2011 2:01 pm

Numbering macro

Post by PJH »

Thanks

Following on from your suggestion, I also found this which does the job:
http://www.cs.brown.edu/system/software ... doceqn.pdf
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Numbering macro

Post by localghost »

If that solves the problem, then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting).


Best regards and welcome to the board
Thorsten
Post Reply