TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
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
up vote 5 down vote accepted

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.



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


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


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

share|improve this answer

\[ 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).

share|improve this answer
I'm out of votes, but your answer will receive an upvote tomorrow. – lockstep Sep 4 '11 at 22:15
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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