]> git.lyx.org Git - lyx.git/commitdiff
tex2lyx: refsection and bibbysection support (biblatex)
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 4 Mar 2018 16:29:59 +0000 (17:29 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 4 Mar 2018 16:29:59 +0000 (17:29 +0100)
src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/TODO.txt
src/tex2lyx/text.cpp

index 48c0033a62a2d20165435a2cf4db5556df2b3209..cd8b5143a024ce5b8234c4429492fb484b39128e 100644 (file)
@@ -1073,6 +1073,16 @@ void Preamble::handle_package(Parser &p, string const & name,
                        if (!opt.empty())
                                h_biblatex_bibstyle = opt;
                }
+               opt = process_keyval_opt(options, "refsection");
+               if (!opt.empty()) {
+                       if (opt == "none" || opt == "part"
+                           || opt == "chapter" || opt == "section"
+                           || opt == "subsection")
+                               h_multibib = opt;
+                       else
+                               cerr << "Ignoring unkown refesection value '"
+                                    << opt << "'.";
+               }
                if (!options.empty()) {
                        h_biblio_options = join(options, ",");
                        options.clear();
@@ -1312,6 +1322,8 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
                os << "\\biblatex_bibstyle " << h_biblatex_bibstyle << "\n";
        if (!h_biblatex_citestyle.empty())
                os << "\\biblatex_citestyle " << h_biblatex_citestyle << "\n";
+       if (!h_multibib.empty())
+               os << "\\multibib " << h_multibib << "\n";
        os << "\\use_indices " << h_use_indices << "\n"
           << "\\paperorientation " << h_paperorientation << '\n'
           << "\\suppress_date " << h_suppress_date << '\n'
index 389bf5e48a6c9fe64a2f00a1493ca7f5514b466c..074a85c61365916069426ce43bc82f46131d6a3c 100644 (file)
@@ -133,6 +133,7 @@ private:
 
        std::ostringstream h_preamble;
        std::string h_backgroundcolor;
+       std::string h_multibib;
        std::string h_biblio_style;
        std::string h_biblio_options;
        std::string h_biblatex_bibstyle;
index f5744e7f934fa2668aaa7a78cf22f7bb3684ee0a..e5488b5936dc7b59254bd55fd6d40272edb560cb 100644 (file)
@@ -114,13 +114,9 @@ Format LaTeX feature                        LyX feature
       Same for:
       \Cites, \textcites, \Textcites, \parencites, \Parencites, \smartcites, \Smartcites, \autocites, Autocites
 533   Multibib support
-      \begin{btUnit}...\end{btUnit}        \multibib {none|part|chapter|section|subsetion}
+      \begin{btUnit}...\end{btUnit}        \multibib {none|part|chapter|section|subsection}
         (if a part, chapter, section etc.
          follows the \begin...)
-      \usepackage[refsection=<val>         \multibib <val>
-      \bibbysection[<opts>]                \begin_inset CommandInset bibtex
-                                             biblatexopts "<opts>"
-                                             btprint "bibbysection"
 534   Chapterbib support
       \usepackage{chapterbib}              \multibib child
 
index 8b8dc6180fe966b337a00294e73b0133f77ed602..559aa735b560c18e7fc8a1d0c7b7ce8eb9d75a86 100644 (file)
@@ -4671,6 +4671,35 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        need_commentbib = false;
                }
 
+               else if (t.cs() == "bibbysection") {
+                       context.check_layout(os);
+                       string BibOpts;
+                       string bbloptions = p.hasOpt() ? p.getArg('[', ']') : string();
+                       vector<string> opts = getVectorFromString(bbloptions);
+                       vector<string>::iterator it =
+                               find(opts.begin(), opts.end(), "heading=bibintoc");
+                       if (it != opts.end()) {
+                               opts.erase(it);
+                               BibOpts = "bibtotoc";
+                       }
+                       bbloptions = getStringFromVector(opts);
+                       begin_command_inset(os, "bibtex", "bibtex");
+                       os << "btprint " << '"' << "bibbysection" << '"' << "\n";
+                       string bibfiles;
+                       for (auto const & bf : preamble.biblatex_bibliographies) {
+                               if (!bibfiles.empty())
+                                       bibfiles += ",";
+                               bibfiles += normalize_filename(bf);
+                       }
+                       if (!bibfiles.empty())
+                               os << "bibfiles " << '"' << bibfiles << '"' << "\n";
+                       os << "options " << '"' << BibOpts << '"' << "\n";
+                       if (!bbloptions.empty())
+                               os << "biblatexopts " << '"' << bbloptions << '"' << "\n";
+                       end_inset(os);
+                       need_commentbib = false;
+               }
+
                else if (t.cs() == "parbox") {
                        // Test whether this is an outer box of a shaded box
                        p.pushPosition();