]> git.lyx.org Git - features.git/commitdiff
tex2lyx: support width setting of \printnomenclature
authorUwe Stöhr <uwestoehr@web.de>
Tue, 25 Oct 2011 00:11:02 +0000 (00:11 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Tue, 25 Oct 2011 00:11:02 +0000 (00:11 +0000)
 (the tex2lyx support in branch for \printnomenclature is currently broken so this must be backported to branch for 2.0.2, OK Richard?)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39960 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/TODO.txt
src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index cf6b09429c02eeaf0f7c448f108916aaf660fea8..c24659e0b713788f35faf360b425f0b85498f81a 100644 (file)
@@ -55,8 +55,6 @@ Format LaTeX feature                        LyX feature
 354    \printindex*, \printsubindex*        InsetIndex
 358    custom bibtex command                \bibtex_command
 358    custom makeindex command             \index_command
-359    set_width                            InsetCommand nomencl_print
-360    width                                InsetCommand nomencl_print
 363    horizontal longtable alignment       InsetTabular
 364    branch file name suffix              \filename_suffix
 366    relative lengths for parskip         \defskip
index 5ffbc6e88dc05c62640b09b7256b1785a9a1db74..1dd90ad3e7b426cfe2da14df0e46739bb09e45dc 100644 (file)
@@ -379,6 +379,11 @@ with $a^2+b^2=c^2$ math}.
 
 \printindex{}
 
+\printnomenclature hello
+
+\settowidth{\nomlabelwidth}{URL2}
 \printnomenclature{}
 
+\printnomenclature[0.02\linewidth]{}
+
 \end{document}
index ce588869816d139bea186dd1b2399b4c7a381043..9870b57c07eed6fe3a931461a4c4b9031a53e4ab 100644 (file)
@@ -2702,8 +2702,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "printnomenclature") {
+                       string width = "";
+                       string width_type = "";
                        context.check_layout(os);
                        begin_command_inset(os, "nomencl_print", "printnomenclature");
+                       // case of a custom width
+                       if (p.hasOpt()) {
+                               width = p.getArg('[', ']');
+                               width = translate_len(width);
+                               width_type = "custom";
+                       }
+                       // case of no custom width
+                       // the case of no custom width but the width set
+                       // via \settowidth{\nomlabelwidth}{***} cannot be supported
+                       // because the user could have set anything, not only the width
+                       // of the longest label (which would be width_type = "auto")
+                       string label = convert_command_inset_arg(p.getArg('{', '}'));
+                       if (label.empty() && width_type.empty())
+                               width_type = "none";
+                       os << "set_width \"" << width_type << "\"\n";
+                       if (width_type == "custom")
+                               os << "width \"" << width << '\"';
                        end_inset(os);
                        skip_spaces_braces(p);
                }