[Tex/LaTex] Horizontal positioning of vertical arrows between lines in an alignment

alignamsmatharrowsmath-modemathtools

I'm trying to get a construction like

\documentclass{article}
\usepackage{amsmath,mathtools}

\begin{document}
\begin{align*}
  a &= b \\
    &\Downarrow \\
  a &= c
\end{align*}
\end{document}

enter image description here

to look good. The problem is that the \Downarrow is not horizontally centered between the = signs. While I understand why this happens and why a \mathrel{\Downarrow} doesn't help, I don't know how to fix it. I'm aware of the \ArrowBetweenLines[\Downarrow] function in mathtools, but that is for having the arrow to the left of the aligned lines. I would ideally want something that works the same way \vdotswithin{=} does (from mathtools). Does that exist somewhere? Or would it be difficult to manually "create a box corersponding to {}={} and typeset a" \Downarrow "centered inside it"?

Best Answer

Here's the definition of \vdotswithin from mathtools:

\newcommand\vdotswithin[1]{%
  {\mathmakebox[\widthof{\ensuremath{{}#1{}}}][c]{{\vdots}}}}

You can update this to something called \symbolwithin{<symbol>}{<within symbol>} (say):

enter image description here

\documentclass{article}

\usepackage{mathtools}

\newcommand\symbolwithin[2]{%
  {\mathmakebox[\widthof{\ensuremath{{}#2{}}}][c]{{#1}}}}

\begin{document}

\begin{align*}
  a &= b \\
    &\symbolwithin{\Downarrow}{=} \\
  a &= c
\end{align*}

\end{document}
Related Question