From 0bf8b8a1d234c31cc2708e80e41c55dfefacec93 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Fri, 14 Nov 2014 20:20:35 +0100 Subject: [PATCH] Load footmisc.sty instead of using outdated code This is a patch I originally sent to lyx-devel in 2012 with subject 'Load footmisc.sty instead of using copied code from obsolete stblftnt.sty'. It now takes all comments into account: It works also if the user loads the package herself, it can be disabled by providing the footmisc feature in a layout, and it does not use the ugly \AtBeginDocument{}. --- lib/chkconfig.ltx | 1 + lib/doc/LaTeXConfig.lyx | 41 +++++++++++++++++++++++++++++++++++++++++ src/BufferParams.cpp | 7 +++++++ src/LaTeXFeatures.cpp | 26 ++++++-------------------- src/Paragraph.cpp | 2 +- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 0cba00ad37..2bf2ea20e1 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -306,6 +306,7 @@ \TestPackage{fix-cm} \TestPackage{float} \TestPackage{fontspec} +\TestPackage{footmisc} \TestPackage{framed} \TestPackage{geometry} \TestPackage{graphicx} diff --git a/lib/doc/LaTeXConfig.lyx b/lib/doc/LaTeXConfig.lyx index da4c2e4fa1..1bfa2db221 100644 --- a/lib/doc/LaTeXConfig.lyx +++ b/lib/doc/LaTeXConfig.lyx @@ -69,6 +69,7 @@ \html_latex_end \author -1379302345 "Julien Rioux" jrioux@lyx.org \author -712698321 "Jürgen Spitzmüller" +\author -195340706 "Georg Baum" \end_header \begin_body @@ -7007,6 +7008,46 @@ fixltx2e fixltx2e \family default module. +\change_inserted -195340706 1415992274 + +\end_layout + +\begin_layout Subsection + +\change_inserted -195340706 1415992274 +footmisc +\end_layout + +\begin_layout Description + +\change_inserted -195340706 1415992274 +Found: +\begin_inset Info +type "package" +arg "footmisc" +\end_inset + + +\end_layout + +\begin_layout Description + +\change_inserted -195340706 1415992274 +CTAN: +\family typewriter +macros/latex/contrib/supported/footmisc/footmisc.sty +\end_layout + +\begin_layout Description + +\change_inserted -195340706 1415992274 +Notes: The package +\family sans +footmisc +\family default +is needed to support stable footnotes in chapter titles. +\change_unchanged + \end_layout \begin_layout Subsection diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 01927a74cf..d94600fb0f 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1892,6 +1892,13 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, "User specified LaTeX commands.\n" + from_utf8(preamble) + '\n'; + // footmisc must be loaded after setspace + // Load it here to avoid clashes with footmisc loaded in the user + // preamble. For that reason we also pass the options via + // \PassOptionsToPackage in getPreamble() and not here. + if (features.mustProvide("footmisc")) + atlyxpreamble += "\\usepackage{footmisc}\n"; + // subfig loads internally the LaTeX package "caption". As // caption is a very popular package, users will load it in // the preamble. Therefore we must load subfig behind the diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 400dfb6c3e..630cc4c30e 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -134,24 +134,6 @@ static docstring const paragraphleftindent_def = from_ascii( "}\n" "{\\end{list}}\n"); -static docstring const floatingfootnote_def = from_ascii( - "%% Special footnote code from the package 'stblftnt.sty'\n" - "%% Author: Robin Fairbairns -- Last revised Dec 13 1996\n" - "\\let\\SF@@footnote\\footnote\n" - "\\def\\footnote{\\ifx\\protect\\@typeset@protect\n" - " \\expandafter\\SF@@footnote\n" - " \\else\n" - " \\expandafter\\SF@gobble@opt\n" - " \\fi\n" - "}\n" - "\\expandafter\\def\\csname SF@gobble@opt \\endcsname{\\@ifnextchar[%]\n" - " \\SF@gobble@twobracket\n" - " \\@gobble\n" - "}\n" - "\\edef\\SF@gobble@opt{\\noexpand\\protect\n" - " \\expandafter\\noexpand\\csname SF@gobble@opt \\endcsname}\n" - "\\def\\SF@gobble@twobracket[#1]#2{}\n"); - static docstring const binom_def = from_ascii( "%% Binom macro for standard LaTeX users\n" "\\newcommand{\\binom}[2]{{#1 \\choose #2}}\n"); @@ -1050,6 +1032,12 @@ string const LaTeXFeatures::getPackages() const if (mustProvide("subscript") && !isRequired("fixltx2e")) packages << "\\usepackage{subscript}\n"; + // footmisc must be loaded after setspace + // Set options here, load the package after the user preamble to + // avoid problems with manual loaded footmisc. + if (mustProvide("footmisc")) + packages << "\\PassOptionsToPackage{stable}{footmisc}\n"; + return packages.str(); } @@ -1178,8 +1166,6 @@ docstring const LaTeXFeatures::getMacros() const // other if (mustProvide("ParagraphLeftIndent")) macros << paragraphleftindent_def; - if (mustProvide("NeedLyXFootnoteCode")) - macros << floatingfootnote_def; // some problems with tex->html converters if (mustProvide("NeedTabularnewline")) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 37e26a8b86..5bfa687abb 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -1521,7 +1521,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const icit->inset->validate(features); if (layout_->needprotect && icit->inset->lyxCode() == FOOT_CODE) - features.require("NeedLyXFootnoteCode"); + features.require("footmisc"); } } -- 2.39.2