# subequation labels with array environment

How can I typeset one subequation label per line to obtain complex output like

x   = y   if my   weird aligned text  (1a)
y   = x^2         fancy               (1b)
z^3 = z      your dull                (1c)


I know similar questions have been asked several times, but almost all answers advise to use the AMS align environment. I need however the full formatting flexibility of the original array environment:

$$\begin{array}{<weird formatting with @{..} and p{..}>} <weird stuff with several &'s> \end{array}$$


Suggestions to replace array by any other environment that does not provide the full and easy configurability of array may be good enough for the above example, and may be helpful in many other cases, but are no valid answers to this generic question.

• Why do you want an array environment to get this, whereas it is so easy with align or alignat? – Bernard Jan 4 '17 at 9:47
• As far as I see, alignat improves over align by allowing more than two columns to be aligned, but still does not give me the flexibility of the l c r @ p options of array. – Joachim W Jan 4 '17 at 9:55
• It's not quite exact: align allows more than two columns to be aligned. The difference you have control on the horizontal distance between columns (so this cares for @).Do the words in your example have to be aligned in 3 columns? – Bernard Jan 4 '17 at 10:00
• but the spacing in array is not ideal for aligned equations (and the entries are set in inline not display mode) the usual way to control left or right alignment in align constructs is to just use the fact that alternate columns are right and left aligned, so if in some special case you need two adjacent left aligned columns use && to skip over the right alignment. – David Carlisle Jan 4 '17 at 10:04
• See tex.stackexchange.com/a/49016/34503 for an accepted answer which concedes that array can do things align can not. – Joachim W Jan 4 '17 at 10:07

Here is how to easily obtain the same result with alignat and the eqparbox package. The trick is to put all texts within an alignment column in an \eqmakebox with the same tag. All boxes which share the same tag will have the width ofthe widest of them.

\documentclass{article}
\usepackage{mathtools, eqparbox}%
\newcommand{\eqbox}[2][]{\eqmakebox[#1][l]{\mbox{#2~}}}

\begin{document}

\begin{subequations}
\begin{alignat}{7}
& x &   & = y & \qquad\text{if } &   & \eqbox[T1]{my} &   & \eqbox[T2]{weird} &   & \text{aligned } &   & \text{text} \\
& y &  &  = x² &  &  &  &  & \eqbox[T2]{fancy}\\
& z³ &  & =  z &  &  & \eqbox[T1]{your} &  & \eqbox[T2]{dull}
\end{alignat}
\end{subequations}

\end{document}