Add TextClass option BibInToc

Fixes #1889
This commit is contained in:
Juergen Spitzmueller 2019-07-08 15:40:17 +02:00
parent 110247f0b7
commit 13b6632228
8 changed files with 175 additions and 13 deletions

View 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

View 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

View File

@ -11,11 +11,12 @@
# 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

View 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

View 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();

View 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);

View 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"));

View 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";