]> git.lyx.org Git - features.git/commitdiff
tex2lyx: backport support for relative sizes and glue lengths
authorUwe Stöhr <uwestoehr@lyx.org>
Wed, 3 Dec 2014 23:48:27 +0000 (00:48 +0100)
committerUwe Stöhr <uwestoehr@lyx.org>
Wed, 3 Dec 2014 23:48:27 +0000 (00:48 +0100)
src/tex2lyx/TODO.txt
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/test/box-color-size-space-align.tex
src/tex2lyx/text.cpp
status.21x

index f7118e11e25186e9f90a7e8d789bf91167b41ef0..eb599bc45d2294a67b396f605a173b182a642c9a 100644 (file)
@@ -36,8 +36,6 @@ Format LaTeX feature                        LyX feature
 358    custom makeindex command             \index_command
 363    horizontal longtable alignment       InsetTabular
 364    branch file name suffix              \filename_suffix
-367    relative lengths for h and v space   InsetSpace, InsetVSpace
-368    glue lengths                         InsetSpace
 371    automatic mhchem loading             \use_mhchem
 375    \includeonly                         \{begin,end}_includeonly
 376    update .aux of unincluded children   \maintain_unincluded_children
index c09701a262c37a396f964b01b8e734d23daf3898..5645b5b9c535e4f56a254179b7af858e2112707b 100644 (file)
@@ -1694,9 +1694,19 @@ in the middle. Lines can have a downbrace fill
 
 \end_inset
 
-in the middle. Lines can have space 
+in the middle. Lines can have an absolute space 
 \begin_inset space \hspace{}
 \length 2cm
+\end_inset
+
+ in the middle. Lines can have a relative space 
+\begin_inset space \hspace{}
+\length 12text%
+\end_inset
+
+ in the middle. Lines can have a glue-length space 
+\begin_inset space \hspace{}
+\length 2cm+2mm-1mm
 \end_inset
 
  in the middle. Lines can have protected space 
@@ -2006,8 +2016,16 @@ in the middle. Lines can have a vfill
 \begin_inset VSpace vfill*
 \end_inset
 
- in the middle. Lines can have vertical space 
+ in the middle. Lines can have a vertical absolute space 
 \begin_inset VSpace 2cm
+\end_inset
+
+ in the middle. Lines can have a vertical relative space 
+\begin_inset VSpace 9col%
+\end_inset
+
+ in the middle. Lines can have a vertical glue-length space 
+\begin_inset VSpace 2cm-2bp+1cc
 \end_inset
 
  in the middle. Lines can have protected vertical space 
index e0428fdf7937aa21c5adc7cd088c701863d4e76d..7bff4bd4abcc43a89ace0f30514ee1f3908f3c73 100644 (file)
@@ -357,7 +357,9 @@ Lines can have a left arrow fill \leftarrowfill in the middle.
 Lines can have a right arrow fill \rightarrowfill in the middle.
 Lines can have a upbrace fill \upbracefill in the middle.
 Lines can have a downbrace fill \downbracefill in the middle.
-Lines can have space \hspace{2cm} in the middle.
+Lines can have an absolute space \hspace{2cm} in the middle.
+Lines can have a relative space \hspace{0.12\textwidth} in the middle.
+Lines can have a glue-length space \hspace{2cm plus 2mm minus 1mm} in the middle.
 Lines can have protected space \hspace*{2cm} in the middle.
 
 We also handle defined spaces:
@@ -421,7 +423,9 @@ interword: $a\ b$
 Lines can have a vfill \vfill in the middle.
 Lines can have a vfill \vspace{\fill} in the middle.
 Lines can have a protected vfill \vspace*{\fill} in the middle.
-Lines can have vertical space \vspace{2cm} in the middle.
+Lines can have a vertical absolute space \vspace{2cm} in the middle.
+Lines can have a vertical relative space \vspace{0.09\columnwidth} in the middle.
+Lines can have a vertical glue-length space \vspace{2cm minus 2bp plus 1cc} in the middle.
 Lines can have protected vertical space \vspace*{2cm} in the middle.
 
 We also handle skips:
index fceeb928e5e4195d0d3d2e5e9f1447d3109f6cde..5657d95b61fccbd8c781ed4c71d80581734e59e2 100644 (file)
@@ -4406,13 +4406,41 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                        case Length::MU:
                                                known_unit = true;
                                                break;
-                                       default:
+                                       default: {
+                                               //unitFromString(unit) fails for relative units like Length::PCW
+                                               // therefore handle them separately
+                                               if (unit == "\\paperwidth" || unit == "\\columnwidth"
+                                                       || unit == "\\textwidth" || unit == "\\linewidth"
+                                                       || unit == "\\textheight" || unit == "\\paperheight")
+                                                       known_unit = true;
                                                break;
+                                                        }
                                        }
                                }
                        }
 
-                       if (t.cs()[0] == 'h' && (known_unit || known_hspace)) {
+                       // check for glue lengths
+                       bool is_gluelength = false;
+                       string gluelength = length;
+                       string::size_type i = length.find(" minus");
+                       if (i == string::npos) {
+                               i = length.find(" plus");
+                               if (i != string::npos)
+                                       is_gluelength = true;
+                       } else
+                               is_gluelength = true;
+                       // if yes transform "9xx minus 8yy plus 7zz"
+                       // to "9xx-8yy+7zz"
+                       if (is_gluelength) {
+                               i = gluelength.find(" minus");
+                               if (i != string::npos)
+                                       gluelength.replace(i, 7, "-");
+                               i = gluelength.find(" plus");
+                               if (i != string::npos)
+                                       gluelength.replace(i, 6, "+");
+                       }
+
+                       if (t.cs()[0] == 'h' && (known_unit || known_hspace || is_gluelength)) {
                                // Literal horizontal length or known variable
                                context.check_layout(os);
                                begin_inset(os, "space ");
@@ -4424,16 +4452,20 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                        os << unit;
                                os << "}";
                                if (known_unit && !known_hspace)
-                                       os << "\n\\length "
-                                          << translate_len(length);
+                                       os << "\n\\length " << translate_len(length);
+                               if (is_gluelength)
+                                       os << "\n\\length " << gluelength;
                                end_inset(os);
-                       } else if (known_unit || known_vspace) {
+                       } else if (known_unit || known_vspace || is_gluelength) {
                                // Literal vertical length or known variable
                                context.check_layout(os);
                                begin_inset(os, "VSpace ");
-                               if (known_unit)
-                                       os << value;
-                               os << unit;
+                               if (known_vspace)
+                                       os << unit;
+                               if (known_unit && !known_vspace)
+                                       os << translate_len(length);
+                               if (is_gluelength)
+                                       os << gluelength;
                                if (starred)
                                        os << '*';
                                end_inset(os);
index 5ae673d3eba35ef4a01a89e715e2fbd373864b42..d227a41188ed17fcbbf5ad4129e8cd1c91521085 100644 (file)
@@ -49,7 +49,11 @@ What's new
 
 - Support for the Libertine fonts.
 
-- Support for relative lengths in  the paragraph separation setting. 
+- Support for relative lengths in  the paragraph separation setting.
+
+- Support for relative lengths in horizontal and vertical spaces.
+
+- Support for glue length in horizontal and vertical spaces.
 
 
 * USER INTERFACE