From f441663600e0fedadc7cb46e0a6e4eba4abd8666 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 12 Nov 2011 17:54:50 +0000 Subject: [PATCH] tabular* git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40176 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/TODO.txt | 1 - src/tex2lyx/table.cpp | 8 +++++--- src/tex2lyx/test/test-insets.tex | 7 +++++++ src/tex2lyx/tex2lyx.1in | 2 -- src/tex2lyx/tex2lyx.h | 4 ++-- src/tex2lyx/text.cpp | 9 +++++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index d0ca661dfd..2e53ac9ad2 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -65,6 +65,5 @@ Format LaTeX feature LyX feature 407 vertical offset for multirows InsetTabular 409 XeTeX \use_non_tex_fonts 411 support for polyglossia \language_package (the cases of no package, of babel and of custom package is supported) -412 tabular* InsetTabular 415 undertilde.sty fonts diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index a16aeeb6a2..d23da08a73 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -770,9 +770,10 @@ void handle_hline_below(RowInfo & ri, vector & ci) } // anonymous namespace -void handle_tabular(Parser & p, ostream & os, bool is_long_tabular, - Context & context) +void handle_tabular(Parser & p, ostream & os, string const & name, + string const & tabularwidth, Context & context) { + bool const is_long_tabular(name == "longtable"); string tabularvalignment("middle"); string posopts = p.getOpt(); if (!posopts.empty()) { @@ -1114,7 +1115,8 @@ void handle_tabular(Parser & p, ostream & os, bool is_long_tabular, << write_attribute("rotate", false) << write_attribute("islongtable", is_long_tabular); if (!is_long_tabular) - os << write_attribute("tabularvalignment", tabularvalignment); + os << write_attribute("tabularvalignment", tabularvalignment) + << write_attribute("tabularwidth", tabularwidth); os << ">\n"; //cerr << "// after header\n"; diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index f6b09391cc..ffeb426865 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -258,6 +258,13 @@ Lots of lines& like this.\\ Lots of lines& like this. \end{longtable} +\begin{tabular*} % some comment +{0.8\columnwidth}[b]{lr} +two\\ +lonely&lines +\end{tabular*} + + \section{Macros} LyX supports several kinds of macros: diff --git a/src/tex2lyx/tex2lyx.1in b/src/tex2lyx/tex2lyx.1in index 316ec0ce20..028f10c906 100644 --- a/src/tex2lyx/tex2lyx.1in +++ b/src/tex2lyx/tex2lyx.1in @@ -206,8 +206,6 @@ should thus be conserved in printed documents, although it will not of course show up in the LyX window. Check Document->Settings->LaTeX Preamble to see the result. .SS "What tex2lyx Can't Handle --- But it's \s-1OK\s0" .IP "\(bu" 4 -tabular* tables -.IP "\(bu" 4 some spacing commands (\f(CW\ehspace\fR, \f(CW\epagebreak\fR and \f(CW\elinebreak\fR) .IP "\(bu" 4 \f(CW\ecentering\fR, \f(CW\eraggedleft\fR, \f(CW\eraggedright\fR diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h index 76ebee69d9..e1d779a115 100644 --- a/src/tex2lyx/tex2lyx.h +++ b/src/tex2lyx/tex2lyx.h @@ -71,8 +71,8 @@ void parse_math(Parser & p, std::ostream & os, unsigned flags, mode_type mode); /// in table.cpp -void handle_tabular(Parser & p, std::ostream & os, bool is_long_tabular, - Context & context); +void handle_tabular(Parser & p, std::ostream & os, std::string const & name, + std::string const & width, Context & context); /// in tex2lyx.cpp diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 33bd530bb0..9aec03e949 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1152,11 +1152,16 @@ void parse_environment(Parser & p, ostream & os, bool outer, end_inset(os); } - else if (name == "tabular" || name == "longtable") { + else if (unstarred_name == "tabular" || name == "longtable") { eat_whitespace(p, os, parent_context, false); + string width = "0pt"; + if (name == "tabular*") { + width = lyx::translate_len(p.getArg('{', '}')); + eat_whitespace(p, os, parent_context, false); + } parent_context.check_layout(os); begin_inset(os, "Tabular "); - handle_tabular(p, os, name == "longtable", parent_context); + handle_tabular(p, os, name, width, parent_context); end_inset(os); p.skip_spaces(); }