# \eqnarray and \boxed

Hey I have following code and I would like to set last equality into box but when I use \boxed I have an error. What can I do?

\begin{eqnarray*}
\Theta _{C} &=&\frac{\partial }{\partial t}\left( C\right) =qSe^{-q\left(
T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right) }N\left(
d_{-}\right)  \\
&&+Se^{-q\left( T-t\right) }n\left( d_{+}\right) \sigma \frac{-1}{2\sqrt{T-t}%
} \\
&=&qSe^{-q\left( T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right)
}N\left( d_{-}\right)\\
&&-Se^{-q\left( T-t\right) }n\left( d_{+}\right) \frac{%
\sigma }{2\sqrt{T-t}} \\
\end{eqnarray*}


Never use eqnarray under any circumstances; amsmath provides several environments for alignments that are more powerful and feature much better spacing.

Here you can use aligned nested inside align*.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\Theta _{C}
= \frac{\partial}{\partial t}(C)
&= \begin{aligned}[t]
&  qSe^{-q(T-t) }N( d_{+}) -rKe^{-r( T-t) } N(d_{-})  \\
&+ Se^{-q( T-t) }n( d_{+}) \sigma \frac{-1}{2\sqrt{T-t}}
\end{aligned}
\\[2ex]
&= \boxed{\begin{aligned}[t]
& qSe^{-q( T-t) }N( d_{+}) -rKe^{-r( T-t)}N( d_{-})\\
&-Se^{-q( T-t) }n( d_{+}) \frac{\sigma }{2\sqrt{T-t}}
\end{aligned}}
\end{align*}

\end{document}


An aligned environment can easily be \boxed.

Note that I removed all \left and \right commands that did nothing useful (and damaged the spacing).

Also, I moved the alignment point to the second “=” in the first line, for better symmetry.

• Thanks it works! :) Nov 5, 2020 at 22:29
• alignat -> aligned Nov 6, 2020 at 13:02
• @IanThompson Thanks, fixed Nov 6, 2020 at 13:05

First, forget about eqnarray/eqnarray*. Use align/align* instead: https://www.texfaq.org/FAQ-eqnarray.

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{align*}
\Theta_{C}&=\frac{\partial }{\partial t}\left( C\right)=qSe^{-q\left(
T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right) }N\left(
d_{-}\right)  \\
&+Se^{-q\left( T-t\right) }n\left( d_{+}\right) \sigma \frac{-1}{2\sqrt{T-t}%
} \\
&=qSe^{-q\left( T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right)
}N\left( d_{-}\right)\\
&-Se^{-q\left( T-t\right) }n\left( d_{+}\right) \frac{%
\sigma }{2\sqrt{T-t}} \\
\end{align*}
\end{document}


Here there is the boxed formula using empheq package.

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{empheq}
\begin{document}
\begin{empheq}[box=\fbox]{align*}
\Theta_{C}&=\frac{\partial }{\partial t}\left( C\right)=qSe^{-q\left(
T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right) }N\left(
d_{-}\right)  \\
&+Se^{-q\left( T-t\right) }n\left( d_{+}\right) \sigma \frac{-1}{2\sqrt{T-t}%
} \\
&=qSe^{-q\left( T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right)
}N\left( d_{-}\right)\\
&-Se^{-q\left( T-t\right) }n\left( d_{+}\right) \frac{%
\sigma }{2\sqrt{T-t}}
\end{empheq}
\end{document}


Addendum 1: "to set into box only last equation, i.e only last two lines, without "=" sign" (see the comment).

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{empheq}
\begin{document}
\begin{align*}
\Theta_{C}&=\frac{\partial }{\partial t}\left( C\right)=qSe^{-q\left(
T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right) }N\left(
d_{-}\right)  \\
&+Se^{-q\left( T-t\right) }n\left( d_{+}\right) \sigma \frac{-1}{2\sqrt{T-t}%
}
\end{align*}
\begin{empheq}[innerbox=\fbox]{align*}
qSe^{-q\left( T-t\right) }N\left( d_{+}\right) -rKe^{-r\left( T-t\right)
}N\left( d_{-}\right) &\\
-Se^{-q\left( T-t\right) }n\left( d_{+}\right) \frac{%
\sigma }{2\sqrt{T-t}} &
\end{empheq}
\end{document}


Addendum 2: From the comment of @Barbarabeeton "Where is the equal sign for the boxed material in the last version".

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{empheq}
\begin{document}
\begin{align*}
\Theta_{C}&=\frac{\partial}{\partial t}(C)=qSe^{-q(
T-t)}N(d_{+})-rKe^{-r(T-t}N(
d_{-})  \\
&+Se^{-q(T-t)}n(d_{+}) \sigma\frac{-1}{2\sqrt{T-t}%
}
\end{align*}
\begin{empheq}[box=\fbox]{align*}
\MoveEqLeft
=qSe^{-q(T-t)}N(d_{+})-rKe^{-r(T-t)
}N(d_{-}) \\
&-Se^{-q(T-t)}n(d_{+}) \frac{%
\sigma}{2\sqrt{T-t}}
\end{empheq}

\end{document}


• I suggest you recommend not using eqnarray with the following reference: texfaq.org/FAQ-eqnarray Nov 5, 2020 at 21:57
• @ivankokan Yes, in the meantime I'm putting the boxed formula. However you can edit my question adding your link if you prefer. Welcome :-) Nov 5, 2020 at 21:59
• @HSmile Work in progress :-) Nov 5, 2020 at 22:03
• Thanks but it still doesnt solve my problem. You set all equations into box, but I would like to set into box only last equation, i.e only last two lines, without "=" sign (sign "-" easy to move to the right by \quad command but how to put this into box?) Nov 5, 2020 at 22:12
• @HSmile Can you see if now is better? Thanks. Nov 5, 2020 at 22:28