3

The management of kerning appears in LaTeX not so effective in the case of note numbers. A magnificent solution for footnotes has been provided by David Purton in this thread:

Lining numbers for footnote

Now, since I have to produce an article with the notes at the end of the text, that solution does not work. Is there a way to re-adapt the code produced by David Purton to endnotes?

I enclose a MWE of the basic endnotes code, obviously without kerning.

\documentclass{article}
\usepackage{fontspec}
\usepackage[english]{babel}
\babelfont[english]{rm}[Ligatures=TeX,Numbers=Proportional,OldStyle},RawFeature=+calt]{Source Serif Pro}

\usepackage{endnotes}
\usepackage{etoolbox}
\preto{\theendnotes}{%
\renewcommand{\makeenmark}{\textsuperscript{\theenmark}\enspace}%
}
\let\footnote=\endnote

\begin{document}

text text «text»\footnote{Footnote text.}.

text text «text»\footnote{Footnote text.}.

text text «text»\footnote{Footnote text.}.

text text «text»\footnote{Footnote text.}.

text text «text»\footnote{Footnote text.}.

text text «text»\footnote{Footnote text.}.

\theendnotes

\end{document}

Thank you

ADDENDUM

A more complex test, with superscript footnotes numbers, but for bibliography:

\begin{filecontents*}{jobname.bib}
@book{ stegmuller:1976,
  author         = "Stegmüller, Wolfgang",
  title          = "The Structure and Dynamics of Theories",
  publisher  = "Springer",
  location   = "New-York Heidelberg Berlin",
  year       = "1976",
}
\end{filecontents*}{jobname.bib}

    \documentclass[a4paper,11pt]{article}
\usepackage{fontspec}
\usepackage[english]{babel}
\babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}

\usepackage{xpatch}
    \usepackage{etoolbox}
\preto{\theendnotes}{%
  \renewcommand{\makeenmark}{\textsuperscript{\theenmark}\enspace}%
}
\let\footnote=\endnote

\usepackage{realscripts}

