Kerning (with realscripts) not in footnotes marker












3















Plz, consider the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{<myfont>}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

end{document}


The resulting .pdf in the following pic:



enter image description here



Obviously, I set a paroxysmal kerning between number 1 and period only for testing reasons. You'll note the kerning works with the last line of the code, but it's not applied to superscript notes marker. Why?



Update



I tried the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Source Serif Pro}

directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["one.superior"] = { ["period"] = -250 },
},
}
}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

A{addfontfeature{RawFeature=+sups}1.}

A{addfontfeature{RawFeature=+supkern;+sups}1.}

end{document}


but directlua doesn't produce any result and the last two line unnecessary, for period is itself superscrit. What's wrong?



Further update



Try this code:



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
},
}
}

usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}
usepackage{realscripts}
usepackage{perpage}
MakePerPage{footnote}
usepackage[bottom,hang,stable,norule]{footmisc} % perpage
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}

makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found_bool
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found_bool
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found_bool
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found_bool
{ use_none:n }
{ __realscripts_footnote:n { l__realscripts_footnote_text_tl } }
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff

begin{document}

chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.

end{document}


You'll realize that something strange happens: no footnote 1!










share|improve this question

























  • It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

    – Ulrike Fischer
    Feb 9 at 23:17






  • 1





    The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

    – Henri Menke
    Feb 10 at 2:45


















3















Plz, consider the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{<myfont>}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

end{document}


The resulting .pdf in the following pic:



enter image description here



Obviously, I set a paroxysmal kerning between number 1 and period only for testing reasons. You'll note the kerning works with the last line of the code, but it's not applied to superscript notes marker. Why?



Update



I tried the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Source Serif Pro}

directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["one.superior"] = { ["period"] = -250 },
},
}
}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

A{addfontfeature{RawFeature=+sups}1.}

A{addfontfeature{RawFeature=+supkern;+sups}1.}

end{document}


but directlua doesn't produce any result and the last two line unnecessary, for period is itself superscrit. What's wrong?



Further update



Try this code:



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
},
}
}

usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}
usepackage{realscripts}
usepackage{perpage}
MakePerPage{footnote}
usepackage[bottom,hang,stable,norule]{footmisc} % perpage
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}

makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found_bool
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found_bool
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found_bool
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found_bool
{ use_none:n }
{ __realscripts_footnote:n { l__realscripts_footnote_text_tl } }
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff

begin{document}

chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.

end{document}


You'll realize that something strange happens: no footnote 1!










share|improve this question

























  • It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

    – Ulrike Fischer
    Feb 9 at 23:17






  • 1





    The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

    – Henri Menke
    Feb 10 at 2:45
















3












3








3


1






Plz, consider the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{<myfont>}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

end{document}


The resulting .pdf in the following pic:



enter image description here



Obviously, I set a paroxysmal kerning between number 1 and period only for testing reasons. You'll note the kerning works with the last line of the code, but it's not applied to superscript notes marker. Why?



Update



I tried the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Source Serif Pro}

directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["one.superior"] = { ["period"] = -250 },
},
}
}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

A{addfontfeature{RawFeature=+sups}1.}

A{addfontfeature{RawFeature=+supkern;+sups}1.}

end{document}


but directlua doesn't produce any result and the last two line unnecessary, for period is itself superscrit. What's wrong?



Further update



Try this code:



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
},
}
}

usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}
usepackage{realscripts}
usepackage{perpage}
MakePerPage{footnote}
usepackage[bottom,hang,stable,norule]{footmisc} % perpage
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}

makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found_bool
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found_bool
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found_bool
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found_bool
{ use_none:n }
{ __realscripts_footnote:n { l__realscripts_footnote_text_tl } }
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff

begin{document}

chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.

end{document}


You'll realize that something strange happens: no footnote 1!










share|improve this question
















Plz, consider the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{<myfont>}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

end{document}


The resulting .pdf in the following pic:



enter image description here



Obviously, I set a paroxysmal kerning between number 1 and period only for testing reasons. You'll note the kerning works with the last line of the code, but it's not applied to superscript notes marker. Why?



Update



I tried the following code:



documentclass[a4paper,12pt]{article}
usepackage{fontspec}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Source Serif Pro}

directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["one.superior"] = { ["period"] = -250 },
},
}
}

frenchspacing

ExplSyntaxOn
cs_new: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

begin{document}
nullvfill
In text numbers: 0123456789

To befootnote{xxx}. or not to befootnote{xxx}: that is the questionfootnote{xxx}:
Whether ‘tis nobler in the mind to sufferfootnote{xxx}
The slings and arrows of outrageous fortunefootnote{xxx},
Or to take arms against a sea of troublesfootnote{xxx},
And by opposing end themfootnote{xxx}? To die: to sleepfootnote{xxx};
No morefootnote{xxx}; and by a sleepfootnote{xxx} to say we endfootnote{xxx}
The heart-achefootnote{xxx} and the thousand natural shocksfootnote{xxx}
That flesh is heir to, ‘tis a consummationfootnote{xxx}
Devoutly to be wish’dfootnote{xxx}. To die, to sleepfootnote{xxx};

A{addfontfeatures{VerticalPosition=Superior}0123456789}.

A{textsuperscript{9876543210}}.

A{addfontfeatures{VerticalPosition=Superior}321}.

A{textsuperscript{321}}.

A{addfontfeature{RawFeature=+sups}1.}

A{addfontfeature{RawFeature=+supkern;+sups}1.}

end{document}


but directlua doesn't produce any result and the last two line unnecessary, for period is itself superscrit. What's wrong?



Further update



Try this code:



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
},
}
}

usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}
usepackage{realscripts}
usepackage{perpage}
MakePerPage{footnote}
usepackage[bottom,hang,stable,norule]{footmisc} % perpage
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}

makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found_bool
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found_bool
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found_bool
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found_bool
{ use_none:n }
{ __realscripts_footnote:n { l__realscripts_footnote_text_tl } }
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff

begin{document}

chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.

end{document}


You'll realize that something strange happens: no footnote 1!







footnotes kerning






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 13 at 18:48







user41063

















asked Feb 9 at 22:22









user41063user41063

7931511




7931511













  • It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

    – Ulrike Fischer
    Feb 9 at 23:17






  • 1





    The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

    – Henri Menke
    Feb 10 at 2:45





















  • It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

    – Ulrike Fischer
    Feb 9 at 23:17






  • 1





    The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

    – Henri Menke
    Feb 10 at 2:45



















It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

– Ulrike Fischer
Feb 9 at 23:17





It would be better if you would make an example with a real font that exists also on our systems and not with a <myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. tex.stackexchange.com/questions/312154/….

– Ulrike Fischer
Feb 9 at 23:17




1




1





The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

– Henri Menke
Feb 10 at 2:45







The kerning is not applied to footnote marks because the marker is wrapped in a box. LaTeX defines def@makefnmark{hbox{@textsuperscript{normalfont@thefnmark}}}

– Henri Menke
Feb 10 at 2:45












1 Answer
1






active

oldest

votes


















4














I updated my answer to your previous question before seeing this one. For the sake of getting the right things in the right place, here's my answer reproduced.



Your kerning problem is caused by the fact that the footnote mark is set inside an hbox. This destroys the kerning between 'A' and '¹'. Consider this code using my patched realsuperscript macro from below:



A{addfontfeatures{VerticalPosition=Superior}1}.
A{textsuperscript{1}}.
Afootnote{1}.}


When we show this we get:



.TU/SourceSerifPro(0)/m/n/12 A
.TU/SourceSerifPro(1)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.kern-1.68 (font)
.TU/SourceSerifPro(0)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.penalty 10000
.hbox(9.936+0.0)x4.44, direction TLT
..TU/SourceSerifPro(0)/m/n/12 ¹
.insert253, natural size 12.00003; split(8.4,3.60004); float cost 20000
..hbox(8.4+3.60004)x390.0, glue set 367.63995fil, direction TLT
...localpar
....localinterlinepenalty=0
....localbrokenpenalty=0
....localleftbox=null
....localrightbox=null
...hbox(8.28+0.0)x18.00003, glue set 14.30003fil, direction TLT
....glue 0.0 plus 1.0fil minus 1.0fil
....hbox(8.28+0.0)x3.7, direction TLT
.....TU/SourceSerifPro(0)/m/n/10 ¹
...hbox(8.4+0.0)x0.0, direction TLT
....rule(8.4+0.0)x0.0
...TU/SourceSerifPro(0)/m/n/10 󰀜
...penalty 10000
...rule(0.0+3.60004)x0.0
...penalty 10000
...glue(parfillskip) 0.0 plus 1.0fil
...glue(rightskip) 0.0
.TU/SourceSerifPro(0)/m/n/12 .


