tex2lyx: support for KOMA-script's \caption* commands

- To my knowledge tex2lyx supports now all caption constructs provided by LyX.
- InsetArgument is correct here, I therefore deleted the FIXME.
This commit is contained in:
Uwe Stöhr 2014-12-01 02:57:12 +01:00
parent 208e67c7a7
commit 7e69ac220d
2 changed files with 28 additions and 15 deletions

View File

@ -72,7 +72,6 @@ Format LaTeX feature LyX feature
\frametitle<overlay>[short}{long}
456 memoir: \epigraph{text}{source} layout Epigraph, InsetArgument
457 automatic stackrel loading \use_package stackrel
458 Extended InsetCaption syntax InsetCaption
459 beamer: \begin{frame}, \begin_layout Frame
\begin{frame}[plain], \begin_layout PlainFrame
\begin{frame}[fragile] \begin_layout FragileFrame

View File

@ -2828,7 +2828,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
preamble.registerAutomaticallyLoadedPackage(*it);
}
else if (t.cs() == "caption") {
else if (t.cs() == "caption" || t.cs() == "captionabove" ||
t.cs() == "captionbelow") {
bool starred = false;
if (p.next_token().asInput() == "*") {
p.get_token();
@ -2837,14 +2838,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
p.skip_spaces();
context.check_layout(os);
p.skip_spaces();
if (starred)
if (starred && t.cs() == "caption")
begin_inset(os, "Caption LongTableNoNumber\n");
else
else if (t.cs() == "caption")
begin_inset(os, "Caption Standard\n");
else if (t.cs() == "captionabove")
begin_inset(os, "Caption Above\n");
else if (t.cs() == "captionbelow")
begin_inset(os, "Caption Below\n");
Context newcontext(true, context.textclass, 0, 0, context.font);
newcontext.check_layout(os);
// FIXME InsetArgument is now properly implemented in InsetLayout
// (for captions, but also for others)
if (p.next_token().cat() != catEscape &&
p.next_token().character() == '[') {
p.get_token(); // eat '['
@ -3427,15 +3430,26 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
else if (is_known(t.cs(), known_phrases) ||
(t.cs() == "protect" &&
p.next_token().cat() == catEscape &&
is_known(p.next_token().cs(), known_phrases))) {
// LyX sometimes puts a \protect in front, so we have to ignore it
// FIXME: This needs to be changed when bug 4752 is fixed.
where = is_known(
t.cs() == "protect" ? p.get_token().cs() : t.cs(),
known_phrases);
context.check_layout(os);
os << known_coded_phrases[where - known_phrases];
skip_spaces_braces(p);
is_known(p.next_token().cs(), known_phrases)) ||
(t.cs() == "protect" &&
(p.next_token().cs() == "caption" ||
p.next_token().cs() == "captionabove" ||
p.next_token().cs() == "captionbelow"))) {
if (p.next_token().cs() == "caption" ||
p.next_token().cs() == "captionabove" ||
p.next_token().cs() == "captionbelow")
// we must ignore if \protect is in front of \caption*
;
else {
// LyX sometimes puts a \protect in front, so we have to ignore it
// FIXME: This needs to be changed when bug 4752 is fixed.
where = is_known(
t.cs() == "protect" ? p.get_token().cs() : t.cs(),
known_phrases);
context.check_layout(os);
os << known_coded_phrases[where - known_phrases];
skip_spaces_braces(p);
}
}
// handle refstyle first to catch \eqref which can also occur