\ExplSyntaxOn
\cs_new_protected:Nn \__realscripts_numtosup:n
  {
    \str_set:Nn \l_tmpa_str {#1}
    \str_map_inline:Nn \l_tmpa_str
      {
        \str_if_in:nnTF {0123456789} {##1}
          {
            \int_set:Nn \l_tmpa_int {##1}
            \if_case:w \l_tmpa_int ⁰
              \or: ¹
              \or: ²
              \or: ³
              \or: ⁴
              \or: ⁵
              \or: ⁶
              \or: ⁷
              \or: ⁸
              \or: ⁹
            \fi:
          }
          { { \addfontfeature {VerticalPosition=Superior} ##1 } }
      }
  }
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript { m }
  {
    \fontspec_if_fontspec_font:TF
      {
        \fontspec_if_opentype:TF
          {
            \fontspec_if_feature:nTF { +sups }
              { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
          {
            \fontspec_if_aat_feature:nnTF {10} {1}
              { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
      }
      { \fakesuperscript {#1} }
  }
\ExplSyntaxOff
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% BIBLIOGRAPHY
\usepackage[babel]{csquotes}

\usepackage[backend=biber,style=philosophy-verbose,scauthors=all,%
lowscauthors=true,giveninits,classical=true,volnumformat=strings,%
volumeformat=romansc,sorting=nyt,commacit=true,citepages=omit,%
editionformat=superscript,indexing]%
{biblatex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\addbibresource{jobname.bib}
\nocite{*}

\begin{document}

Text\footnote{Footnote text} more «text»\footcite[220]{stegmuller:1976}. Further text

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\linespread{0.9}
\theendnotes

\printbibliography[heading=bibintoc]

\end{document}

Does \footcite have a different approach to superscript numbers?

LAST UPDATE

When I try to compile this source:

  \begin{filecontents*}{\jobname.bib}
  @book{ stegmuller:1976,
  author     = "Stegmüller, Wolfgang",
  title      = "The Structure and Dynamics of Theories",
  publisher  = "Springer",
  location   = "New-York Heidelberg Berlin",
  year       = "1976",
  edition    = "2",
}
\end{filecontents*}

\documentclass{article}

\directlua {
  fonts.handlers.otf.addfeature {
    name = "supkern",
    type = "kern",
    data = {
      ["¹"] = { ["."] =  -180,
                [","] =  -180 },
      ["²"] = { ["."] =  -180,
                [","] =  -180 },
      ["³"] = { ["."] =  -180,
                [","] =  -180 },
      ["⁴"] = { ["."] =  -180,
                [","] =  -180 },
    },
  }
}

\usepackage{realscripts}
\usepackage[english]{babel}
\usepackage[babel]{csquotes}
\babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}

\ExplSyntaxOn
\cs_new_protected:Nn \__realscripts_numtosup:n
  {
    \str_set:Nn \l_tmpa_str {#1}
    \str_map_inline:Nn \l_tmpa_str
      {
        \str_if_in:nnTF {0123456789} {##1}
          {
            \int_set:Nn \l_tmpa_int {##1}
            \if_case:w \l_tmpa_int ⁰
              \or: ¹
              \or: ²
              \or: ³
              \or: ⁴
              \or: ⁵
              \or: ⁶
              \or: ⁷
              \or: ⁸
              \or: ⁹
            \fi:
          }
          { { \addfontfeature {VerticalPosition=Superior} ##1 } }
      }
  }
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript { m }
  {
    \fontspec_if_fontspec_font:TF
      {
        \fontspec_if_opentype:TF
          {
            \fontspec_if_feature:nTF { +sups }
              { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
          {
            \fontspec_if_aat_feature:nnTF {10} {1}
              { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
      }
      { \fakesuperscript {#1} }
  }
\ExplSyntaxOff

\usepackage{endnotes}
\usepackage{etoolbox}
\preto{\theendnotes}{%
  \renewcommand{\makeenmark}{\textsuperscript{\theenmark}\enspace}%
}
\makeatletter
\def\@makeenmark{\unpenalty{\footnotemarkfont\textsuperscript{\@theenmark}}}
\makeatother
\let\footnote\endnote

\usepackage[style=philosophy-verbose, scauthors=all, lowscauthors=true,
  giveninits, classical=true, volnumformat=strings, volumeformat=romansc,
  sorting=nyt, commacit=true, citepages=omit, editionformat=superscript,
  indexing]{biblatex}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}

A\footnote{Footnote text}.

A\footnote{Footnote text},

A\footnote{Footnote text};

A\footcite[53]{stegmuller:1976}.

\theendnotes

\printbibliography
\end{document}

1) first compilation with lualates works fine

2) bibliography compilation with biber works fine

3) new final compilation with lualates produces this error:

! Illegal parameter number in definition of \l__exp_internal_tl.
<to be read again> 
1
l.17 {footcite}{}{53}{stegmuller:1976}{}}}

? 

I realized that the error comes from edition = "2",in the bibliographical record. That is the very reason for the compilation stops!

user41063
  • 1,967

1 Answers1

3

Fortunately, it's straight forward to modify things from my previous answers here and here to work with end notes.

Note that your last update with the example of the edition field in the bibliography entry reveals a weakness in my code. It assumes that the argument to \textsuperscript is fully expandable, but this is not necessarily the case (and isn't the case for \mkbibsuperscript which is used by biblatex-philosophy to format the edition). I've worked around this in the MWE below, but you will run into other problems.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @book{ stegmuller:1976,
  author     = "Stegmüller, Wolfgang",
  title      = "The Structure and Dynamics of Theories",
  publisher  = "Springer",
  location   = "New-York Heidelberg Berlin",
  year       = "1976",
  edition    = "2",
}
\end{filecontents}

\directlua {
  fonts.handlers.otf.addfeature {
    name = "supkern",
    type = "kern",
    data = {
      ["¹"] = { ["."] =  -180,
                [","] =  -180 },
      ["²"] = { ["."] =  -180,
                [","] =  -180 },
      ["³"] = { ["."] =  -180,
                [","] =  -180 },
      ["⁴"] = { ["."] =  -180,
                [","] =  -180 },
    },
  }
}

\usepackage{realscripts}
\usepackage[english]{babel}
\usepackage[babel]{csquotes}
\babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}

\ExplSyntaxOn
\cs_new_protected:Nn \__realscripts_numtosup:n
  {
    \str_set:Nn \l_tmpa_str {#1}
    \str_map_inline:Nn \l_tmpa_str
      {
        \str_if_in:nnTF {0123456789} {##1}
          {
            \int_set:Nn \l_tmpa_int {##1}
            \if_case:w \l_tmpa_int ⁰
              \or: ¹
              \or: ²
              \or: ³
              \or: ⁴
              \or: ⁵
              \or: ⁶
              \or: ⁷
              \or: ⁸
              \or: ⁹
            \fi:
          }
          { { \addfontfeature {VerticalPosition=Superior} ##1 } }
      }
  }
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript { m }
  {
    \fontspec_if_fontspec_font:TF
      {
        \fontspec_if_opentype:TF
          {
            \fontspec_if_feature:nTF { +sups }
            { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
          {
            \fontspec_if_aat_feature:nnTF {10} {1}
              { \__realscripts_numtosup:x {#1} }
              { \fakesuperscript {#1} }
          }
      }
      { \fakesuperscript {#1} }
  }
\ExplSyntaxOff

\usepackage{endnotes}
\usepackage{etoolbox}
\preto{\theendnotes}{%
  \renewcommand{\makeenmark}{\textsuperscript{\theenmark}\enspace}%
}
\makeatletter
\def\@makeenmark{\unpenalty{\footnotemarkfont\textsuperscript{\@theenmark}}}
\makeatother
\let\footnote\endnote

\usepackage[style=philosophy-verbose, scauthors=all, lowscauthors=true,
  giveninits, classical=true, volnumformat=strings, volumeformat=romansc,
  sorting=nyt, commacit=true, citepages=omit, editionformat=superscript,
  indexing]{biblatex}
\addbibresource{\jobname.bib}
\nocite{*}

\makeatletter
\DeclareFieldFormat{edition}{%
  \ifinteger{#1}{%
    \ifdefstring{\bbx@editionformat}{arabic}
    {\mkbibordedition{#1}~\bibstring{edition}}
    {\ifdefstring{\bbx@editionformat}{Roman}%
      {\RN{#1}~\bibstring{edition}}%
      {\ifdefstring{\bbx@editionformat}{romansc}%
        {\textsc{\Rn{#1}}~\bibstring{edition}}%
        {\ifdefstring{\bbx@editionformat}{roman}%
          {\Rn{#1}~\bibstring{edition}}
          {\ifdefstring{\bbx@editionformat}{superscript}%
            {\textsuperscript{#1}}%
            {\optionerror{editionformat}}}}}}}{#1}}%\isdot??
\makeatother

\begin{document}

A\footnote{Footnote text}.

A\footnote{Footnote text},

A\footnote{Footnote text};

A\footcite[53]{stegmuller:1976}.

\theendnotes

\printbibliography
\end{document}

output

David Purton
  • 25,884
  • Thanx a lot!! I add an update for a more complex situation – user41063 Apr 09 '19 at 18:14
  • @user41063, it works fine with biblatex. Your MWE has some errors in it and you haven't included the custom kerning between super scripts and punctuation which is not present in Source Serif Pro. I'll update my answer to show that it works. – David Purton Apr 10 '19 at 01:24
  • Yes, you're right. For a copy/paste error the original code didn't work. I made some trial, your code works fine. But in the original text I'm working around I've a (for me) incomprehensible. I added a LAST UPDATE with that code. Thank you again – user41063 Apr 10 '19 at 17:26
  • @user41063 one error is that you should not have jobname.bib after \end{filecontents}. – David Purton Apr 10 '19 at 21:54
  • 1
    @user41063. That's the only error. BTW, typically we use \jobname.bib, rather than jobname.bib. This makes the temporary bib file have the same name as the tex file. – David Purton Apr 11 '19 at 00:38
  • I have modified the code according to your correct remarks. Then, I went to trial and error because I didn't understand what was blocking the compilation, and finally I found. I updated the code and reported the cause of the problem: the edition number ... The MWE is now updated to show the error – user41063 Apr 11 '19 at 12:30
  • @user41063, this happens because of how the edition is printed. The argument to \textsuperscript is not expandable. It is possible to work around this by slightly redefining the edition field format. But you will run into other problems whenever the argument to \textsuperscript is unexpandable. – David Purton Apr 11 '19 at 14:23
  • I'll ask to 'philosophy' package author. For at present I I see no other way out – user41063 Apr 11 '19 at 15:25
  • @user41063, \mkbibsuperscript is actually a core biblatex function. But this is just one example of what might end up in the argument to \textsuperscript that won't work. There could be all kinds of things. – David Purton Apr 12 '19 at 02:19
  • I see this it's a dangerous affair. Unfortunately these interferences do not always make the code for the kerning of superscript numbers applicable. A small flaw in LaTeX's excellent font management – user41063 Apr 12 '19 at 13:22
  • Thanx again, I'll test your last code for my purpose. Can I apply it to the old code for foot- (and not end-) note ? – user41063 Apr 13 '19 at 16:21
  • @user41063, yes should be fine to do this. – David Purton Apr 13 '19 at 22:33
  • Yes, tested and works fine! – user41063 Apr 13 '19 at 22:58
  • I apologize for the late reply. however in these days I have tested the code in some of my files and so far I have not encountered problems. My files are essentially relatively simple non-mathematical texts and everything seems to be going well. I will report any problems: for the moment, thank you very much! – user41063 Apr 18 '19 at 09:14