We can see that




  1. In the first case there is a font change and no kerning is inserted.

  2. In the second case there is no font change and kerning is inserted.

  3. In the third case there is a penalty and and then '¹' is placed inside an hbox and therefore no kerning is inserted even though there is no font change.

  4. I the third case the hbox with the footnote mark and the final period is separated by the float material for the footnote text. Therefore any kerning between '¹' and '.' is lost.


So to work around this two things are needed:




  1. Adjust the @makefnmark macro (previously adjusted from the default by the realscripts package) to remove the penalty and not to use the hbox. This could have unwanted side effects, of course :).

  2. Use Afootnotemark.footnotetext{…} instead of Afootnote{…}.


The first could be achieved by using something like:



makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother


I have had a go at redefining footnote to test for punctuation and automatically deal with the second point.



MWE



Here's a full MWE (I added some directlua to add kerning between '¹' and '.' and ',' as Source Sans Serif does not include this). It also shows how to patch things to make it work with the perpage and stable options of the footmisc package.



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
["²"] = { ["."] = -180,
[","] = -180 },
["³"] = { ["."] = -180,
[","] = -180 },
["⁵"] = { ["."] = -180,
[","] = -180 },
},
}
}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}
usepackage[perpage,bottom,hang,stable,norule]{footmisc}
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}
usepackage{xpatch}
makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
ifFN@perpage
xpatchcmd{footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
xpretocmd{@footnotetext}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
ifFN@stablefootnote
xpatchcmd{FN@sf@@footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
fi
fi
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found
{
use_none:n
}
{
__realscripts_footnote:n { l__realscripts_footnote_text_tl }
}
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff
begin{document}
chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.
end{document}


output






share|improve this answer


























  • The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

    – user41063
    Feb 10 at 15:52











  • @user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

    – David Purton
    Feb 10 at 22:31











  • I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

    – user41063
    Feb 11 at 15:37











  • @user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

    – David Purton
    Feb 12 at 3:21











  • what a great work! now I make some testing... Thank you!

    – user41063
    Feb 12 at 16:59











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474116%2fkerning-with-realscripts-not-in-footnotes-marker%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














I updated my answer to your previous question before seeing this one. For the sake of getting the right things in the right place, here's my answer reproduced.



Your kerning problem is caused by the fact that the footnote mark is set inside an hbox. This destroys the kerning between 'A' and '¹'. Consider this code using my patched realsuperscript macro from below:



A{addfontfeatures{VerticalPosition=Superior}1}.
A{textsuperscript{1}}.
Afootnote{1}.}


When we show this we get:



.TU/SourceSerifPro(0)/m/n/12 A
.TU/SourceSerifPro(1)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.kern-1.68 (font)
.TU/SourceSerifPro(0)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.penalty 10000
.hbox(9.936+0.0)x4.44, direction TLT
..TU/SourceSerifPro(0)/m/n/12 ¹
.insert253, natural size 12.00003; split(8.4,3.60004); float cost 20000
..hbox(8.4+3.60004)x390.0, glue set 367.63995fil, direction TLT
...localpar
....localinterlinepenalty=0
....localbrokenpenalty=0
....localleftbox=null
....localrightbox=null
...hbox(8.28+0.0)x18.00003, glue set 14.30003fil, direction TLT
....glue 0.0 plus 1.0fil minus 1.0fil
....hbox(8.28+0.0)x3.7, direction TLT
.....TU/SourceSerifPro(0)/m/n/10 ¹
...hbox(8.4+0.0)x0.0, direction TLT
....rule(8.4+0.0)x0.0
...TU/SourceSerifPro(0)/m/n/10 󰀜
...penalty 10000
...rule(0.0+3.60004)x0.0
...penalty 10000
...glue(parfillskip) 0.0 plus 1.0fil
...glue(rightskip) 0.0
.TU/SourceSerifPro(0)/m/n/12 .


We can see that




  1. In the first case there is a font change and no kerning is inserted.

  2. In the second case there is no font change and kerning is inserted.

  3. In the third case there is a penalty and and then '¹' is placed inside an hbox and therefore no kerning is inserted even though there is no font change.

  4. I the third case the hbox with the footnote mark and the final period is separated by the float material for the footnote text. Therefore any kerning between '¹' and '.' is lost.


So to work around this two things are needed:




  1. Adjust the @makefnmark macro (previously adjusted from the default by the realscripts package) to remove the penalty and not to use the hbox. This could have unwanted side effects, of course :).

  2. Use Afootnotemark.footnotetext{…} instead of Afootnote{…}.


The first could be achieved by using something like:



makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother


I have had a go at redefining footnote to test for punctuation and automatically deal with the second point.



MWE



Here's a full MWE (I added some directlua to add kerning between '¹' and '.' and ',' as Source Sans Serif does not include this). It also shows how to patch things to make it work with the perpage and stable options of the footmisc package.



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
["²"] = { ["."] = -180,
[","] = -180 },
["³"] = { ["."] = -180,
[","] = -180 },
["⁵"] = { ["."] = -180,
[","] = -180 },
},
}
}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}
usepackage[perpage,bottom,hang,stable,norule]{footmisc}
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}
usepackage{xpatch}
makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
ifFN@perpage
xpatchcmd{footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
xpretocmd{@footnotetext}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
ifFN@stablefootnote
xpatchcmd{FN@sf@@footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
fi
fi
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found
{
use_none:n
}
{
__realscripts_footnote:n { l__realscripts_footnote_text_tl }
}
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff
begin{document}
chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.
end{document}


output






share|improve this answer


























  • The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

    – user41063
    Feb 10 at 15:52











  • @user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

    – David Purton
    Feb 10 at 22:31











  • I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

    – user41063
    Feb 11 at 15:37











  • @user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

    – David Purton
    Feb 12 at 3:21











  • what a great work! now I make some testing... Thank you!

    – user41063
    Feb 12 at 16:59
















4














I updated my answer to your previous question before seeing this one. For the sake of getting the right things in the right place, here's my answer reproduced.



Your kerning problem is caused by the fact that the footnote mark is set inside an hbox. This destroys the kerning between 'A' and '¹'. Consider this code using my patched realsuperscript macro from below:



A{addfontfeatures{VerticalPosition=Superior}1}.
A{textsuperscript{1}}.
Afootnote{1}.}


When we show this we get:



.TU/SourceSerifPro(0)/m/n/12 A
.TU/SourceSerifPro(1)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.kern-1.68 (font)
.TU/SourceSerifPro(0)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.penalty 10000
.hbox(9.936+0.0)x4.44, direction TLT
..TU/SourceSerifPro(0)/m/n/12 ¹
.insert253, natural size 12.00003; split(8.4,3.60004); float cost 20000
..hbox(8.4+3.60004)x390.0, glue set 367.63995fil, direction TLT
...localpar
....localinterlinepenalty=0
....localbrokenpenalty=0
....localleftbox=null
....localrightbox=null
...hbox(8.28+0.0)x18.00003, glue set 14.30003fil, direction TLT
....glue 0.0 plus 1.0fil minus 1.0fil
....hbox(8.28+0.0)x3.7, direction TLT
.....TU/SourceSerifPro(0)/m/n/10 ¹
...hbox(8.4+0.0)x0.0, direction TLT
....rule(8.4+0.0)x0.0
...TU/SourceSerifPro(0)/m/n/10 󰀜
...penalty 10000
...rule(0.0+3.60004)x0.0
...penalty 10000
...glue(parfillskip) 0.0 plus 1.0fil
...glue(rightskip) 0.0
.TU/SourceSerifPro(0)/m/n/12 .


We can see that




  1. In the first case there is a font change and no kerning is inserted.

  2. In the second case there is no font change and kerning is inserted.

  3. In the third case there is a penalty and and then '¹' is placed inside an hbox and therefore no kerning is inserted even though there is no font change.

  4. I the third case the hbox with the footnote mark and the final period is separated by the float material for the footnote text. Therefore any kerning between '¹' and '.' is lost.


So to work around this two things are needed:




  1. Adjust the @makefnmark macro (previously adjusted from the default by the realscripts package) to remove the penalty and not to use the hbox. This could have unwanted side effects, of course :).

  2. Use Afootnotemark.footnotetext{…} instead of Afootnote{…}.


