]> git.lyx.org Git - features.git/commitdiff
Add TextClass option BibInToc
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 8 Jul 2019 13:40:17 +0000 (15:40 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:35 +0000 (15:48 +0200)
Fixes #1889

lib/doc/Customization.lyx
lib/doc/de/Customization.lyx
lib/layouts/amsart.layout
lib/scripts/layout2layout.py
src/TextClass.cpp
src/TextClass.h
src/frontends/qt4/GuiBibtex.cpp
src/insets/InsetBibtex.cpp

index af95f4db37a208889fbc667540e9f28fc7989b0d..9bf5d9d86023abfc4d506873d5266b5a98143d07 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 575
+\lyxformat 578
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -9106,6 +9106,87 @@ EndPreamble
 \end_inset
 
 .
+\change_inserted -712698321 1562592950
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted -712698321 1562593040
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1562592954
+BibInToc
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1562592950
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1562592950
+1
+\end_layout
+
+\end_inset
+
+] If the document class adds the bibliography to the table of contents,
+ add this option with value 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1562592996
+1
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+ (or 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted -712698321 1562593006
+true
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+).
+ This prevents the bibliography from being added twice.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Description
index f1cde430279b9b561a25167c5facb21fe13b1d88..127cc43b483382a56eca5da5aaad8d471d6a125d 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 575
+\lyxformat 578
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -7474,6 +7474,67 @@ EndPreamble
 \begin_inset Flex Code
 status collapsed
 
+\begin_layout Plain Layout
+BibInToc
+\end_layout
+
+\end_inset
+
+ [
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\emph on
+0
+\end_layout
+
+\end_inset
+
+,
+\begin_inset space \thinspace{}
+\end_inset
+
+
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+] Falls die Dokumentklasse das Literaturverzeichnis per Voreinstellung im
+ Inhaltsverzeichnis aufführt, fügen Sie diese Option mit dem Wert 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+1
+\end_layout
+
+\end_inset
+
+ (oder 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+true
+\end_layout
+
+\end_inset
+
+) hinzu.
+ Dies verhindert, dass das Literaturverzeichnis zweimal erscheint.
+\end_layout
+
+\begin_layout Description
+\begin_inset Flex Code
+status collapsed
+
 \begin_layout Plain Layout
 CiteEngine <engine>
 \end_layout
index cd3d38da5418137aa8bc687a7cc9c22476d781ce..3b60359b925db3b81543d20349721ec2389c8e71 100644 (file)
 # Modularized Jan '08 by Richard Heck <rgheck@brown.edu>
 # Moved "number within sections" to modules Aug '09 (Paul Rubin <rubin@msu.edu>)
 
-Format 74
+Format 75
 
 Columns                 1
 Sides                   2
 PageStyle               Headers
+BibInToc                true
 
 Provides amsmath         1
 Provides makeidx         1
index af2a85155042fcc15cedc60886b308dbf9079445..46a8ea6efb151d0c8262cd6005900e1d11b533a3 100644 (file)
@@ -11,7 +11,7 @@
 # This script will update a .layout file to current format
 
 # The latest layout format is also defined in src/TextClass.cpp
-currentFormat = 75
+currentFormat = 76
 
 
 # Incremented to format 4, 6 April 2007, lasgouttes
@@ -252,6 +252,9 @@ currentFormat = 75
 # New Argument tags FreeSpacing, InsertOnNewline
 # New InsetLayout tag ParbreakIgnored
 
+# Incremented to format 76, 8 July 2019 by spitz
+# New textclass tag BibInToc
+
 # Do not forget to document format change in Customization
 # Manual (section "Declaring a new text class").
 
@@ -501,7 +504,7 @@ def convert(lines, end_format):
                 i += 1
             continue
 
-        if format >= 65 and format <= 74:
+        if format >= 65 and format <= 75:
             # nothing to do.
             i += 1
             continue
