From: Jean-Marc Lasgouttes Date: Sat, 22 Jul 2023 14:53:14 +0000 (+0200) Subject: Display footnote labels as superscripts X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=6a8c10f0d6178dc261f089fe8245de1000ef1941;p=features.git Display footnote labels as superscripts A new counter type \superarabic is introduced, that transforms the counter into superscript Unicode numbers. This is used for the footnote counter. The Foot inset layout is modified to use an empty LabelString (in size Normal, since the numbers could be too small). We use this occasion to set footnote text in footnotesize, as it should. A couple of changes are done to the code to make the button label and tooltip look better. Fixes bug #12238. --- diff --git a/lib/layouts/numreport.inc b/lib/layouts/numreport.inc index 44ee0fb7df..9788d8f829 100644 --- a/lib/layouts/numreport.inc +++ b/lib/layouts/numreport.inc @@ -41,5 +41,4 @@ End Counter footnote GuiName Footnote Within chapter - LabelString "\arabic{footnote}" End diff --git a/lib/layouts/stdcounters.inc b/lib/layouts/stdcounters.inc index 4ee63d0f45..dc730c70c7 100644 --- a/lib/layouts/stdcounters.inc +++ b/lib/layouts/stdcounters.inc @@ -84,6 +84,7 @@ End Counter footnote GuiName Footnote + LabelString "\superarabic{footnote}" PrettyFormat "Footnote ##" End diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 8fafff8caf..68c3660368 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -49,17 +49,17 @@ InsetLayout Marginal End InsetLayout Foot - LabelString Foot + LabelString "" LatexType Command LatexName footnote Counter footnote InheritFont false Font - Size Small + Size FootnoteSize EndFont LabelFont Color footlabel - Size Small + Size Normal EndFont MultiPar true RefPrefix fn diff --git a/src/Counters.cpp b/src/Counters.cpp index 0133f76bca..d7f8630adf 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -476,6 +476,9 @@ docstring Counters::labelItem(docstring const & ctr, if (numbertype == "fnsymbol") return fnsymbolCounter(val); + if (numbertype == "superarabic") + return superarabicCounter(val); + return convert(val); } diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index a0f3435bcd..0f5c7062ed 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -88,7 +88,9 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype, bool cons int val = cnts.value(count); if (cnts.hasCounter(count)) { cnts.step(count, utype); - custom_label_ += ' ' + cnts.theCounter(count, lang->code()); + if (!custom_label_.empty()) + custom_label_ += ' '; + custom_label_ += cnts.theCounter(count, lang->code()); if (deleted) // un-step after deleted counter cnts.set(count, val); @@ -107,7 +109,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const if (isOpen(bv)) // this will give us something useful if there is no button return InsetCollapsible::toolTip(bv, x, y); - return toolTipText(custom_label_+ ": "); + return toolTipText(custom_label_+ " "); } diff --git a/src/support/counter_reps.cpp b/src/support/counter_reps.cpp index 96cbe24f5c..0d13c1085a 100644 --- a/src/support/counter_reps.cpp +++ b/src/support/counter_reps.cpp @@ -12,6 +12,8 @@ #include #include "support/counter_reps.h" + +#include "support/convert.h" #include "support/docstring.h" #include "support/lstrings.h" @@ -132,4 +134,15 @@ docstring const fnsymbolCounter(int const n) }; } + +docstring const superarabicCounter(int const n) +{ + docstring superarabic = convert(n); + static char_type map[] = {0x2070, 0x00b9, 0x00b2, 0x00b3, 0x2074, + 0x2075, 0x2076, 0x2077, 0x2078, 0x2079 }; + for (char_type & c : superarabic) + c = map[c - char_type('0')]; + return superarabic; +} + } // namespace lyx diff --git a/src/support/counter_reps.h b/src/support/counter_reps.h index e6a3f67d9e..59305dc427 100644 --- a/src/support/counter_reps.h +++ b/src/support/counter_reps.h @@ -27,6 +27,7 @@ char hebrewCounter(int const n); docstring const romanCounter(int const n); docstring const lowerromanCounter(int const n); docstring const fnsymbolCounter(int const n); +docstring const superarabicCounter(int const n); } // namespace lyx