diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 5ee9a922ac..f797b15476 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -26,9 +26,6 @@ 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 diff --git a/src/tex2lyx/preamble.cpp b/src/tex2lyx/preamble.cpp index 151efff4c9..7ba86a2430 100644 --- a/src/tex2lyx/preamble.cpp +++ b/src/tex2lyx/preamble.cpp @@ -651,6 +651,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/test/test-structure.tex b/src/tex2lyx/test/test-structure.tex index d71b5c3cd2..1f6402dd75 100644 --- a/src/tex2lyx/test/test-structure.tex +++ b/src/tex2lyx/test/test-structure.tex @@ -64,7 +64,7 @@ an unknown environment An environment \end{quote} -\section*{A starred section} +\section*{A starred section for floats} \begin{figure} \caption{ \emph{\noun{is}} a caption} @@ -88,17 +88,69 @@ d & c\tabularnewline \end{tabular} \end{sidewaystable*} +\begin{wrapfigure}[4]{L}[2ex]{0.5\columnwidth}% +\begin{centering} +fdgsdfdh +\par\end{centering} + +\caption{test1} +\end{wrapfigure}% +\LyX{} is a document preparation system. It excels at letting you +create complex technical and scientific articles with mathematics, +cross-references, bibliographies, indices, etc. It is very good at +documents of any length in which the usual processing abilities are +required: automatic sectioning and pagination, spell checking, and +so forth. It can also be used to write a letter to your mom, though +granted, there are probably simpler programs available for that. It +is definitely not the best tool for creating banners, flyers, or advertisements +(we'll explain why later), though with some effort all these can be +done, too. + +\begin{wrapfigure}{o}{0.5\columnwidth}% +\begin{centering} +fdgs +\par\end{centering} + +\caption{test2} +\end{wrapfigure}% +\LyX{} is a document preparation system. It excels at letting you +create complex technical and scientific articles with mathematics, +cross-references, bibliographies, indices, etc. It is very good at +documents of any length in which the usual processing abilities are +required: automatic sectioning and pagination, spell checking, and +so forth. It can also be used to write a letter to your mom, though +granted, there are probably simpler programs available for that. It +is definitely not the best tool for creating banners, flyers, or advertisements +(we'll explain why later), though with some effort all these can be +done, too. + +\begin{wraptable}{i}[0.05\textwidth]{5ex}% +\caption{fdg} + + +\centering{}dfgd\end{wraptable}% +\LyX{} is a document preparation system. It excels at letting you +create complex technical and scientific articles with mathematics, +cross-references, bibliographies, indices, etc. It is very good at +documents of any length in which the usual processing abilities are +required: automatic sectioning and pagination, spell checking, and +so forth. It can also be used to write a letter to your mom, though +granted, there are probably simpler programs available for that. It +is definitely not the best tool for creating banners, flyers, or advertisements +(we'll explain why later), though with some effort all these can be +done, too. + +\subsection{Some paragraph stuff} + A paragraph\footnote{hello} with a footnote and another one\footnote{hello -there} with several paragraphs - -some ERT \vspace{1cm} aa +there} with several paragraphs \vspace{1cm} aa and another paragraph \begin{center} -Some centered stuff (does not work) +Some centered stuff \end{center} \begin{quotation} diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 7a5565e25b..a2bd665c8f 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1094,6 +1094,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); @@ -2534,7 +2566,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, string const offset = (p.hasOpt() ? p.getArg('[', ']') : string()); string const width = p.getArg('{', '}'); string const thickness = p.getArg('{', '}'); - context.check_layout(os); begin_command_inset(os, "line", "rule"); if (!offset.empty())