The first could be achieved by using something like:



makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother


I have had a go at redefining footnote to test for punctuation and automatically deal with the second point.



MWE



Here's a full MWE (I added some directlua to add kerning between '¹' and '.' and ',' as Source Sans Serif does not include this). It also shows how to patch things to make it work with the perpage and stable options of the footmisc package.



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
["²"] = { ["."] = -180,
[","] = -180 },
["³"] = { ["."] = -180,
[","] = -180 },
["⁵"] = { ["."] = -180,
[","] = -180 },
},
}
}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}
usepackage[perpage,bottom,hang,stable,norule]{footmisc}
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}
usepackage{xpatch}
makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
ifFN@perpage
xpatchcmd{footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
xpretocmd{@footnotetext}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
ifFN@stablefootnote
xpatchcmd{FN@sf@@footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
fi
fi
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found
{
use_none:n
}
{
__realscripts_footnote:n { l__realscripts_footnote_text_tl }
}
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff
begin{document}
chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.
end{document}


output






share|improve this answer


























  • The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

    – user41063
    Feb 10 at 15:52











  • @user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

    – David Purton
    Feb 10 at 22:31











  • I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

    – user41063
    Feb 11 at 15:37











  • @user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

    – David Purton
    Feb 12 at 3:21











  • what a great work! now I make some testing... Thank you!

    – user41063
    Feb 12 at 16:59














4












4








4







I updated my answer to your previous question before seeing this one. For the sake of getting the right things in the right place, here's my answer reproduced.



Your kerning problem is caused by the fact that the footnote mark is set inside an hbox. This destroys the kerning between 'A' and '¹'. Consider this code using my patched realsuperscript macro from below:



A{addfontfeatures{VerticalPosition=Superior}1}.
A{textsuperscript{1}}.
Afootnote{1}.}


When we show this we get:



.TU/SourceSerifPro(0)/m/n/12 A
.TU/SourceSerifPro(1)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.kern-1.68 (font)
.TU/SourceSerifPro(0)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.penalty 10000
.hbox(9.936+0.0)x4.44, direction TLT
..TU/SourceSerifPro(0)/m/n/12 ¹
.insert253, natural size 12.00003; split(8.4,3.60004); float cost 20000
..hbox(8.4+3.60004)x390.0, glue set 367.63995fil, direction TLT
...localpar
....localinterlinepenalty=0
....localbrokenpenalty=0
....localleftbox=null
....localrightbox=null
...hbox(8.28+0.0)x18.00003, glue set 14.30003fil, direction TLT
....glue 0.0 plus 1.0fil minus 1.0fil
....hbox(8.28+0.0)x3.7, direction TLT
.....TU/SourceSerifPro(0)/m/n/10 ¹
...hbox(8.4+0.0)x0.0, direction TLT
....rule(8.4+0.0)x0.0
...TU/SourceSerifPro(0)/m/n/10 󰀜
...penalty 10000
...rule(0.0+3.60004)x0.0
...penalty 10000
...glue(parfillskip) 0.0 plus 1.0fil
...glue(rightskip) 0.0
.TU/SourceSerifPro(0)/m/n/12 .


We can see that




  1. In the first case there is a font change and no kerning is inserted.

  2. In the second case there is no font change and kerning is inserted.

  3. In the third case there is a penalty and and then '¹' is placed inside an hbox and therefore no kerning is inserted even though there is no font change.

  4. I the third case the hbox with the footnote mark and the final period is separated by the float material for the footnote text. Therefore any kerning between '¹' and '.' is lost.


So to work around this two things are needed:




  1. Adjust the @makefnmark macro (previously adjusted from the default by the realscripts package) to remove the penalty and not to use the hbox. This could have unwanted side effects, of course :).

  2. Use Afootnotemark.footnotetext{…} instead of Afootnote{…}.


