From 86bf02a3c226133ca241a86ec8976bfabde74c50 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 8 Jul 2019 15:40:17 +0200 Subject: [PATCH] Add TextClass option BibInToc Fixes #1889 --- lib/doc/Customization.lyx | 83 ++++++++++++++++++++++++++++++++- lib/doc/de/Customization.lyx | 63 ++++++++++++++++++++++++- lib/layouts/amsart.layout | 3 +- lib/scripts/layout2layout.py | 7 ++- src/TextClass.cpp | 13 ++++-- src/TextClass.h | 4 ++ src/frontends/qt4/GuiBibtex.cpp | 12 +++-- src/insets/InsetBibtex.cpp | 3 +- 8 files changed, 175 insertions(+), 13 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index af95f4db37..9bf5d9d860 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -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 diff --git a/lib/doc/de/Customization.lyx b/lib/doc/de/Customization.lyx index f1cde43027..127cc43b48 100644 --- a/lib/doc/de/Customization.lyx +++ b/lib/doc/de/Customization.lyx @@ -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 \end_layout diff --git a/lib/layouts/amsart.layout b/lib/layouts/amsart.layout index cd3d38da54..3b60359b92 100644 --- a/lib/layouts/amsart.layout +++ b/lib/layouts/amsart.layout @@ -11,11 +11,12 @@ # Modularized Jan '08 by Richard Heck # Moved "number within sections" to modules Aug '09 (Paul Rubin ) -Format 74 +Format 75 Columns 1 Sides 2 PageStyle Headers +BibInToc true Provides amsmath 1 Provides makeidx 1 diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index af2a851550..46a8ea6efb 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -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 diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 43abe6769b..3c4c3307fb 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -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(); diff --git a/src/TextClass.h b/src/TextClass.h index dc1b296475..222384ff34 100644 --- a/src/TextClass.h +++ b/src/TextClass.h @@ -357,6 +357,8 @@ protected: std::map > class_cite_styles_; /// std::map 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); diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 8680a384d2..8414daa1cd 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -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")); diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index d20f67187c..91e1e6034d 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -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"; -- 2.39.5