# How to underline in math mode with ampersand anchor?

When I use the ampersand & in align for positioning I loose the underline function. Is there a (simple) way of underlining the last math line completely?

\documentclass[14pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}

\begin{document}
\begin{align*}
\mathcal{H} (c, K, \lambda, t) &= \frac{c^{1-\frac{1}{\sigma} } -1}{1 - \frac{1}{\sigma}} + \lambda \cdot \left(  r \cdot K + w \cdot L_Y + \Pi_x \cdot A - c \cdot L \right) \\
\Leftrightarrow \frac{\dot c}{c} &= \sigma \cdot \left( r - \rho - n \right) \tag{25}
\end{align}
\end{document}


Example:

You can underline the whole equation or colour it..... using tcolorbox.

\documentclass[14pt,a4paper,headlines=6,headinclude=true]{scrartcl}
\usepackage{amsmath,amssymb,stmaryrd}
\usepackage{empheq}
\usepackage[theorems,skins]{tcolorbox}

\newtcbox{\underlined}[1][]{nobeforeafter,math upper,tcbox raise base,
enhanced jigsaw,arc=0pt,boxrule=0pt,bottomrule=1pt,colback=white,colframe=black,
#1}

\begin{document}
\begin{empheq}[box=\underlined]{align}
\mathcal{H} (c, K, \lambda, t) &= \frac{c^{1-\frac{1}{\sigma} } -1}{1 - \frac{1}{\sigma}} + \lambda \cdot \left(  r \cdot K + w \cdot L_Y + \Pi_x \cdot A - c \cdot L \right) \notag\\
\Leftrightarrow \frac{\dot c}{c} &= \sigma \cdot \left( r - \rho - n \right)
\end{empheq}
\end{document}


• But my MWE was just a code snippet. This box just underlines the last line of math-environment? Would be great to give underline to any line also within the align or empheq.
– Mac
Apr 15, 2015 at 13:58
• @Mac Yes only the last line. If you want every line, then you have to put them in separate environments.
– user11232
Apr 15, 2015 at 13:59

Is this what you want? After a lot of phantoms, looks right.

\begin{align*}
\mathcal{H} (c, K, \lambda, t) &= \frac{c^{1-\frac{1}{\sigma} } -1}{1 - \frac{1}{\sigma}} + \lambda \cdot \left(  r \cdot K + w \cdot L_Y + \Pi_x \cdot A - c \cdot L \right) \\
\rlap{%
\underline{%
\vphantom{$\displaystyle\frac{\dot c}{c}$}%
\hphantom{$\Leftrightarrow \frac{\dot c}{c} = \sigma \cdot \left( r - \rho - n \right)$}%
}%
}%
\Leftrightarrow \frac{\dot c}{c} &= \sigma \cdot \left( r - \rho - n \right)
\tag{25}
\end{align*}


• I'm looking for a way that gives a end-to-end underline. Even under the equation sign.
– Mac
Apr 15, 2015 at 13:37