The first could be achieved by using something like:



makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother


I have had a go at redefining footnote to test for punctuation and automatically deal with the second point.



MWE



Here's a full MWE (I added some directlua to add kerning between '¹' and '.' and ',' as Source Sans Serif does not include this). It also shows how to patch things to make it work with the perpage and stable options of the footmisc package.



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
["²"] = { ["."] = -180,
[","] = -180 },
["³"] = { ["."] = -180,
[","] = -180 },
["⁵"] = { ["."] = -180,
[","] = -180 },
},
}
}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}
usepackage[perpage,bottom,hang,stable,norule]{footmisc}
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}
usepackage{xpatch}
makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
ifFN@perpage
xpatchcmd{footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
xpretocmd{@footnotetext}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
ifFN@stablefootnote
xpatchcmd{FN@sf@@footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
fi
fi
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found
{
use_none:n
}
{
__realscripts_footnote:n { l__realscripts_footnote_text_tl }
}
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff
begin{document}
chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.
end{document}


output






share|improve this answer















I updated my answer to your previous question before seeing this one. For the sake of getting the right things in the right place, here's my answer reproduced.



Your kerning problem is caused by the fact that the footnote mark is set inside an hbox. This destroys the kerning between 'A' and '¹'. Consider this code using my patched realsuperscript macro from below:



A{addfontfeatures{VerticalPosition=Superior}1}.
A{textsuperscript{1}}.
Afootnote{1}.}


When we show this we get:



.TU/SourceSerifPro(0)/m/n/12 A
.TU/SourceSerifPro(1)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.kern-1.68 (font)
.TU/SourceSerifPro(0)/m/n/12 ¹
.TU/SourceSerifPro(0)/m/n/12 .
.glue(spaceskip) 3.72801 plus 4.19398 minus 0.31067
.TU/SourceSerifPro(0)/m/n/12 A
.penalty 10000
.hbox(9.936+0.0)x4.44, direction TLT
..TU/SourceSerifPro(0)/m/n/12 ¹
.insert253, natural size 12.00003; split(8.4,3.60004); float cost 20000
..hbox(8.4+3.60004)x390.0, glue set 367.63995fil, direction TLT
...localpar
....localinterlinepenalty=0
....localbrokenpenalty=0
....localleftbox=null
....localrightbox=null
...hbox(8.28+0.0)x18.00003, glue set 14.30003fil, direction TLT
....glue 0.0 plus 1.0fil minus 1.0fil
....hbox(8.28+0.0)x3.7, direction TLT
.....TU/SourceSerifPro(0)/m/n/10 ¹
...hbox(8.4+0.0)x0.0, direction TLT
....rule(8.4+0.0)x0.0
...TU/SourceSerifPro(0)/m/n/10 󰀜
...penalty 10000
...rule(0.0+3.60004)x0.0
...penalty 10000
...glue(parfillskip) 0.0 plus 1.0fil
...glue(rightskip) 0.0
.TU/SourceSerifPro(0)/m/n/12 .


We can see that




  1. In the first case there is a font change and no kerning is inserted.

  2. In the second case there is no font change and kerning is inserted.

  3. In the third case there is a penalty and and then '¹' is placed inside an hbox and therefore no kerning is inserted even though there is no font change.

  4. I the third case the hbox with the footnote mark and the final period is separated by the float material for the footnote text. Therefore any kerning between '¹' and '.' is lost.


So to work around this two things are needed:




  1. Adjust the @makefnmark macro (previously adjusted from the default by the realscripts package) to remove the penalty and not to use the hbox. This could have unwanted side effects, of course :).

  2. Use Afootnotemark.footnotetext{…} instead of Afootnote{…}.


The first could be achieved by using something like:



makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
makeatother


I have had a go at redefining footnote to test for punctuation and automatically deal with the second point.



MWE



Here's a full MWE (I added some directlua to add kerning between '¹' and '.' and ',' as Source Sans Serif does not include this). It also shows how to patch things to make it work with the perpage and stable options of the footmisc package.



