]> git.lyx.org Git - lyx.git/commitdiff
Display footnote labels as superscripts
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 22 Jul 2023 14:53:14 +0000 (16:53 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Jul 2023 09:15:03 +0000 (11:15 +0200)
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.

lib/layouts/numreport.inc
lib/layouts/stdcounters.inc
lib/layouts/stdinsets.inc
src/Counters.cpp
src/insets/InsetFoot.cpp
src/support/counter_reps.cpp
src/support/counter_reps.h

index 44ee0fb7df717a159a61cdf85a458970915f46ab..9788d8f829ea6e553f3277ec3a930d7fcfb652c8 100644 (file)
@@ -41,5 +41,4 @@ End
 Counter footnote
        GuiName Footnote
        Within                chapter
-       LabelString           "\arabic{footnote}"
 End
index 4ee63d0f45c7d22a96f6b77136bba7383c0cdbf8..dc730c70c71bf87f4e75bce2fcb22887cad58b47 100644 (file)
@@ -84,6 +84,7 @@ End
 
 Counter footnote
        GuiName Footnote
+       LabelString          "\superarabic{footnote}"
        PrettyFormat         "Footnote ##"
 End
 
index 8fafff8caf7e6e662585a4c11d82bb3d86bceae0..68c3660368d30abaa01bce2796538f3c45b249ae 100644 (file)
@@ -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
index 0133f76bcab455f876c0f05631641313d09dfe32..d7f8630adf482c5abe7f80b7419ec32abfd573fa 100644 (file)
@@ -476,6 +476,9 @@ docstring Counters::labelItem(docstring const & ctr,
        if (numbertype == "fnsymbol")
                return fnsymbolCounter(val);
 
+       if (numbertype == "superarabic")
+               return superarabicCounter(val);
+
        return convert<docstring>(val);
 }
 
index a0f3435bcd7f8d14c716b78fa91eeb99b12b5b0d..0f5c7062eda6b7c1e85fd0b58c8cf714d4f49038 100644 (file)
@@ -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_+ " ");
 }
 
 
index 96cbe24f5c6f20ff1899599e4165cb1fe2c28ff8..0d13c1085ab9ce3481785ec3c9e39b11f6d396b4 100644 (file)
@@ -12,6 +12,8 @@
 #include <config.h>
 
 #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<docstring>(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
index e6a3f67d9e85c9ecfbbc354b2d59949a8baa81a4..59305dc427c8fd12b45ff522273ff6a2758ff1dc 100644 (file)
@@ -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