edit: Is there a way to accomplish the below without using the flalign environment? As I mentioned in my question, I know that it is possible to achieve what I'm asking using the flalign environment. This environment however, cannot be wrapped in a newenvironment and so the solution can't be automated. Does anyone know of another solution method?

My question is simple. I'm trying to create an equation environment that will tag an equation with both custom text and an equation number. The text should be flush left and the equation number flush right. It should look like the following.

(customTxt)                      1 + 1 = 2                                 (1)

The custom text is generated by a complicated command that does some arithmetic with counters. The equation number is just \theequation as usual.

I can certainly accomplish this using e.g. flalign:

  \mycommand && 1 + 1 = 2 &&

However, I can't seem to wrap this into a newenvironment. This appears to be a known issue about align cf this question or this question. I'm working on a very long document and every equation needs to be marked like this. I'd really like to have some sort of custom equation environment that sets this up for me:

  1 + 1 = 2

Can anyone offer suggestions? edit How do I define a shortcut or command to do this succinctly? Every time I use this command, the parts

\mycommand && ... &&

will always be the same. Is there any way to automate this? The trouble is that the solution given in the referred-to questions will not work in a \newenvironment command.

  • 1
    Related: tex.stackexchange.com/questions/159800/… Commented Dec 2, 2016 at 4:59
  • @StevenB.Segletes does your stackEngine solution work with equation labels? I want the right equation number to be referred to in e.g. Equation \ref{mylabel}
    – Austin A.
    Commented Dec 2, 2016 at 5:05
  • 1
    @AustinA.: See this paste for a solution to your problem (which still uses flalign).
    – Werner
    Commented Dec 2, 2016 at 8:19
  • It should work in the normal way with labels, since it uses the equation environment. Of course, the caveat here is that what is stacked is the text identifier to the left of the equation. If you instead stack multiple equations with the package in an equation environment, you will still only get one equation number per equation environment. Commented Dec 2, 2016 at 11:40

1 Answer 1


Actually, it is possible to wrap flalign inside a different environment. Below I capture the environment's contents using environ and process it like a macro in two different ways:

enter image description here



    #1 && \BODY &&

  \text{mycom}% ...or a complicated macro

    \makebox[0pt]{$\displaystyle \BODY$}% Set equation
    \makebox[0pt][r]{\makebox[.5\linewidth][l]{#1}}% Set custom text (argument)


  1 + 1 = 2

  1 + 1 = 2


The differences in horizontal alignment stem from the differences in how the equations are set up. In myEqnB, both the equation and the custom text (argument) are set in zero-width boxes (for ease of alignment).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .