\ProvidesPackage{eqexpl}[2018/11/11 v.1]
\RequirePackage{etoolbox}
\RequirePackage{calc}

%% Spaces between elements
\newlength{\eqexplSpaceWidth}
\newcommand{\eqexplSetSpace}[1]{%
  \setlength{\eqexplSpaceWidth}{\ifstrempty{#1}{2mm}{#1}}%
}
\eqexplSetSpace{}

%% Width of 'intro' (typ. 'where')
\newcommand{\eqexplSetIntro}[1]{%
  \def\eqexplIntro{#1}%
}
\eqexplSetIntro{}

%% Width of delimiter
\newcommand{\eqexplSetDelim}[1]{%
  \def\eqexplDelim{#1}%
}
\eqexplSetDelim{---}

%% Width of item
\newcommand{\eqexplSetItemWidth}[1]{%
  \def\eqexplItemWidth{#1}%
}
\eqexplSetItemWidth{5mm}

%% Align of item
\newcommand{\eqexplSetItemAlign}[1]{%
  \def\eqexplItemAlign{#1}%
}
\eqexplSetItemAlign{r}

\newlength{\itemWidth}
\newlength{\leftSideWidth}

\newenvironment{eqexpl}[1][\eqexplItemWidth]{%
  \let\olditem\item%
  \setlength{\itemWidth}{#1}%
  \setlength{\leftSideWidth}{\ifdefempty{\eqexplIntro}{}{\widthof{\eqexplIntro}+%
                             \eqexplSpaceWidth+}%
                             \itemWidth+%
                             \eqexplSpaceWidth+%
                             \widthof{\eqexplDelim}+%
                             \eqexplSpaceWidth}%
  \newtoggle{eqexplFirstItem}%
  \toggletrue{eqexplFirstItem}%
  \renewcommand{\item}[1]{%
    \olditem \makebox[\leftSideWidth]{%
      \ifdefempty{\eqexplIntro}{}{
        \makebox[\widthof{\eqexplIntro}][l]{\iftoggle{eqexplFirstItem}{\eqexplIntro}{}}%
        \hspace{\eqexplSpaceWidth}%
      }
      \makebox[\itemWidth][\eqexplItemAlign]{##1}%
      \hspace{\eqexplSpaceWidth}%
      \makebox[\widthof{\eqexplDelim}][c]{\eqexplDelim}%
      \hspace{\eqexplSpaceWidth}%
    }%
    \togglefalse{eqexplFirstItem}%
    \ignorespaces% https://tex.stackexchange.com/a/44062
  }%
  \begin{list}{}{\setlength{\parsep}{0pt}%
  \setlength{\topsep}{0pt}%
  \setlength{\itemsep}{0pt}%
  \setlength{\labelsep}{0pt}%
  \setlength{\leftmargin}{\leftSideWidth}%
  \setlength{\itemindent}{-\leftSideWidth}}}{%
  \end{list}
}
\endinput
