# Cross reference to align

What I want to do is to make a cross reference to program (P) and still be able to make cross references to each separate line in the alignment.

\begin{align}
s.t.: & Ax\geq b\label{firstConst}\\
& Dx\geq d\label{secondConst}\\
& x\in\{0,1\}\label{binary}
\end{aling}


I known that I can use gather-aligned to make a reference to the program, but then I do not have the possibility to make references to separate lines. Any suggestions?

• Welcome to TeX.sx! Feel free to visit our TeX.SX starter guide to get the most out of our site. – Peter Jansson May 20 '13 at 7:09
• Is it a program or an equation system? – Marco Daniel May 20 '13 at 9:33
• It is a integer linear program. That is minimize a linear function (objective) subject to the linear constraints firstConst and secondConst given the variables are binary. – Sune May 20 '13 at 9:36
• @MarcoDaniel For historical reasons, those optimisation problems are known as programs (linear program, mixed-integer program etc.). I think George Dantzig is to blame :-) – mafp May 20 '13 at 10:35

You could use subequations to number the individual contraints, and tag the whole program with P. At least that is something I've seen in some books:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$$a = b$$

\renewcommand{\theequation}{P}
\begin{subequations}\label{ip}
\renewcommand{\theequation}{\theparentequation.\arabic{equation}}
\begin{align}
\min &\ cx\label{objective}\\
\text{s.t.}\qquad Ax & \geq b\label{firstConst}\\
Dx & \geq d\label{secondConst}\\
x  & \in\{0,1\}\label{binary}
\end{align}
\end{subequations}
\renewcommand{\theequation}{\arabic{equation}}
The binary program~\eqref{ip}, the objective~\eqref{objective}, the constraint~\eqref{firstConst}.

$$c = d$$
\end{document}


• +1 The numbering scheme is much more elegant than in my solution. I disapprove of the lack of horizontal alignment, though. – jub0bs May 20 '13 at 11:13
• @Jubobs What alignment would you like to have, min and s.t.? – mafp May 20 '13 at 11:18
• Yes, I think the program would be easier to parse that way, but it's just my personal preference. Do what you think is best :) – jub0bs May 20 '13 at 11:20

I suggest using a subequations environment, in which you can have a label (placed outside the align environment) for reference to the whole binary linear program. That approach allows you to have one label for each individual line of the program.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\diag}{diag}
\begin{document}
\begin{subequations}
\label{myILP}
\begin{align}
\text{minimize}   \quad & cx            \label{objective} \\
\text{subject to} \quad & Ax \geq b     \label{firstConst}\\
& Dx \geq d     \label{secondConst}\\
& x \in \{0,1\} \label{binary}
\end{align}
\end{subequations}
\noindent In binary linear program~\ref{myILP},
\eqref{objective} correponds to the (linear) objective,
\eqref{firstConst} and \eqref{secondConst} correspond to
(linear) inequality constraints,
and \eqref{binary} correspond to the binary constraint.
\end{document}