11

When having multiple equations inside one displaymath environment, it is sometimes desirable to refer to just one of them without having to break the environment up into smaller pieces. Take for example the following set of boundary conditions (where the last three labels won't work, but are written here to illustrate the goal of this question):

\[\left\{\begin{array}{l l l l}
    (i)\label{eq:i}\quad        & \epsilon_1E_1^\perp=\epsilon_2E_2^\perp,\quad     &
    (ii)\label{eq:ii}\quad      & B_1^\perp=B_2^\perp,\\\\
    (iii)\label{eq:iii}\quad    & \mathbf{E}_1^\parallel=\mathbf{E}_2^\parallel,\quad   &
    (iv)\label{eq:iv}\quad      & \dfrac{1}{\mu_1}\mathbf{B}_1^\parallel=\dfrac{1}{\mu_2}\mathbf{B}_2^\parallel.
\end{array}\right.\]

enter image description here

How can one refer to any of the above four equations separately? Is a list inside a math environment perhaps possible?

Betohaku
  • 1,637

2 Answers2

15

Here is one way: create your own \mylabel, that mimics the regular \label. The following is a hyperref-compatible version:

enter image description here

\documentclass{article}
\usepackage{amsmath,hyperref}% http://ctan.org/pkg/{amsmath,hyperref}

\providecommand{\phantomsection}{}% In case hyperref is not loaded
\AtBeginDocument{\let\textlabel\label}% http://tex.stackexchange.com/q/9939/5764
\makeatletter
\newcommand{\mylabel}[2]{\raisebox{.7\normalbaselineskip}{\phantomsection}#1%
  \def\@currentlabel{#1}\textlabel{#2}}
\makeatother

\begin{document}

\[
  \left\{\begin{array}{l l l l}
    \mylabel{\text{(\textit{i})}}{eq:i}\quad        & \epsilon_1E_1^\perp=\epsilon_2E_2^\perp,\quad     &
    \mylabel{\text{(\textit{ii})}}{eq:ii}\quad      & B_1^\perp=B_2^\perp,\\\\
    \mylabel{\text{(\textit{iii})}}{eq:iii}\quad    & \mathbf{E}_1^\parallel=\mathbf{E}_2^\parallel,\quad   &
    \mylabel{\text{(\textit{iv})}}{eq:iv}\quad      & \dfrac{1}{\mu_1}\mathbf{B}_1^\parallel=\dfrac{1}{\mu_2}\mathbf{B}_2^\parallel.
  \end{array}\right.
\]
See~\ref{eq:i}, or~\ref{eq:iv}, or~\ref{eq:iii}, or~\ref{eq:ii}.
\end{document}

\mylabel{<to-print>}{<label>} prints and stores <to-print> in the <label> that you can reference later.

Werner
  • 603,163
4

This one is based on Werner's idea but works only when hyperref is loaded.

\documentclass{article}
\usepackage{amsmath}
\usepackage{hyperref}
\makeatletter
\newcommand{\mylabel}[2]{%
  \phantomsection#1%
  \@bsphack
  \begingroup
    \def\label@name{#2}%
    \label@hook
    \protected@write\@auxout{}{%
      \string\newlabel{#2}{%
        {#1}%
        {\thepage}%
        {\@currentlabelname}%
        {\@currentHref}{}%
      }%
    }%
  \endgroup
  \@esphack
}%

\makeatother
\begin{document}

\[
  \left\{\begin{array}{l l l l}
    \mylabel{(\textit{i})}{eq:i}\quad        & \epsilon_1E_1^\perp=\epsilon_2E_2^\perp,\quad     &
    \mylabel{(\textit{ii})}{eq:ii}\quad      & B_1^\perp=B_2^\perp,\\\\
    \mylabel{(\textit{iii})}{eq:iii}\quad    & \mathbf{E}_1^\parallel=\mathbf{E}_2^\parallel,\quad   &
    \mylabel{(\textit{iv})}{eq:iv}\quad      & \dfrac{1}{\mu_1}\mathbf{B}_1^\parallel=\dfrac{1}{\mu_2}\mathbf{B}_2^\parallel.
  \end{array}\right.
\]
See~\ref{eq:i}, or~\ref{eq:iv}, or~\ref{eq:iii}, or~\ref{eq:ii}.
\end{document} 

Output:

enter image description here

karlkoeller
  • 124,410