From: Uwe Stöhr Date: Mon, 1 Dec 2014 01:57:12 +0000 (+0100) Subject: tex2lyx: support for KOMA-script's \caption* commands X-Git-Tag: 2.2.0alpha1~1492 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7e69ac220dd;p=features.git 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. --- diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index eb599bc45d..511927052b 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -72,7 +72,6 @@ Format LaTeX feature LyX feature \frametitle[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 diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 7c72b64404..3f9446afcf 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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