# Draw baseline in equation

I need to draw a base line in an equation. For example i generate equation

\documentclass{article}
\usepackage{amsmath}
\pagestyle{empty}

\begin{document}
\begin{align*}
\psi_{tot}(x,-t_0,r) = \frac{1}{(2\pi)^2} \int\!\!\!\int
\tilde\Psi_{tot}\left(k_x,\frac{c}{2}\sqrt{k_x^2 + k_r^2},r=0\right)
\end{align*}

\end{document}


and get

but i need

\documentclass{scrartcl}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{xcolor}

\newcommand*\drawbaseline[2][orange]
{\begingroup\sbox0{$\displaystyle#2$}\mathrlap{\color{#1}\rule{\wd0}{.1pt}}\endgroup#2}

\begin{document}

\begin{align*}
\drawbaseline{\psi_{\mathrm{tot}}(x,-t_0,r) = \frac{1}{(2\pi)^2} \iint
\tilde\Psi_{\mathrm{tot}}\Bigl(k_x,\frac{c}{2}\sqrt{k_x^2 + k_r^2},r=0\Bigr)}
\end{align*}

\end{document}


A dirty trick, exploiting align (which generally shouldn't be used for single line displays)

\documentclass{article}
\usepackage{amsmath,xcolor}
\pagestyle{empty}

\makeatletter
\newcommand{\showbaseline}{%
\ifmeasuring@
\else
\makebox[0pt][l]{%
\color{red}%
\vrule height.05pt depth 0.05pt
width \ifcase\expandafter1\maxcolumn@widths\fi
}%
\fi
}
\makeatother

\begin{document}

\begin{align*}
\showbaseline
\psi_{\mathrm{tot}}(x,-t_0,r) =
\frac{1}{(2\pi)^2} \iint
\tilde\Psi_{\mathrm{tot}}\left(k_x,\frac{c}{2}\sqrt{k_x^2 + k_r^2},r=0\right)
\end{align*}

\end{document}


The trick is somewhat explained in https://tex.stackexchange.com/a/209732/4427

I also fixed some errors in the code.