Align units of equations and units of corresponding legends below each other

I am using this code to align equation units of right the equation and to create nice equation legends.

Minimum Working Example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{siunitx}

%--------------------------------------------------------------------------------------------
% ---- The following part is to align the units of right the equations: ---------------------
%--------------------------------------------------------------------------------------------

\makeatletter%
\renewcommand\tagform@[1]{%
}%
\makeatother%

%--------------------------------------------------------------------------------------------
% ---- The following part is for equation legends including symbol, description and unit ----
%--------------------------------------------------------------------------------------------

\newenvironment{legend*}{%
\par\vspace{\abovedisplayskip}\noindent%
\begingroup%
\leftskip = 3em%                                                    Indent from left, alternative 4em
\noindent\text{\hspace{0.2em} where}%
\par\vspace{\abovedisplayskip}\noindent%
\tabularx{\columnwidth}{>{$$}l<{$$} @{\hspace{2em}} l @{\hspace{2em}} >{\raggedright\arraybackslash}>{[} c<{]}}}%
{\endtabularx\par\vspace{2em}%
\par%
\endgroup%
}%

%--------------------------------------------------------------------------------------------
% ---- Document part ------------------------------------------------------------------------
%--------------------------------------------------------------------------------------------

\begin{document}

$$V = BC \addunit{\square\meter}$$

\begin{legend*}
V & Filter volume & \si{\cubic\meter}\\
B & Density of the filter & \si{\kilo\gram\per\cubic\meter}\\
C & Filter mass & \si{\kilo\gram}\\
\end{legend*}

\end{document}


Screenshot of the result:

Description of the issue:

As you can see, this is looking nice but not perfect. Therefore I want to align the units of the legend flushed right in one line with the unit of the equation.

Screenshot of the desired state:

How can I modify this code?

Use an X column:

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{siunitx}

%--------------------------------------------------------------------------------------------
% ---- The following part is to align the units of right the equations: ---------------------
%--------------------------------------------------------------------------------------------

\makeatletter
}
\renewcommand\tagform@[1]{%
}
\makeatother

%--------------------------------------------------------------------------------------------
% ---- The following part is for equation legends including symbol, description and unit ----
%--------------------------------------------------------------------------------------------

\newenvironment{legend*}{%
\par\vspace{\abovedisplayskip}\noindent
\begingroup
\tabularx{\columnwidth}{
@{\hspace{3em}}
>{$$}l<{$$}
@{\hspace{2em}}
l
@{\hspace{2em}}
@{}
}\multicolumn{3}{@{\hspace{3em}}l@{}}{where}\\[1ex]
}%
{\endtabularx\par\vspace{2em}%
\par
\endgroup
}%

%--------------------------------------------------------------------------------------------
% ---- Document part ------------------------------------------------------------------------
%--------------------------------------------------------------------------------------------

\begin{document}

$$V = BC \addunit{\square\meter}$$

\begin{legend*}
V & Filter volume & \si{\cubic\meter}\\
B & Density of the filter & \si{\kilo\gram\per\cubic\meter}\\
C & Filter mass & \si{\kilo\gram}\\
\end{legend*}

\end{document}


• @Dave Fixed. I would not use this alignment, though; in the equation the unit should be next to the formula, say two quads from it; in the legend, just after the description. – egreg Dec 7 '18 at 13:20
• Thanks a lot for your help! You said "in the equation the unit should be next to the formula, [...]; in the legend, just after the description." Oh, is this a rule or just an opinion? :-) – Dave Dec 7 '18 at 13:25
• @Dave Personal opinion. Do as it is common in your field. – egreg Dec 7 '18 at 13:37
• Yes, when thinking about it - I think you are right! It is better to keep them close to each other. But something else makes me headache: Do you have an idea on how to auto-write the third table column always as \si{<column content>}? How can we add that to the modification? It would be nice, so in the text there is no need to write \si{<unit>} anymore, just <unit>... – Dave Dec 7 '18 at 13:58
• @Dave There's the s column type – egreg Dec 7 '18 at 14:05