4

I am using the following code to create a list of equations,

\begin{equation}
  \begin{array}{rcll}
  \| \hat{\textbf{v}}_{i}^{*} \|^{2} & = & \left\| \hat{\textbf{v}}_{i}^{*} + \sum_{j=1}^{i-1} \mu_{i,j}\hat{\textbf{v}}_{j}^{*} \right\|^{2} & \mbox{from (\ref{eqn:gram-schmit-orthogonalization})}, \notag \\
    & = & \| \hat{\textbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} \mu_{i,j}^{2} \| \hat{\textbf{v}}_{j}^{*} \|^{2} & \mbox{since~} \hat{\textbf{v}}_{1}^{*}, \ldots, \hat{\textbf{v}}_{n}^{*} \mbox{~are orthogonal}, \notag \\
    & \leq & \| \hat{\textbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} \frac{1}{4} \| \hat{\textbf{v}}_{j}^{*} \|^{2} & \mbox{since~} | \mu_{i,j} | \leq \frac{1}{2}, \notag \\
    & = & \| \hat{\textbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} 2^{i-j-2} \| \hat{\textbf{v}}_{i}^{*} \|^{2} & \mbox{from (\ref{eqn:lovasz-useful-estimate})}, \notag \\
    & = & \frac{1+2^{i-1}}{2} \| \hat{\textbf{v}}_{i}^{*} \|^{2} & \notag \\
    & \leq & 2^{i-1} \| \hat{\textbf{v}}_{i}^{*} \|^{2} & \mbox{since~} 1 \leq 2^{i-1} \mbox{~for all~} i \geq 1. \label{eqn:lovasz-simplification} \\
  \end{array}
\end{equation}

What I want to do is put a label (or number) against the last equation in the list. I am not quite sure how to do this. I have tried searching online, and the closest that I have been able to find is using the \tag{...} command of the align environment. Unfortunately, this environment only allows the equation to be split into two. I want more control over splitting the equation, which is why I chose the array environment to split the equations into four segments. Any help would be appreciated.

1
  • 1
    If you need more alignment points, simply use the alignat environment. For details refer to the amsmath user guide. Commented Mar 1, 2012 at 10:27

2 Answers 2

5

I know you wrote that you don't like align, but I believe that the following code does exactly what you want. Notice that I use \text and \mathbf, which is more proper than \mbox and \textbf. The \text command does better font handling and \mathbf should be used for upright bold math.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}
  \| \hat{\mathbf{v}}_{i}^{*} \|^{2} & = \left\| \hat{\mathbf{v}}_{i}^{*} + \sum_{j=1}^{i-1} \mu_{i,j}\hat{\mathbf{v}}_{j}^{*} \right\|^{2} && \text{from (\ref{eqn:gram-schmit-orthogonalization})}, \notag \\
    & = \| \hat{\mathbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} \mu_{i,j}^{2} \| \hat{\mathbf{v}}_{j}^{*} \|^{2} && \text{since~} \hat{\mathbf{v}}_{1}^{*}, \ldots, \hat{\mathbf{v}}_{n}^{*} \text{~are orthogonal}, \notag \\
    & \leq \| \hat{\mathbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} \frac{1}{4} \| \hat{\mathbf{v}}_{j}^{*} \|^{2} && \text{since~} | \mu_{i,j} | \leq \frac{1}{2}, \notag \\
    & = \| \hat{\mathbf{v}}_{i}^{*} \|^{2} + \sum_{j = 1}^{i-1} 2^{i-j-2} \| \hat{\mathbf{v}}_{i}^{*} \|^{2} && \text{from (\ref{eqn:lovasz-useful-estimate})}, \notag \\
    & = \frac{1+2^{i-1}}{2} \| \hat{\mathbf{v}}_{i}^{*} \|^{2} \notag \\
    & \leq 2^{i-1} \| \hat{\mathbf{v}}_{i}^{*} \|^{2} && \text{since~} 1 \leq 2^{i-1} \text{~for all~} i \geq 1. \label{eqn:lovasz-simplification}
\end{align}

\end{document}
5
  • Thanks for that! I didn't realize that the align environment had a double ampersand (&&) option!
    – Bill
    Commented Mar 1, 2012 at 10:18
  • 3
    It has something like 20 columns, and the odd ones are formatted right, the even ones left and there is a "stretch" between each pair of {rl} columns. As well, the columnsep is set in such way that you should use & in front of the relation/operator, so &= is correct whereas =& is not.
    – yo'
    Commented Mar 1, 2012 at 10:20
  • 1
    @tohecz -- the "v"s in the expression, although bold, are still math. better to use \mathbf instead of \textbf. this does not apply to the use of \text, which should definitely be used when there is real text in the display. Commented Mar 1, 2012 at 14:57
  • @barbarabeeton Sorry, I did not check the input precisely, which I should have. I simply used the code by Bill. I'm correcting it.
    – yo'
    Commented Mar 1, 2012 at 15:00
  • @barbarabeeton - Yep! That's my fault! Thanks for the advice Barbara!
    – Bill
    Commented Mar 1, 2012 at 22:51
5

Instead of using \notag you can define \eqnumtag taht inserts the number in {align*}.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\eqnumtag}{%
   % step the counter and make it lable-able
   \refstepcounter{equation}%
   % print the counter as tag
   \tag{\theequation}%
}

\begin{document}
Reference to eq.~(\ref{eqn:test}) and (\ref{eqn:test2}).
\begin{equation}
1+1=2
\end{equation}
Text
\begin{align*}
   a &= b \\
   0 &= 0 \\
   1 &= 1 \eqnumtag\label{eqn:test}
\end{align*}
Text
\begin{equation}
2^2=4
\end{equation}
Text
\begin{subequations}
\begin{align*}
   a &= b \\
   0 &= 0 \\
   1 &= 1 \eqnumtag\label{eqn:test2}
\end{align*}
Text
\begin{equation}
2^2=4
\end{equation}
Text
\end{subequations}
\end{document}

eqtag

Note that this solution also works with {subequations}.

1
  • Thanks Tobi, but I rather like tohecz's solution as it more closely resembles what I am used to using the array environment.
    – Bill
    Commented Mar 1, 2012 at 10:29

You must log in to answer this question.

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