[Tex/LaTex] In horizontally aligned minipages, how can I force the last minipage width to extend to the right margin

geometryhorizontal alignmentmarginsminipagetextwidth

I need to use minipage environment to give side by side descriptions of equations. The minipages themselves must be separated by equal distance, which is in this case a quad. However, it would not be clear in such case what the last minipage would be. I want the width of the last minipage to be determined automatically so that its contents will stretch all the way until the allowable margin for text.

A sample pics are shown here. The original output:

enter image description here

Desired output:

enter image description here

The output above is obtained by fine-tuning the width of the last minipage, but if the margins were adjusted here, the minipage will either be too big to fit with other minipages or it will not extend until it reaches the margins.For this case, I can get the desired output with 0.43\textwidth, but I want LaTeX to automatically detect and specify the width of the final minipage.

I know that this issue was addressed here: minipage that fills space to right margin by using the command \dimexpr \textwidth-\wd0-\columnsep to specify text width of the last minipage, but the solution does not seem to work for my particular content. The output after including this command:

enter image description here

My source code:

\documentclass[]{book}
\usepackage{amsmath}
\usepackage{mathtools}

\usepackage[showframe]{geometry}


\begin{document}


    \noindent You can use multiple \texttt{minipage} environments for side-by-side descriptions:
    \begin{center}
        \begin{minipage}{0.25\textwidth}
            \vspace{-\baselineskip}
            \begin{align}
            f_1 &= a + b &\\
            f_2 &= a - b &
            \end{align}
        \end{minipage}
    \quad
        $\begin{array}{c @{\medspace}c @{\medspace}l}
            a &= &\text{Some one line text}\\
            b &= &\text{Some two line text}\\
            & &\text{The second line}
        \end{array}$
    \quad
        \begin{minipage}{0.3\textwidth}
            This is detailed description of the equation. Note how the two equations are both centered with respect to what is mentioned here. Such code could be so useful to give comments for tutorials and the like. 
        \end{minipage}

    \end{center}



\end{document}

Best Answer

You can make tabularx calculate the last width automatically for you.

\documentclass[]{book}
\usepackage{amsmath}
\usepackage{mathtools,tabularx}
\usepackage[showframe]{geometry}

\begin{document}

\noindent%
\begin{tabularx}{\linewidth}{@{} *2{>{\hsize=.5\hsize}X} X@{}}
\begin{align}
  f_1 = a + b \\
  f_2 = a - b 
\end{align}
&
\begin{equation*}
\begin{aligned}
 a ={} &\text{Some one line text}\\
 b ={} &\text{Some two line text}\\
       &\text{The second line}
\end{aligned}
\end{equation*}
&
This is detailed description of the equation. Note how the two equations are both centered with respect to what is mentioned here. Such code could be so useful to give comments for tutorials and the like.
\end{tabularx}

\end{document}

enter image description here