From: Uwe Stöhr Date: Sun, 17 May 2015 23:37:59 +0000 (+0200) Subject: tex2lyx/text.cpp: support for lengths like "2.5\width" in boxes X-Git-Tag: 2.2.0alpha1~774 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=496dba453237d748dec05bc8d89a957f04c95bf1;p=features.git tex2lyx/text.cpp: support for lengths like "2.5\width" in boxes LyX supports these length in boxes for a while now; tex2lyx was not up to date --- diff --git a/src/tex2lyx/test/box-color-size-space-align.tex b/src/tex2lyx/test/box-color-size-space-align.tex index b004eedbbd..ccbf0cdad5 100644 --- a/src/tex2lyx/test/box-color-size-space-align.tex +++ b/src/tex2lyx/test/box-color-size-space-align.tex @@ -97,6 +97,10 @@ blabla \makebox[3cm]{makebox 2} blabla blabla \makebox[3cm][l]{makebox 3} blabla +\makebox[1\width]{www} + +\parbox[t][1\depth]{2.3cm}{www} + \begin{figure}[ht] \centering \setlength{\unitlength}{.2in} @@ -126,6 +130,8 @@ blabla \framebox[3cm]{framebox 2} blabla blabla \framebox[3cm][l]{framebox 3} blabla +\framebox[1.5\totalheight]{www} + This is an example text. % \framebox{% \begin{minipage}[c][1\totalheight][s]{0.2\columnwidth}% diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 9f1dd5d9b0..1178f3a01b 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -998,9 +998,8 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, if (!outer_type.empty() && !inner_type.empty() && (inner_flags & FLAG_END)) active_environments.push_back(inner_type); - // LyX can't handle length variables - bool use_ert = contains(width_unit, '\\') || contains(height_unit, '\\'); - if (!use_ert && !outer_type.empty() && !inner_type.empty()) { + bool use_ert = false; + if (!outer_type.empty() && !inner_type.empty()) { // Look whether there is some content after the end of the // inner box, but before the end of the outer box. // If yes, we need to output ERT. @@ -1130,10 +1129,20 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags, os << "use_makebox " << (inner_type == "makebox") << '\n'; if (outer_type == "fbox" || outer_type == "mbox") os << "width \"\"\n"; + // for values like "1.5\width" LyX uses "1.5in" as width ad sets "width" as sepecial + else if (contains(width_unit, '\\')) + os << "width \"" << width_value << "in" << "\"\n"; else os << "width \"" << width_value << width_unit << "\"\n"; - os << "special \"" << width_special << "\"\n"; - os << "height \"" << height_value << height_unit << "\"\n"; + if (contains(width_unit, '\\')) { + width_unit.erase (0,1); // remove the leading '\' + os << "special \"" << width_unit << "\"\n"; + } else + os << "special \"" << width_special << "\"\n"; + if (contains(height_unit, '\\')) + os << "height \"" << height_value << "in" << "\"\n"; + else + os << "height \"" << height_value << height_unit << "\"\n"; os << "height_special \"" << height_special << "\"\n"; os << "thickness \"" << thickness << "\"\n"; os << "separation \"" << separation << "\"\n";