0

I have a list of several conditions with a parameter, and I would like to include the parameter explicitly in tag of the condition. However, I would also like to reference the definition of each condition (with the parameter fixed) later in the text. (It's a bit hard to describe, but if you look at the code below, it should hopefully be clear what I mean.)

Can this be accomplished using enumitem (or some other, hopefully compatible package)?

Mwe:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{enumitem}
\newtheorem*{theorem}{Theorem}
\begin{document}
    Consider the following conditions:
    \begin{enumerate}[label=(\roman{*})$_n$]
        \item
        \label{item:first_condition}
        Some condition
        \item
        \label{item:second_condition}
        Some other conditon.
    \end{enumerate}
    
    How I would imagine I could type it:
    \begin{theorem}
        \ref{item:first_condition}[7] holds.
    \end{theorem}
    \begin{theorem}
        If \ref{item:second_condition}[n] holds, then \ref{item:first_condition}[n+2] holds.
    \end{theorem}
    
    How I would like it to look like:
    \begin{theorem}
        (i)$_7$ holds.
    \end{theorem}

    \begin{theorem}
        If (ii)$_n$ holds, then (i)$_{n+2}$ holds.
    \end{theorem}
\end{document}

1 Answer 1

1

You can set the label and the ref output separately in enumitem, using both the label and the ref key for \begin{enumerate}. This can be used to show the n in the label but not in the reference. That allows you to reference the equation by the main number and adding your own subscript.

Now you can define a separate referencing command with two arguments, the equation and the subscript, using the command \hyperref[target label]{link text}.

To avoid a double link box you can disable the link for \ref using the star form (\ref*), and let \hyperref create the link box (or colorlink with \usepackage[colorlinks]{hyperref}) for the combined label.

MWE:

\documentclass{article}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{enumitem}
\newcommand{\nref}[2]{\hyperref[#1]{\ref*{#1}$_{#2}$}}
\newtheorem*{theorem}{Theorem}
\begin{document}
    Consider the following conditions:
    \begin{enumerate}[label=(\roman{*})$_n$,ref=(\roman*)]
        \item
        \label{item:first_condition}
        Some condition
        \item
        \label{item:second_condition}
        Some other conditon.
    \end{enumerate}
    
    How I would imagine I could type it:
    \begin{theorem}
        \nref{item:first_condition}{7} holds.
    \end{theorem}
    \begin{theorem}
        If \nref{item:second_condition}{n} holds, then \nref{item:first_condition}{n+2} holds.
    \end{theorem}
    
    How I would like it to look like:
    \begin{theorem}
        (i)$_7$ holds.
    \end{theorem}

    \begin{theorem}
        If (ii)$_n$ holds, then (i)$_{n+2}$ holds.
    \end{theorem}
\end{document}

Result:

enter image description here

1
  • That's nice. I didn't know about the ref= option. Thanks!
    – tomasz
    Aug 22, 2020 at 16:01

You must log in to answer this question.

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