5

For example, suppose A \iff B \iff C. What's a way to put a number (like equation number) on each \iff symbol, label them, and reference them separately later?

  • Welcome! Why don't you use an equation environment? – cfr Oct 19 '15 at 3:21
  • If I put A \iff B \iff C in an equation environment, the reference would refer to the whole thing. I want to specifically refer to A \iff B or B \iff C. For example, each \iff has its own proof. So when proving, I need to specify which \iff I'm proving. – Myath Oct 19 '15 at 3:24
  • I hope you don't mind but I've edited your question to clarify that. You might look at tikzmark, especially if you might need to do this for arbitrary connectives. – cfr Oct 19 '15 at 12:53
7

Update: after some poking around it now works with old \ref and is compatible with hyperref (avoid using within a labeled equation because \refstepcounter messed up the label counter)

\documentclass{article}
\usepackage{mathtools}
\usepackage{hyperref}

\makeatletter
\newcounter{iffcount}
\@ifpackageloaded{hyperref}{
    \newcommand{\liff}[1]{
        \refstepcounter{iffcount}
        \def\Hy@AnchorName{iff.\theiffcount}
        \underset{(\theiffcount)}{\iff}
        \newcounter{#1}
        \setcounter{#1}{\theiffcount}
        \@bsphack    
        \protected@write\@auxout{}{%
            \string\newlabel{#1}{{\theiffcount}{\thepage}{}{\Hy@AnchorName}{}}%
        }%
        \@esphack
        \hyper@@anchor{\Hy@AnchorName}{\relax}%
    }
}{
    \newcommand{\liff}[1]{
        \refstepcounter{iffcount}
        \underset{(\theiffcount)}{\iff}
        \newcounter{#1}
        \setcounter{#1}{\theiffcount}
        \@bsphack
        \protected@write\@auxout{}%
            {\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
        \@esphack
    }
}
\makeatother

\begin{document}
I claim that \[A\liff{iff:1} B\liff{iff:2} C.\]

I am going to prove \ref{iff:1} here, and prove \ref{iff:2} there.

I also claim that \[C\liff{iff:3} D\liff{iff:4} E.\]

I am going to prove \ref{iff:3} here, and prove \ref{iff:4} there.
\end{document}

Result: enter image description here


Old version: Here is a rough way of doing it... (does not support hyperref!)

\documentclass{article}
\usepackage{mathtools}

\newcounter{iffcount}
\setcounter{iffcount}{1}
\newcommand{\liff}[1]{
    \underset{(\theiffcount)}{\iff}
    \newcounter{#1}
    \setcounter{#1}{\theiffcount}
    \stepcounter{iffcount}
}
\newcommand{\riff}[1]{\arabic{#1}}

\begin{document}
I claim that \[A\liff{iff:1} B\liff{iff:2} C.\]

I am going to prove \riff{iff:1} here, and prove \riff{iff:2} there.

I also claim that \[C\liff{iff:3} D\liff{iff:4} E.\]

I am going to prove \riff{iff:3} here, and prove \riff{iff:4} there.
\end{document}

Result: enter image description here

| improve this answer | |
  • 1
    Thank you! I change underset to overset, replace the newly defined counter iffcount with equation, put \displaystyle before (\theequation) in the overset to make the numbers bigger, and give the command one more argument so I can use it with any symbol instead of just \iff. – Myath Oct 19 '15 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.