tex2lyx: support V table column type

This commit is contained in:
Juergen Spitzmueller 2018-08-27 12:12:56 +02:00
parent c480889077
commit 64ad077c9c
2 changed files with 22 additions and 4 deletions

View File

@ -34,8 +34,7 @@ Format LaTeX feature LyX feature
443 unicode-math.sty InsetMath* 443 unicode-math.sty InsetMath*
453 automatic stmaryrd loading \use_package stmaryrd 453 automatic stmaryrd loading \use_package stmaryrd
457 automatic stackrel loading \use_package stackrel 457 automatic stackrel loading \use_package stackrel
555 V column type (varwidth package) Automatically detected with newlines, paragraph breaks and environment content in cells of rows 563 InsetArgument listpreamble:1 All content between \begin{env} and first \item of a list
563 InsetArgument listpreamble:<nr> All content between \begin{env} and first \item of a list

View File

@ -39,7 +39,7 @@ namespace {
class ColInfo { class ColInfo {
public: public:
ColInfo() : align('n'), valign('n'), rightlines(0), leftlines(0), ColInfo() : align('n'), valign('n'), rightlines(0), leftlines(0),
varwidth(false), decimal_point('\0') {} varwidth(false), decimal_point('\0'), vcolumn(false) {}
/// column alignment /// column alignment
char align; char align;
/// vertical alignment /// vertical alignment
@ -56,6 +56,8 @@ public:
bool varwidth; bool varwidth;
/// decimal separator /// decimal separator
char decimal_point; char decimal_point;
/// V column type
bool vcolumn;
}; };
@ -298,7 +300,9 @@ void ci2special(ColInfo & ci)
ci.special += ">{\\centering" + arraybackslash + "}"; ci.special += ">{\\centering" + arraybackslash + "}";
break; break;
} }
if (ci.varwidth) if (ci.vcolumn)
ci.special += 'V';
else if (ci.varwidth)
ci.special += 'X'; ci.special += 'X';
else if (ci.valign == 'n') else if (ci.valign == 'n')
ci.special += 'p'; ci.special += 'p';
@ -384,6 +388,21 @@ void handle_colalign(Parser & p, vector<ColInfo> & colinfo,
colinfo.push_back(next); colinfo.push_back(next);
next = ColInfo(); next = ColInfo();
break; break;
case 'V': {
// V column type (varwidth package)
string const s = trimSpaceAndEol(p.verbatim_item());
// V{\linewidth} is treated as a normal column
// (which allows for line breaks). The V type is
// automatically set by LyX in this case
if (s != "\\linewidth" || !next.special.empty()) {
next.vcolumn = true;
next.width = s;
ci2special(next);
}
colinfo.push_back(next);
next = ColInfo();
break;
}
case 'p': case 'p':
case 'b': case 'b':
case 'm': case 'm':