mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix data loss with [ in first cell of aligned
If the first character in the first cell of an aligned math environment is '[', and the environment does not use top or bottom vertical alignment, then LyX did write the '[' unprotected so that it got misinterpreted as optional argument, both when reading the .lyx file in LyX and when reading the .tex file in LaTeX => data loss! The fix is to output an empty optional argument in this case, which is interpreted as default alignment both by LyX and LaTeX. It would also be possible to output \[ in the first cell instead, but this would be more difficult to implement.
This commit is contained in:
parent
a931e84e8b
commit
a6be519a81
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "MathData.h"
|
#include "MathData.h"
|
||||||
#include "MathStream.h"
|
#include "MathStream.h"
|
||||||
#include "MathStream.h"
|
#include "MathSupport.h"
|
||||||
|
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
@ -141,9 +141,19 @@ void InsetMathSplit::write(WriteStream & ws) const
|
|||||||
suffix = from_ascii("*");
|
suffix = from_ascii("*");
|
||||||
ws << "\\begin{" << name_ << suffix << '}';
|
ws << "\\begin{" << name_ << suffix << '}';
|
||||||
bool open = ws.startOuterRow();
|
bool open = ws.startOuterRow();
|
||||||
if (name_ != "split" && name_ != "align" && verticalAlignment() != 'c')
|
bool const hasArg(name_ == "alignedat");
|
||||||
ws << '[' << verticalAlignment() << ']';
|
if (name_ != "split" && name_ != "align") {
|
||||||
if (name_ == "alignedat")
|
if (verticalAlignment() != 'c')
|
||||||
|
ws << '[' << verticalAlignment() << ']';
|
||||||
|
else if (!hasArg) {
|
||||||
|
docstring const first(asString(cell(0)));
|
||||||
|
// prevent misinterpretation of the first character of
|
||||||
|
// the first cell as optional argument (bug 10361)
|
||||||
|
if (!first.empty() && first[0] == '[')
|
||||||
|
ws << "[]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasArg)
|
||||||
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
||||||
InsetMathGrid::write(ws);
|
InsetMathGrid::write(ws);
|
||||||
if (ws.fragile())
|
if (ws.fragile())
|
||||||
|
Loading…
Reference in New Issue
Block a user