# How to label an optimization problem with a label such as (P)?

I am trying to write an optimization problem in my document, and for convenience, to define a label to refer to it. I don't want to refer to it as equation (3), which I know how to do, I want to define a special text label for it, see below for an example.

       max  \sum p_t s_t
(P)    s.t. s_t \leq d_t
\sum s_t \leq I


Is there a way to put the label on the right side if I so desire? For example,

max  \sum p_t s_t
s.t. s_t \leq d_t    (P)
\sum s_t \leq I

-
The first part of your question is answered in tex.stackexchange.com/questions/12026/… –  Caramdir Aug 8 '11 at 20:55
I think the labels are on the right by default. Are you doing something to make them go to the left? –  Caramdir Aug 8 '11 at 20:57
@Caramdir: Yes, they are on the right by default. Setting them to the left can by done by the leqno package option: \usepackage[leqno]{amsmath}. But that will then hold for all equations. –  Werner Aug 8 '11 at 21:00
$f(x) = y \eqno{(P)}$ will put (P) on the right even with leqno, but it's not a true tag, and can't be referred back to with \ref (AFAIK). –  frabjous Aug 8 '11 at 22:42
Thank you for your answers! That definitely answers my questions. –  I Like to Code Aug 10 '11 at 19:10

this will give you the tag and xref you want. you'll probably want to adjust the alignment, but that's not what the question was about.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

We want to refer to an optimization problem \eqref{opt-P} with a
non-numeric tag.
\begin{aligned} & \max \sum p_t s_t\\ & \text{s.t. } s_t \leq d_t\\ & \sum s_t \leq I \end{aligned} \tag{P}\label{opt-P}

\end{document}


if you're using amsmath (as this example does) and the tags are usually on the left, then add this to the preamble:

\makeatletter
\newcommand{\onetagright}{\tagsleft@false}
\makeatother


wrap the equation in \begingroup \onetagright ... \endgroup and just that one tag goes on the right.

-

$f(x) = y \eqno{(P)}$ will put (P) on the right even with leqno, but it's not a true tag, and can't be referred back to with \ref (AFAIK).

-
The braces should be unnecessary, as everything from \eqno to the first \$ (with expansion, so \] will end it) is the "equation number" and it's definitely not a command with an argument. Maybe \eqno\textup{(P)} would be better, since the equation number is typeset in math mode. –  egreg Sep 4 '11 at 23:47