From 25ea525d9bce6bd0b05b1fb78a1ba368a1fcf521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20St=C3=B6hr?= Date: Fri, 28 Oct 2011 18:28:28 +0000 Subject: [PATCH] backporting tex2lyx: the support for wrap floats git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40055 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/TODO.txt | 4 ---- src/tex2lyx/preamble.cpp | 3 +++ src/tex2lyx/text.cpp | 32 ++++++++++++++++++++++++++++++++ status.20x | 2 ++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index f05100558b..7e081ba3d8 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -26,15 +26,11 @@ Format LaTeX feature LyX feature 269 listings.sty (inline, with args) InsetListings 270 \alert, \structure (beamer) layout 281 ? modules -284 wrapfig.sty InsetWrap -287 wrapfig.sty (optarg) InsetWrap -290 wrapped tables InsetWrap 292 japanese japanese-plain 293 ? InsetInfo 309 \nocite InsetCitation 310 \nocite{*} InsetBibtex 316 subfig.sty (subfloats) InsetFloat -317 floating placements InsetWrap 322 ? local layout 325 japanese one japanese language 326 PDFLaTeX for external insets InsetExternal diff --git a/src/tex2lyx/preamble.cpp b/src/tex2lyx/preamble.cpp index 2f1f484a9d..4ce162df49 100644 --- a/src/tex2lyx/preamble.cpp +++ b/src/tex2lyx/preamble.cpp @@ -645,6 +645,9 @@ void handle_package(Parser &p, string const & name, string const & opts, else if (name == "rotfloat") ; // ignore this + else if (name == "wrapfig") + ; // ignore this + else if (is_known(name, known_languages)) h_language = name; diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 7409ae6db9..4edc2912f1 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1089,6 +1089,38 @@ void parse_environment(Parser & p, ostream & os, bool outer, p.skip_spaces(); } + else if (name == "wrapfigure" || name == "wraptable") { + // syntax is \begin{wrapfigure}[lines]{placement}[overhang]{width} + eat_whitespace(p, os, parent_context, false); + parent_context.check_layout(os); + // default values + string lines = "0"; + string overhang = "0col%"; + // parse + if (p.hasOpt()) + lines = p.getArg('[', ']'); + string const placement = p.getArg('{', '}'); + if (p.hasOpt()) + overhang = p.getArg('[', ']'); + string const width = p.getArg('{', '}'); + // write + if (name == "wrapfigure") + begin_inset(os, "Wrap figure\n"); + else + begin_inset(os, "Wrap table\n"); + os << "lines " << lines + << "\nplacement " << placement + << "\noverhang " << lyx::translate_len(overhang) + << "\nwidth " << lyx::translate_len(width) + << "\nstatus open\n\n"; + parse_text_in_inset(p, os, FLAG_END, outer, parent_context); + end_inset(os); + // We don't need really a new paragraph, but + // we must make sure that the next item gets a \begin_layout. + parent_context.new_paragraph(os); + p.skip_spaces(); + } + else if (name == "minipage") { eat_whitespace(p, os, parent_context, false); parse_box(p, os, 0, FLAG_END, outer, parent_context, "", "", name); diff --git a/status.20x b/status.20x index 133a4f577c..8c2cf19f83 100644 --- a/status.20x +++ b/status.20x @@ -61,6 +61,8 @@ What's new * Rotated floats (sidewaysfigure, sidewaystable). + * Wrapped floats (wrapfigure, wraptable) (bug 4378). + * Command \date{} in the preamble to suppress the date output.