diff --git a/lib/layouts/apa.layout b/lib/layouts/apa.layout index d771973ccf..a421c4e492 100644 --- a/lib/layouts/apa.layout +++ b/lib/layouts/apa.layout @@ -309,7 +309,7 @@ Style Section Series Bold Size Huge EndFont - TocLevel 1 + TocLevel 1 End @@ -319,7 +319,7 @@ Style Subsection Series Bold Size Larger EndFont - TocLevel 2 + TocLevel 2 End @@ -329,7 +329,7 @@ Style Subsubsection Series Bold Size Large EndFont - TocLevel 3 + TocLevel 3 End @@ -339,7 +339,7 @@ Style Paragraph Series Bold Size Normal EndFont - TocLevel 4 + TocLevel 4 End @@ -350,7 +350,7 @@ Style Subparagraph Size Normal Shape Italic EndFont - TocLevel 5 + TocLevel 5 End diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index 5eeeba556a..14e4549d54 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -216,6 +216,7 @@ Style Part LabelString "Short Title|S" Tooltip "The part as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument NeedProtect 1 NextNoIndent 1 @@ -270,6 +271,7 @@ Style Section LabelString "Short Title|S" Tooltip "The section as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Family Roman @@ -331,6 +333,7 @@ Style Subsection LabelString "Short Title|S" Tooltip "The subsection as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Family Roman @@ -392,6 +395,7 @@ Style Subsubsection LabelString "Short Title|S" Tooltip "The subsubsection as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Family Roman @@ -481,6 +485,7 @@ Style Frame Size largest EndFont AutoInsert 1 + IsTocCaption 1 EndArgument End diff --git a/lib/layouts/europecv.layout b/lib/layouts/europecv.layout index 141f78707e..cc30eecba4 100644 --- a/lib/layouts/europecv.layout +++ b/lib/layouts/europecv.layout @@ -136,7 +136,8 @@ Style Section Argument 1 LabelString "Short Title|S" Tooltip "The title as it appears in the header" - InsertCotext 1 + InsertCotext 1 + IsTocCaption 1 EndArgument ParSkip 0.4 TopSep 1.3 diff --git a/lib/layouts/isprs.layout b/lib/layouts/isprs.layout index f75bca09dc..d0ca792cae 100644 --- a/lib/layouts/isprs.layout +++ b/lib/layouts/isprs.layout @@ -153,7 +153,7 @@ Style Section Series Bold Size Normal EndFont - TocLevel 1 + TocLevel 1 End # Subsection style definition @@ -163,7 +163,7 @@ Style Subsection Series Bold Size Normal EndFont - TocLevel 2 + TocLevel 2 End # Subsubsection style definition @@ -173,7 +173,7 @@ Style Subsubsection Series Bold Size Normal EndFont - TocLevel 3 + TocLevel 3 End # Section* style definition diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout index 09b175846b..0a13f23ccf 100644 --- a/lib/layouts/simplecv.layout +++ b/lib/layouts/simplecv.layout @@ -46,11 +46,12 @@ Style Section Family Sans Series Bold EndFont - TocLevel 1 + TocLevel 1 Argument 1 LabelString "Short Title|S" Tooltip "The section as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument End diff --git a/lib/layouts/stdsections.inc b/lib/layouts/stdsections.inc index 0705e45041..e7a0292632 100644 --- a/lib/layouts/stdsections.inc +++ b/lib/layouts/stdsections.inc @@ -32,6 +32,7 @@ Style Part LabelString "Short Title|S" Tooltip "The part as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold @@ -63,6 +64,7 @@ Style Chapter LabelString "Short Title|S" Tooltip "The chapter as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold @@ -93,6 +95,7 @@ Style Section LabelString "Short Title|S" Tooltip "The section as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold diff --git a/lib/layouts/svcommon.inc b/lib/layouts/svcommon.inc index 6ebb40eed3..d370adaa7a 100644 --- a/lib/layouts/svcommon.inc +++ b/lib/layouts/svcommon.inc @@ -140,6 +140,7 @@ Style PartBacktext Mandatory 1 LabelString "Part Title" Tooltip "Title of this part" + IsTocCaption 1 EndArgument Preamble \newenvironment{svmultpartbacktext}[1]{\begin{partbacktext} diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout index d29e86ee15..9ffc0e5ec5 100644 --- a/lib/layouts/tufte-book.layout +++ b/lib/layouts/tufte-book.layout @@ -81,8 +81,9 @@ Style Chapter RefPrefix chap Argument 1 LabelString "Short Title|S" - Tooltip "The chapter as it appears in the table of contents/running headers" + Tooltip "The chapter as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold @@ -109,8 +110,9 @@ Style Section RefPrefix sec Argument 1 LabelString "Short Title|S" - Tooltip "The section as it appears in the table of contents/running headers" + Tooltip "The section as it appears in the table of contents/running headers" InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold diff --git a/lib/layouts/tufte-handout.layout b/lib/layouts/tufte-handout.layout index 507e4a9411..dc1c4acad4 100644 --- a/lib/layouts/tufte-handout.layout +++ b/lib/layouts/tufte-handout.layout @@ -39,7 +39,8 @@ Style Part Argument 1 LabelString "Short Title|S" Tooltip "The part as it appears in the table of contents/running headers" - InsertCotext 1 + InsertCotext 1 + IsTocCaption 1 EndArgument Font Series Bold diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index a3cf1c5202..df1344e626 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -43,7 +43,7 @@ InsetArgument::InsetArgument(Buffer * buf, string const & name) : InsetCollapsible(buf), name_(name), labelstring_(docstring()), font_(inherit_font), labelfont_(inherit_font), decoration_(string()), pass_thru_context_(false), pass_thru_local_(false), pass_thru_(false), - pass_thru_chars_(docstring()) + pass_thru_chars_(docstring()), is_toc_caption_(false) {} @@ -119,11 +119,13 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype) decoration_ = (*lait).second.decoration; pass_thru_chars_ = (*lait).second.pass_thru_chars; pass_thru_local_ = false; - if (lait->second.is_toc_caption) + if (lait->second.is_toc_caption) { + is_toc_caption_ = true; // empty if AddToToc is not set caption_of_toc_ = insetlayout ? it.inset().getLayout().tocType() : it.paragraph().layout().tocType(); + } switch ((*lait).second.passthru) { case PT_INHERITED: diff --git a/src/insets/InsetArgument.h b/src/insets/InsetArgument.h index 9fff93b4e1..2bd0578f28 100644 --- a/src/insets/InsetArgument.h +++ b/src/insets/InsetArgument.h @@ -69,6 +69,8 @@ public: /// bool isPassThru() const { return pass_thru_; } /// + bool isTocCaption() const { return is_toc_caption_; } + /// bool resetFontEdit() const { return false; } //@} /// \name Public functions inherited from InsetCollapsible class @@ -113,6 +115,8 @@ private: bool pass_thru_; /// docstring pass_thru_chars_; + /// Does this argument provide content for the TOC? + bool is_toc_caption_; /// The type of Toc this is the caption of, empty otherwise. std::string caption_of_toc_; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 28484a4d76..523dc5bd53 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -870,13 +870,15 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active, addtotoc_stack.push({pit, end}); } - // if we find an optarg, we'll save it for use later. + // If we find an InsetArgument that is supposed to provide the TOC caption, + // we'll save it for use later. InsetArgument const * arginset = nullptr; for (auto const & table : par.insetList()) { dit.pos() = table.pos; table.inset->addToToc(dit, doing_output, utype, backend); if (InsetArgument const * x = table.inset->asInsetArgument()) - arginset = x; + if (x->isTocCaption()) + arginset = x; } // End custom AddToToc in paragraph layouts