Take the 2-minute tour ×
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.

currently I have an optimization problem defined in {equation} environment:

enter image description here

I want to add a label (P) before equation (6).

Currently, I had to use the first line "Optimization problem (P)" as a workaround.

Ideally, I'd like it to look like this:

enter image description here

I tried to use {IEEEeqnarray}, but it didn't work well. Also tried to google, but couldn't find an answer.

Any help is much appreciated!

share|improve this question
1  
In case you don't need the label (6), you could use the command \tag{(P)} together with \label for your equation. It will change the (6) by (P), and each time you call the equation it compiler put a (P). Note: the package amsmath needs to be loaded. –  Dox Feb 11 at 11:30
    
@Dox Thanks - I tried to use \tag{P}, but ideally, I still want the label (6) to be there because I need to cross-reference it elsewhere in the paper with (6), not with (P). –  Chang Feb 11 at 11:36
    
I have a feeling that you're going to seriously confuse your reader by this (P) and (6) schizophreny, but do as you wish :) –  yo' Feb 11 at 12:09
    
@tohecz Actually...(P) refers to the entire optimization problem including (6) and a bunch of other constraints (7)(8)..., where (6) is only the objective equation of (P). That's how I'll cross-reference them in the context. Do you think this is not a good idea? :) –  Chang Feb 11 at 12:22

1 Answer 1

up vote 7 down vote accepted

Following the method described in Formula label outside of formula

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent text
\begin{flalign}
\text{(P)}&&\min_{x_{ij},\delta_i} \sum_{i=1}^m (P_i^{svr} + P_i^{cool})&&\phantom{\text{(P)}}
\end{flalign}
text
\end{document}

enter image description here

As daleif points out in the comments, the textual superscripts like "svr" and "cool" should be in upright, not italic, text. I left them italic, mimicking the OP's original effort, since they had nothing to do with placing the label on the left. More properly, one should use \mathrm{} or one of the several other ways to force those superscripts upright.

And here is another way to achieve the leftward label, using my stackengine package instead of amsmath (the only quirk is the \rule that I added because the vertical space above the equation was otherwise too short).

\documentclass{article}
\usepackage{stackengine}
\begin{document}
\noindent text
\begin{equation}
\renewcommand\useanchorwidth{T}
\renewcommand\stacktype{L}
\stackon[0pt]{$\displaystyle\min_{x_{ij},\delta_i} \sum_{i=1}^m (P_i^{svr} + P_i^{cool})
$}{\makebox[\textwidth][l]{(P)}\rule{0ex}{5.5ex}}
\end{equation}
text
\end{document}

enter image description here

One flexibility of this approach is that you could make the \makebox of width, for example, [.9\textwidth] which would provide for a constant indent of the label with respect to the left margin.

Finally, If one didn't need the label left-aligned, but merely offset to the left (let's say a fixed amount), a third approach could use \llap{(P)\hspace{1in}} at the beginning of the equation in the equation environment.

share|improve this answer
    
Better than my suggestion! Thank you for the trick! –  Dox Feb 11 at 11:39
    
Excellent, it works! Thanks a lot! –  Chang Feb 11 at 11:41
    
Remember to put the named indices in upright font –  daleif Feb 11 at 12:46
    
@daleif Are you referring to "svr" and "cool"? I mimicked the OP's code, but I agree that these should be upright. –  Steven B. Segletes Feb 11 at 12:48
    
Yes, those indices, basically just to let others coming by know, that that is what they should remember to do –  daleif Feb 11 at 20:33

Your Answer

 
discard

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.