[Tex/LaTex] Unable to use systeme for a system of equations with \ldots and non-numeric coefficients

equationssysteme

I just found in this answer: https://tex.stackexchange.com/a/35176/4011, that using the systeme package ist probably the best way to typeset a system of linear equations in LaTeX.

Now I tried to generate a general system of linear equations like in this approach but it doesn't work:

\documentclass{article}

\usepackage[active,tightpage]{preview}
\usepackage{systeme}

\begin{document}

\sysdelim..
\systeme{%
a_11 x_1 + a_12 x_2 + \dots + a_1m x_m = b_1, 
a_21 x_1 + a_22 x_2 + \dots + a_2m x_m = b_2, 
%%Here I should add some vertical and diagonal dots
a_n1 x_1 + a_n2 x_2 + \dots + a_nm x_m  = b_n
}%

\end{document}

Any idea how to make this work without making the syntax too complex?

Best Answer

The systeme package cannot work with non-numeric coefficients. But you can build your own macro to copy how systeme works.

\documentclass{article}
\usepackage{xstring}
\def\typesystem#1{%
    \begingroup\expandarg
    \baselineskip=1.5\baselineskip% 1.5 to enlarge vertical space between lines
    \StrSubstitute{\noexpand#1}+{&+&}[\tempsystem]%
    \StrSubstitute\tempsystem={&=&}[\tempsystem]%
    \StrSubstitute\tempsystem,{\noexpand\cr}[\tempsystem]%
    $\vcenter{\halign{&$\hfil\strut##$&${}##{}$\cr\tempsystem\crcr}}$%
    \endgroup
}
\begin{document}
my system : \typesystem{
a_{11} x_1 + a_{12} x_2 + \ldots + a_{1m} x_m = b_1,
a_{21} x_1 + a_{22} x_2 + \ldots + a_{2m} x_m = b_2,
\vdots\hfil&&           &&       &&\vdots\hfil= \vdots,
a_{n1} x_1 + a_{n2} x_2 + \ldots + a_{nm} x_m = b_m
}
\end{document}

enter image description here