Attached is a patch for tex2lyx to go into branch for LyX 2.1.3. It add
missing support of tex2lyx for:
- \nameref (textual references in LyX)
- Iwona and Kurier math fonts
- bibtopic
OK to go in?
regards Uwe
src/tex2lyx/Preamble.cpp | 11 +++++++++++
src/tex2lyx/TODO.txt | 4 ----
src/tex2lyx/test/test-insets.lyx.lyx | 12 ++++++++++++
src/tex2lyx/test/test-insets.tex | 3 ++-
src/tex2lyx/text.cpp | 35 +++++++++++++++++++++++++++++++++--
5 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index c87b766..f138348 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -768,6 +768,14 @@ void Preamble::handle_package(Parser &p, string const &
name,
h_font_math = "minion-ntxm";
}
+ if (name == "iwona")
+ if (opts == "math")
+ h_font_math = "iwona-math";
+
+ if (name == "kurier")
+ if (opts == "math")
+ h_font_math = "kurier-math";
+
// after the detection and handling of special cases, we can remove the
// fonts, otherwise they would appear in the preamble, see bug #7856
if (is_known(name, known_roman_fonts) || is_known(name,
known_sans_fonts)
@@ -958,6 +966,9 @@ void Preamble::handle_package(Parser &p, string const &
name,
h_cite_engine_type = "authoryear";
}
+ else if (name == "bibtopic")
+ h_use_bibtopic = "true";
+
else if (name == "hyperref")
handle_hyperref(options);
diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index 17979db..afd7ce4 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -18,7 +18,6 @@ Format LaTeX feature LyX feature
226 nothing (impossible to import) InsetBranch, \branch...\end_branch
226 transformations InsetExternal
228 draft InsetExternal
-232 bibtopic InsetBibTeX
254 esint.sty \use_esint
267 XeTeX utf8 encoding
270 \alert, \structure (beamer) layout
@@ -46,7 +45,6 @@ Format LaTeX feature LyX feature
390 forward/reverse search \forward_search, \forward_macro
391 decimal alignment in tables InsetTabular
392 new beamer format InsetLayout
-396 nameref.sty InsetRef
399 automatic mathdots loading \use_mathdots
407 vertical offset for multirows InsetTabular
411 support for polyglossia \language_package (the cases of
no package, of babel and of custom package is supported)
@@ -80,7 +78,6 @@ Format LaTeX feature LyX feature
459 beamer: \begin{frame}, \begin_layout Frame
\begin{frame}[plain], \begin_layout PlainFrame
\begin{frame}[fragile] \begin_layout FragileFrame
-461 support for kurier math font (the other kurier fonts are already
supported)
462 New libertine LaTeX fonts:
\usepackage[scale|scaled|ttscale=$val]{libertineMono-type1}
\font_typewriter
@@ -96,7 +93,6 @@ Format LaTeX feature LyX feature
\twocolumn[]{}{} Layout Twocolumn, InsetArgument
\item[]<> InsetArgument
\begin{enumerate|itemize|...}[] InsetArgument
-467 support for iwona math font (the other iwona fonts are already supported)
General
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx
b/src/tex2lyx/test/test-insets.lyx.lyx
index a90bec9..25f372b 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -252,6 +252,18 @@ reference "lab:test"
\end_inset
+ as well as textual references like
+\begin_inset space ~
+
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand nameref
+reference "lab:test"
+
+\end_inset
+
. The command
\begin_inset ERT
status collapsed
diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex
index 5009086..5fd3930 100644
--- a/src/tex2lyx/test/test-insets.tex
+++ b/src/tex2lyx/test/test-insets.tex
@@ -86,7 +86,8 @@ Of course there are other kind of references, like page
reference~\pageref{lab:test}, but also equation
reference~\eqref{lab:test} (from amsmath package), or varioref's
equivalents~\vref{lab:test} and~\vpageref{lab:test}, without
-forgetting pretty references like~\prettyref{lab:test}.
+forgetting pretty references like~\prettyref{lab:test} as well as textual
+references like~\nameref{lab:test}.
The command \secref{lab:test} will be parsed in ERT, since LyX
does not support refstyle and prettyref natively at the same time.
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index e5b7209..6f88d8e 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -112,10 +112,10 @@ string parse_text_snippet(Parser & p, unsigned flags,
const bool outer,
char const * const known_ref_commands[] = { "ref", "pageref", "vref",
- "vpageref", "prettyref", "eqref", 0 };
+ "vpageref", "prettyref", "nameref", "eqref", 0 };
char const * const known_coded_ref_commands[] = { "ref", "pageref", "vref",
- "vpageref", "formatted", "eqref", 0 };
+ "vpageref", "formatted", "nameref", "eqref", 0 };
char const * const known_refstyle_commands[] = { "algref", "chapref", "corref",
"eqref", "enuref", "figref", "fnref", "lemref", "parref", "partref",
"propref",
@@ -1525,6 +1525,37 @@ void parse_environment(Parser & p, ostream & os, bool
outer,
preamble.registerAutomaticallyLoadedPackage("color");
}
+ else if (name == "btSect") {
+ eat_whitespace(p, os, parent_context, false);
+ parent_context.check_layout(os);
+ begin_command_inset(os, "bibtex", "bibtex");
+ string bibstyle = "plain";
+ if (p.hasOpt()) {
+ bibstyle = p.getArg('[', ']');
+ p.skip_spaces(true);
+ }
+ string const bibfile = p.getArg('{', '}');
+ eat_whitespace(p, os, parent_context, false);
+ Token t = p.get_token();
+ if (t.asInput() == "\\btPrintCited") {
+ p.skip_spaces(true);
+ os << "btprint " << '"' << "btPrintCited" << '"' <<
"\n";
+ }
+ if (t.asInput() == "\\btPrintNotCited") {
+ p.skip_spaces(true);
+ os << "btprint " << '"' << "btPrintNotCited" << '"' <<
"\n";
+ }
+ if (t.asInput() == "\\btPrintAll") {
+ p.skip_spaces(true);
+ os << "btprint " << '"' << "btPrintAll" << '"' << "\n";
+ }
+ os << "bibfiles " << '"' << bibfile << '"' << "\n";
+ os << "options " << '"' << bibstyle << '"' << "\n";
+ parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
+ end_inset(os);
+ p.skip_spaces();
+ }
+
else if (name == "framed" || name == "shaded") {
eat_whitespace(p, os, parent_context, false);
parse_outer_box(p, os, FLAG_END, outer, parent_context, name,
"");