documentclass[a4paper,12pt]{book}
usepackage{fontspec}
directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
["²"] = { ["."] = -180,
[","] = -180 },
["³"] = { ["."] = -180,
[","] = -180 },
["⁵"] = { ["."] = -180,
[","] = -180 },
},
}
}
usepackage{realscripts}
usepackage[english]{babel}
babelfont[english]{rm}[Ligatures=TeX,Language=Default,Numbers={Proportional,OldStyle},RawFeature=+supkern]{Source Serif Pro}
usepackage[perpage,bottom,hang,stable,norule]{footmisc}
renewcommand{footnotemargin}{0.01em}
renewcommand{hangfootparskip}{0pt}
renewcommand{footnotelayout}{hspace{1em}}
usepackage{xpatch}
makeatletter
def@makefnmark{unpenalty{footnotemarkfonttextsuperscript{@thefnmark}}}
ifFN@perpage
xpatchcmd{footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
xpretocmd{@footnotetext}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
ifFN@stablefootnote
xpatchcmd{FN@sf@@footnotemark}
{ifFN@pp@towrite
FN@pp@writetemp
FN@pp@towritefalse
fi}
{}
{}
{}
fi
fi
makeatother
ExplSyntaxOn
bool_new:N l__realscripts_punct_found
tl_new:N l__realscripts_footnote_text_tl
cs_set_eq:NN __realscripts_footnote:n footnote
cs_new_protected:Nn __realscripts_footnote_with_punct:
{
bool_set_false:N l__realscripts_punct_found
str_map_inline:nn { ., }
{
token_if_eq_meaning:NNT l_peek_token ##1
{
footnotemark
l_peek_token
footnotetext { l__realscripts_footnote_text_tl }
bool_set_true:N l__realscripts_punct_found
str_map_break:
}
}
bool_if:NTF l__realscripts_punct_found
{
use_none:n
}
{
__realscripts_footnote:n { l__realscripts_footnote_text_tl }
}
}
cs_new_protected:Nn __realscripts_footnote_with_punct:n
{
tl_set:Nn l__realscripts_footnote_text_tl {#1}
peek_after:Nw __realscripts_footnote_with_punct:
}
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} }
}
DeclareDocumentCommand footnote { +m }
{
__realscripts_footnote_with_punct:n {#1}
}
ExplSyntaxOff
begin{document}
chapter{Test chapter}

«text»footnote{Footnote text}.

Afootnote{Footnote text}.

Afootnote{Footnote text},

Afootnote{Footnote text};

Afootnote{Footnote text}.
end{document}


output







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 14 at 0:32

























answered Feb 10 at 11:25









David PurtonDavid Purton

9,8251936




9,8251936













  • The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

    – user41063
    Feb 10 at 15:52











  • @user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

    – David Purton
    Feb 10 at 22:31











  • I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

    – user41063
    Feb 11 at 15:37











  • @user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

    – David Purton
    Feb 12 at 3:21











  • what a great work! now I make some testing... Thank you!

    – user41063
    Feb 12 at 16:59



















  • The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

    – user41063
    Feb 10 at 15:52











  • @user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

    – David Purton
    Feb 10 at 22:31











  • I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

    – user41063
    Feb 11 at 15:37











  • @user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

    – David Purton
    Feb 12 at 3:21











  • what a great work! now I make some testing... Thank you!

    – user41063
    Feb 12 at 16:59

















The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

– user41063
Feb 10 at 15:52





The matter is complicated. Your code works well, however it interferes with other note management packages: for example if you use footmisc, you return to the starting situation ... no kerning

– user41063
Feb 10 at 15:52













@user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

– David Purton
Feb 10 at 22:31





@user41063, Make sure you load footmisc before you redefine @makefnmark, as footmisc also redefines this.

– David Purton
Feb 10 at 22:31













I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

– user41063
Feb 11 at 15:37





I tried, but it does not seem to work even when first loading the packages dedicated to managing the notes as footmisc

– user41063
Feb 11 at 15:37













@user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

– David Purton
Feb 12 at 3:21





@user41063, I included a redefinition of footnote and also the footmisc package to show that it does work.

– David Purton
Feb 12 at 3:21













what a great work! now I make some testing... Thank you!

– user41063
Feb 12 at 16:59





what a great work! now I make some testing... Thank you!

– user41063
Feb 12 at 16:59


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f474116%2fkerning-with-realscripts-not-in-footnotes-marker%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?