Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I just found in this answer: http://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?

share|improve this question
    
Creating a new package-specific tag is good practice; I added a fitting general tag to attract more attention from potential answerers. –  lockstep Feb 16 at 12:44
    
the package documentation (texdoc systeme) shows no examples using dots either vertically or horizontally, and the string dot isn't present in the documentation. i think the package may not cover this situation, but can't be sure because the documentation is in french, and i'm sure i'm missing some of the important points. –  barbara beeton Feb 16 at 15:08
    
@barbarabeeton Yes, you might be right. But then I wonder that it is such highly voted in the other question: tex.stackexchange.com/questions/35174/… as the best solution to such a basic task... –  student Feb 16 at 15:11
    
the package looks very nice for what it handles. i haven't looked at the code, but think it might be worth writing to the author (name and e-mail address in the documentation) to ask for a possible extension. –  barbara beeton Feb 16 at 15:20

2 Answers 2

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

share|improve this answer
    
Thanks. For future readers: Replace \left\{ in the line before \endgroup by \left. to get rid of the curly brace (as setting \sysdelim in my question would do). –  student Feb 16 at 15:28
    
There is a problem with the alignment of the vdots after the = sign. Is there a way to solve it? –  Bernard Feb 16 at 16:13
    
as well as the vdots being too far to the right, the *b*s on the right-hand side aren't aligned. it appears that the whole last column is aligned at the right. –  barbara beeton Feb 16 at 16:28
    
@Bernard: Yes, replace \noexpand\ by hfil. –  unbonpetit Feb 16 at 16:50

I think this should help you:

\documentclass[12pt]{article}
\usepackage{systeme,mathtools}
\begin{document}

\sysdelim.
\systeme{
\noindent 
$ 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\\
a_{n1} x_1 + a_{n2} x_2 + \ldots + a_{nm} x_m = b_m
$
}
\end{document}

enter image description here

share|improve this answer
    
I got this compiled in shareLaTeX and posted the answer.. –  subham soni Feb 16 at 14:12
    
the blank line between \systeme{ and its closing brace will trigger the "paragraph ended" error. tex requires that math expressions be complete with no paragraph breaks. and according to the package documentation (texdoc systeme; it's in french), no double backslashes are used at the ends of lines, only commas. unfortunately, i can 't help with the other problems. –  barbara beeton Feb 16 at 14:59
    
@student , I have modified the code. It works now. I have used TeXLive 2013 and TeXMaker –  subham soni Feb 16 at 15:14
    
Thanks. Now it works for me too. Is it also possible to get the vertical dots such as in unbonpetit's answer? By the way it should be b_n and not b_m. –  student Feb 16 at 15:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.