From 55bc36587210575f9ef0df3b101f18161469c22b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 19 Nov 2017 12:56:40 +0100 Subject: [PATCH] Allow footnotes in floating tables via tablefootnote package See #808. (cherry picked from commit 5017a0a1c635ed8da2b1fce5e240d0e297cf1aaf) --- lib/chkconfig.ltx | 1 + lib/doc/LaTeXConfig.lyx | 33 +++++++++++++++++++++++++++++++-- lib/layouts/stdinsets.inc | 7 +++++++ src/LaTeXFeatures.cpp | 1 + src/insets/InsetFoot.cpp | 16 +++++++++++++--- src/insets/InsetFoot.h | 2 ++ src/insets/InsetTabular.cpp | 2 +- 7 files changed, 56 insertions(+), 6 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 7087e55442..c31fb9228e 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -369,6 +369,7 @@ \TestPackage{subfig} \TestPackage{subscript} \TestPackage{Sweave} +\TestPackage{tablefootnote} \TestPackage{tcolorbox} \TestPackage{textcomp} \TestPackage{thswitch} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index 93b6563b92..10693d2e9a 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -5178,8 +5178,8 @@ Notes: The package footnote \family default is needed by \SpecialChar LyX - to allow footnotes in non-floating tables and multi-page - table headers and footers. + to allow footnotes in description items, non-floating tables + and multi-page table headers and footers. \end_layout @@ -5307,6 +5307,35 @@ longtable to be able to output correctly multipage tables. \end_layout +\begin_layout Subsection +tablefootnote +\end_layout + +\begin_layout Description +Found: +\begin_inset Info +type "package" +arg "tablefootnote" +\end_inset + + +\end_layout + +\begin_layout Description +CTAN: +\family typewriter +macros/latex/contrib/tablefootnote/ +\end_layout + +\begin_layout Description +Notes: The package +\family sans +tablefootnote +\family default + is needed by \SpecialChar LyX + to be able to output footnotes in floating tables. +\end_layout + \begin_layout Subsection textcomp \end_layout diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 90e5958920..da91f1c189 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -122,6 +122,13 @@ InsetLayout Foot:InTitle EndHTMLStyle End +InsetLayout Foot:InFloatTable + CopyStyle Foot + LatexName tablefootnote + Requires tablefootnote +End + + InsetLayout Note:Comment LabelString Comment LatexType environment diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index c28d7958f6..3f9eb67762 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -975,6 +975,7 @@ char const * simplefeatures[] = { "forest", "varwidth", "footnote", + "tablefootnote", }; char const * bibliofeatures[] = { diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index de00e8935e..db7e1ac331 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -34,13 +34,17 @@ using namespace std; namespace lyx { InsetFoot::InsetFoot(Buffer * buf) - : InsetFootlike(buf), intitle_(false) + : InsetFootlike(buf), intitle_(false), infloattable_(false) {} docstring InsetFoot::layoutName() const { - return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot"); + if (intitle_) + return from_ascii("Foot:InTitle"); + else if (infloattable_) + return from_ascii("Foot:InFloatTable"); + return from_ascii("Foot"); } @@ -54,7 +58,13 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype) } intitle_ = false; - for (size_type sl = 0 ; sl < it.depth() ; ++ sl) { + infloattable_ = false; + bool intable = false; + if (it.innerInsetOfType(TABULAR_CODE) != 0) + intable = true; + if (it.innerInsetOfType(FLOAT_CODE) != 0) + infloattable_ = intable; + for (size_type sl = 0 ; sl < it.depth() ; ++sl) { if (it[sl].text() && it[sl].paragraph().layout().intitle) { intitle_ = true; break; diff --git a/src/insets/InsetFoot.h b/src/insets/InsetFoot.h index c04ecabb78..d032e04848 100644 --- a/src/insets/InsetFoot.h +++ b/src/insets/InsetFoot.h @@ -48,6 +48,8 @@ private: docstring custom_label_; /// bool intitle_; + /// + bool infloattable_; }; diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 032621d367..a49c5bf77d 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -3427,7 +3427,7 @@ void Tabular::validate(LaTeXFeatures & features) const // Tell footnote that we need a savenote // environment in non-long tables or // longtable headers/footers - if (!is_long_tabular) + else if (!is_long_tabular && !features.inFloat()) features.saveNoteEnv("tabular"); else if (!isValidRow(cellRow(cell))) features.saveNoteEnv("longtable");