]> git.lyx.org Git - features.git/commitdiff
tex2lyx: support for wrapped floats and all their possible options
authorUwe Stöhr <uwestoehr@web.de>
Wed, 26 Oct 2011 20:53:18 +0000 (20:53 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Wed, 26 Oct 2011 20:53:18 +0000 (20:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40020 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/TODO.txt
src/tex2lyx/preamble.cpp
src/tex2lyx/test/test-structure.tex
src/tex2lyx/text.cpp

index 5ee9a922ac294cd09431fcb475437247b7484ef9..f797b15476491813061610915e256f966ba9e7da 100644 (file)
@@ -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
index 151efff4c9f29af2b1883841564cc21b5a565cf0..7ba86a243032885d2e75642af0664903eac25ae3 100644 (file)
@@ -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;
 
index d71b5c3cd250ce69d5c8da6e40ac07e627a3dc72..1f6402dd751d0495cd5ced03f5fcd7c9d50caf1d 100644 (file)
@@ -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}
index 7a5565e25b72cf547cd6d7f08710be1116776a01..a2bd665c8f6c6ae4a52f58b4cbf0e168fe093da0 100644 (file)
@@ -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())