5

When I try to input:

\begin{eqnarray*}
w(t) &=& \frac{1}{2}Cv^2(t)\\
\boxed{w(t) &=& \frac{1}{2}C \frac{q(t)^2}{C^2}}\\
w(t) &=& \frac{1}{2}\frac{q(t)^2}{C}\\
w(t) &=& \frac{1}{2}Cv^2(t)\\
\end{eqnarray*}

I get an error. The following code works but the box is way of to the left... (I didn't use &=& on the boxed equation this time.)

\begin{eqnarray*}
w(t) &=& \frac{1}{2}Cv^2(t)\\
\boxed{w(t) = \frac{1}{2}C \frac{q(t)^2}{C^2}}\\
w(t) &=& \frac{1}{2}\frac{q(t)^2}{C}\\
w(t) &=& \frac{1}{2}Cv^2(t)\\
\end{eqnarray*}

Are there any ways to fix this issue?

Karlo
  • 3,257
Rectifier
  • 765

1 Answers1

10

Why no use \Aboxed command of the package mathtools? inside of an align* environment

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
w(t) &= \frac{1}{2}Cv^2(t)\\
\Aboxed{w(t) &= \frac{1}{2}C \frac{q(t)^2}{C^2}}\\
w(t) &= \frac{1}{2}\frac{q(t)^2}{C}\\
w(t) &= \frac{1}{2}Cv^2(t)\\
\end{align*}
\end{document}

enter image description here

skpblack
  • 8,904
  • 3
  • 31
  • 42