tex2lyx: support for wrapped floats and all their possible options

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40020 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2011-10-26 20:53:18 +00:00
parent f397989137
commit 3d1cace2bc
4 changed files with 92 additions and 9 deletions

View File

@ -26,9 +26,6 @@ Format LaTeX feature LyX feature
269 listings.sty (inline, with args) InsetListings 269 listings.sty (inline, with args) InsetListings
270 \alert, \structure (beamer) layout 270 \alert, \structure (beamer) layout
281 ? modules 281 ? modules
284 wrapfig.sty InsetWrap
287 wrapfig.sty (optarg) InsetWrap
290 wrapped tables InsetWrap
292 japanese japanese-plain 292 japanese japanese-plain
293 ? InsetInfo 293 ? InsetInfo
309 \nocite InsetCitation 309 \nocite InsetCitation

View File

@ -651,6 +651,9 @@ void handle_package(Parser &p, string const & name, string const & opts,
else if (name == "rotfloat") else if (name == "rotfloat")
; // ignore this ; // ignore this
else if (name == "wrapfig")
; // ignore this
else if (is_known(name, known_languages)) else if (is_known(name, known_languages))
h_language = name; h_language = name;

View File

@ -64,7 +64,7 @@ an unknown environment
An environment An environment
\end{quote} \end{quote}
\section*{A starred section} \section*{A starred section for floats}
\begin{figure} \begin{figure}
\caption{ \emph{\noun{is}} a caption} \caption{ \emph{\noun{is}} a caption}
@ -88,17 +88,69 @@ d & c\tabularnewline
\end{tabular} \end{tabular}
\end{sidewaystable*} \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 A paragraph\footnote{hello} with a footnote and another
one\footnote{hello one\footnote{hello
there} with several paragraphs there} with several paragraphs \vspace{1cm} aa
some ERT \vspace{1cm} aa
and another paragraph and another paragraph
\begin{center} \begin{center}
Some centered stuff (does not work) Some centered stuff
\end{center} \end{center}
\begin{quotation} \begin{quotation}

View File

@ -1094,6 +1094,38 @@ void parse_environment(Parser & p, ostream & os, bool outer,
p.skip_spaces(); 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") { else if (name == "minipage") {
eat_whitespace(p, os, parent_context, false); eat_whitespace(p, os, parent_context, false);
parse_box(p, os, 0, FLAG_END, outer, parent_context, "", "", name); 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 offset = (p.hasOpt() ? p.getArg('[', ']') : string());
string const width = p.getArg('{', '}'); string const width = p.getArg('{', '}');
string const thickness = p.getArg('{', '}'); string const thickness = p.getArg('{', '}');
context.check_layout(os); context.check_layout(os);
begin_command_inset(os, "line", "rule"); begin_command_inset(os, "line", "rule");
if (!offset.empty()) if (!offset.empty())