Uwe Stöhr wrote:
> > It looks like someone spent some effort not to output &'s if they are
> > not necessary.

André: http://www.lyx.org/trac/changeset/5004

> > Why would it be more correct to output all &'s ? Isn't it
> > much cleaner not to output them ?
>
> It is not clean and even wrong. That we not output the column separators
> causes the bug we have. Equations are in general arrays that have for every
> row the same number of columns. What we currently output is an array where
> one row doesn't have any column and this is wrong.

As I understand it, '&' only indicates a column jump, it does not define the 
number of columns, so it's not mandatory if cells don't need to be accessed.
Thus
        \begin{tabular}{ccc}
        a & b & c\tabularnewline
          &   &  \tabularnewline
        d & e & \tabularnewline
        \end{tabular}
and
        \begin{tabular}{ccc}
        a & b & c\tabularnewline
        \tabularnewline
        d & e \tabularnewline
        \end{tabular}
or
        \begin{array}{ccc}
        1 & 2 & 3 \\
          &   &   \\
        4 & 5 &
        \end{array}
and
        \begin{array}{ccc}
        1 & 2 & 3 \\
        \\
        4 & 5
        \end{array}
are equal.

IMHO (but I'm not a math user) it's just a matter of style whether the '&' are 
output or not in the given cases. I've looked into some math manuals (such as 
http://tug.ctan.org/get/info/math/voss/mathmode/Mathmode.pdf), and omitting 
the '&' seems frequent practice.

However, I think our current LaTeX output can be improved anyway. I think new 
rows should always be started on a new line. I.e.,
        \begin{align*}
        a & = & b & = & c\\
        \\
        x & = & y & = & z\end{align*}
not
        \begin{align*}
        a & = & b & = & c\\
        \\x & = & y & = & z\end{align*}

As to the proposed patch, I'd like to hear the opinion of math users. In any 
case

+               return " & " + eol;

should be

+               return from_ascii(" & ") + eol;

There are some other cases in InsetMathGrid, where conversion from string to 
docstring is missing.

Jürgen

Reply via email to