]> git.lyx.org Git - features.git/commitdiff
tex2lyx/text.cpp: support for lengths like "2.5\width" in boxes
authorUwe Stöhr <uwestoehr@lyx.org>
Sun, 17 May 2015 23:37:59 +0000 (01:37 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Sun, 17 May 2015 23:37:59 +0000 (01:37 +0200)
LyX supports these length in boxes for a while now; tex2lyx was not up to date

src/tex2lyx/test/box-color-size-space-align.tex
src/tex2lyx/text.cpp

index b004eedbbddc7721f2e57f0556f93044cac1fd81..ccbf0cdad51f698e3d6abe9e0408ee7c8c02364c 100644 (file)
@@ -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}%
index 9f1dd5d9b0a564635e9473e8368eeb90772f333a..1178f3a01b27c686da06382aacf5df1714345d39 100644 (file)
@@ -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";