index 43abe6769bcedd67cd416217e6fe155c2df36eff..3c4c3307fb4020f8d1d9e097b1ba2ec6198c18e4 100644 (file)
@@ -62,7 +62,7 @@ namespace lyx {
 // You should also run the development/tools/updatelayouts.py script,
 // to update the format of all of our layout files.
 //
-int const LAYOUT_FORMAT = 75; // spitz: FreeSpacing (Argument)
+int const LAYOUT_FORMAT = 76; // spitz: BibInToc
 
 
 // Layout format for the current lyx file format. Controls which format is
@@ -156,7 +156,7 @@ TextClass::TextClass()
          has_output_format_(false), defaultfont_(sane_font), 
          titletype_(TITLE_COMMAND_AFTER), titlename_("maketitle"),
          min_toclevel_(0), max_toclevel_(0), maxcitenames_(2),
-         cite_full_author_list_(true)
+         cite_full_author_list_(true), bibintoc_(false)
 {
 }
 
@@ -227,7 +227,8 @@ enum TextClassTags {
        TC_DEFAULTBIBLIO,
        TC_FULLAUTHORLIST,
        TC_OUTLINERNAME,
-       TC_TABLESTYLE
+       TC_TABLESTYLE,
+       TC_BIBINTOC
 };
 
 
@@ -238,6 +239,7 @@ LexerKeyword textClassTags[] = {
        { "addtohtmlpreamble", TC_ADDTOHTMLPREAMBLE },
        { "addtohtmlstyles",   TC_ADDTOHTMLSTYLES },
        { "addtopreamble",     TC_ADDTOPREAMBLE },
+       { "bibintoc",          TC_BIBINTOC },
        { "citeengine",        TC_CITEENGINE },
        { "citeenginetype",    TC_CITEENGINETYPE },
        { "citeformat",        TC_CITEFORMAT },
@@ -810,6 +812,11 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                        }
                        break;
 
+               case TC_BIBINTOC:
+                       if (lexrc.next())
+                               bibintoc_ = lexrc.getBool();
+                       break;
+
                case TC_FULLAUTHORLIST:
                        if (lexrc.next())
                                cite_full_author_list_ &= lexrc.getBool();
index dc1b296475a1c9a8f7f3aeaa645c4a3bd3def913..222384ff3419f06811c7764cdc52c0a2b9be5df7 100644 (file)
@@ -357,6 +357,8 @@ protected:
        std::map<CiteEngineType, std::vector<CitationStyle> > class_cite_styles_;
        ///
        std::map<std::string, docstring> outliner_names_;
+       /// Does this class put the bibliography to toc by itself?
+       bool bibintoc_;
 private:
        ///////////////////////////////////////////////////////////////////
        // helper routines for reading layout files
@@ -523,6 +525,8 @@ public:
        size_t max_citenames() const { return maxcitenames_; }
        ///
        bool const & fullAuthorList() const { return cite_full_author_list_; }
+       ///
+       bool const & bibInToc() const { return bibintoc_; }
 protected:
        /// Constructs a DocumentClass based upon a LayoutFile.
        DocumentClass(LayoutFile const & tc);
index 8680a384d286e96c63dd92f456788b606d86a933..8414daa1cd8937365028c34d63d2ccc173433bcf 100644 (file)
@@ -23,6 +23,7 @@
 #include "GuiApplication.h"
 #include "LyXRC.h"
 #include "qt_helpers.h"
+#include "TextClass.h"
 #include "Validator.h"
 
 #include "ButtonPolicy.h"
@@ -336,8 +337,8 @@ void GuiBibtex::databaseChanged()
 
 void GuiBibtex::updateContents()
 {
-       bool bibtopic = usingBibtopic();
-       bool biblatex = usingBiblatex();
+       bool const bibtopic = usingBibtopic();
+       bool const biblatex = usingBiblatex();
 
        if (biblatex)
                setTitle(qt_("Biblatex Bibliography"));
@@ -346,8 +347,11 @@ void GuiBibtex::updateContents()
 
        QString const bibstyle = styleFile();
 
-       bibtocCB->setChecked(bibtotoc() && !bibtopic);
-       bibtocCB->setEnabled(!bibtopic);
+       bool const hasbibintoc = buffer().params().documentClass().bibInToc()
+                       && !biblatex;
+
+       bibtocCB->setChecked((bibtotoc() && !bibtopic) || hasbibintoc);
+       bibtocCB->setEnabled(!bibtopic && !hasbibintoc);
 
        btPrintCO->clear();
        btPrintCO->addItem(qt_("all cited references"), toqstr("btPrintCited"));
index d20f67187cdaf652f9ecdda1d28590106eed60ef..91e1e6034d24e9a17448bf667f5c71f9a8f543c6 100644 (file)
@@ -363,7 +363,8 @@ void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                           << "\\end{btSect}\n";
                }
                // bibtotoc option
-               if (!bibtotoc.empty() && !buffer().masterParams().useBibtopic()) {
+               if (!bibtotoc.empty() && !buffer().masterParams().useBibtopic()
+                   && !buffer().masterParams().documentClass().bibInToc()) {
                        // set label for hyperref, see http://www.lyx.org/trac/ticket/6470
                        if (buffer().masterParams().pdfoptions().use_hyperref)
                                        os << "\\phantomsection";