Skip to main content
Added new variation.
Source Link
Andrew Swann
  • 98.2k
  • 13
  • 210
  • 473

The hyperref solution I gave to the other question works fine with mathtools' option showonlyrefs provided you drop cleveref, which is a standard caveat for this option of mathtools:

Sample output

\documentclass{article} \usepackage{mathtools,amsthm,etoolbox} \usepackage{hyperref} \mathtoolsset{showonlyrefs} \newtheorem{theorem}{Theorem} \newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}} \begin{document} \begin{equation} \label{eq:one} x = 1 \end{equation} \begin{theorem} A theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p} and gives \begin{equation} \label{eq:q} c = d \end{equation} as required. \end{proof} \begin{equation} \label{eq:two} z = 2 \end{equation} Refer to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p}. \begin{theorem} A second theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p2} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and gives \begin{equation} \label{eq:q2} c = d. \end{equation} \eqref{eq:q2} is the required result. \end{proof} \end{document} 

For your new request of applying the reference-use check only to equations inside proofs, you can adjust the above code to

\newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\mathtoolsset{showonlyrefs}% \setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}% \mathtoolsset{showonlyrefs=false}} 

The hyperref solution I gave to the other question works fine with mathtools' option showonlyrefs provided you drop cleveref, which is a standard caveat for this option of mathtools:

Sample output

\documentclass{article} \usepackage{mathtools,amsthm,etoolbox} \usepackage{hyperref} \mathtoolsset{showonlyrefs} \newtheorem{theorem}{Theorem} \newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}} \begin{document} \begin{equation} \label{eq:one} x = 1 \end{equation} \begin{theorem} A theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p} and gives \begin{equation} \label{eq:q} c = d \end{equation} as required. \end{proof} \begin{equation} \label{eq:two} z = 2 \end{equation} Refer to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p}. \begin{theorem} A second theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p2} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and gives \begin{equation} \label{eq:q2} c = d. \end{equation} \eqref{eq:q2} is the required result. \end{proof} \end{document} 

The hyperref solution I gave to the other question works fine with mathtools' option showonlyrefs provided you drop cleveref, which is a standard caveat for this option of mathtools:

Sample output

\documentclass{article} \usepackage{mathtools,amsthm,etoolbox} \usepackage{hyperref} \mathtoolsset{showonlyrefs} \newtheorem{theorem}{Theorem} \newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}} \begin{document} \begin{equation} \label{eq:one} x = 1 \end{equation} \begin{theorem} A theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p} and gives \begin{equation} \label{eq:q} c = d \end{equation} as required. \end{proof} \begin{equation} \label{eq:two} z = 2 \end{equation} Refer to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p}. \begin{theorem} A second theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p2} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and gives \begin{equation} \label{eq:q2} c = d. \end{equation} \eqref{eq:q2} is the required result. \end{proof} \end{document} 

For your new request of applying the reference-use check only to equations inside proofs, you can adjust the above code to

\newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\mathtoolsset{showonlyrefs}% \setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}% \mathtoolsset{showonlyrefs=false}} 
Source Link
Andrew Swann
  • 98.2k
  • 13
  • 210
  • 473

The hyperref solution I gave to the other question works fine with mathtools' option showonlyrefs provided you drop cleveref, which is a standard caveat for this option of mathtools:

Sample output

\documentclass{article} \usepackage{mathtools,amsthm,etoolbox} \usepackage{hyperref} \mathtoolsset{showonlyrefs} \newtheorem{theorem}{Theorem} \newcounter{equationstore} \newcounter{proofnum} \AtBeginEnvironment{proof}{\setcounter{equationstore}{\value{equation}} \refstepcounter{proofnum} \setcounter{equation}{0}\renewcommand{\theequation}{\arabic{equation}$^*$} \renewcommand{\theHequation}{\arabic{proofnum}.\arabic{equation}$^*$}} \AtEndEnvironment{proof}{\setcounter{equation}{\value{equationstore}}} \begin{document} \begin{equation} \label{eq:one} x = 1 \end{equation} \begin{theorem} A theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p} and gives \begin{equation} \label{eq:q} c = d \end{equation} as required. \end{proof} \begin{equation} \label{eq:two} z = 2 \end{equation} Refer to \eqref{eq:one}, \eqref{eq:two} and \eqref{eq:p}. \begin{theorem} A second theorem. \end{theorem} \begin{proof} Proof \begin{equation} \label{eq:p2} a = b \end{equation} refers to \eqref{eq:one}, \eqref{eq:two} and gives \begin{equation} \label{eq:q2} c = d. \end{equation} \eqref{eq:q2} is the required result. \end{proof} \end{document}