9

I have to give a talk, and I am using a LaTeX paper that I will write onto the blackboard. However, it is quite annoying to write all equation numbers on the blackboard, but I do want to have them all in my document. Thus disabling all unreferenced numbers is not an option.

My qestion is: is there a way to define another style for equations that are referred to than those that are not? Let's say I want normal formula numbers in upright and if they are referenced in italics. By this way I can see which numbers are necessary to be written on the blackboard.

2
  • I'm not aware of a package that does this, but it would likely require two passes, because an equation may only be (and, in most cases, is) referenced after its occurrence in the document.
    – jub0bs
    Commented May 20, 2013 at 10:21
  • Yes, I can only imagine that at the first run all references to equations are stored in an auxiliary file and the next run, it is read and the numbers are formatted accordingly. Which command actually produces the equation number? Would it be enough to update this one and ref/eqref? Would that change also work with cleveref/varioref...?
    – Bubaya
    Commented May 20, 2013 at 11:03

1 Answer 1

3

Without having amsmath loaded, the following code manages to draw an fbox around the equation numbers if they have been referenced. However, this does not work together with amsmath and should be altered to make use of mathtools, which could be used more easily, but at the moment I have no idea how to switch the style back after printing out the eq. number.

\makeatletter
% overwrite the reference mechanism: ref shall also create a label where a label has first been referenced. The next time LaTeX is run, \label will recognized that the created eq. number is referenced later on and make it being formatted accordingly. A macro is defined so that no multiple labels for referenced to the same eq. label are defined.
\let\old@ref\ref
\def\ref#1{%
    \write\@auxout{%
        \string\used@label{#1}%
    }%
  \old@ref{#1}%
}
% overwrite the label mechanism: if a label has been created by a former run of LaTeX that indicates that there has been made use of the actual label ought to be created, the next print of the eq. number via \@eqnum is redirected to a new command
\let\old@label\label
\def\label#1{%
    \@ifundefined{used@label@#1}%
        {}%
        {\let\@eqnnum\new@eqnum}%
    \old@label{#1}
}
% overwrite the equation number mechanism: the new@eqnum prints the equation number in another style and then switches back to the default style. 
\let\old@eqnnum\@eqnnum
\def\new@eqnum{%
    \refeqnum%
    \let\@eqnnum\old@eqnum%
}
% this macro marks the label given as used in the aux file.
\def\used@label#1{%
    \@ifundefined{used@label@#1}{%
        \expandafter\gdef\csname used@label@#1\endcsname{}%
    }%
    {}%
}
\makeatother
% this macro holds the \theequation-definition for referenced equations.
\def\refeqnum{\fbox{\theequation}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .