如何使用微类型通过 \fnsymbol 启用脚注的突出功能?

如何使用微类型通过 \fnsymbol 启用脚注的突出功能?

microtype 包 (v.2.5 beta 06) 和脚注突出,脚注数字的自定义突出功能已启用。但是,只要我将脚注字符编辑为生成的字符\fnsymbol并更改要突出的相应字符,它就会停止工作。以下是带数字的脚注的 MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\geometry{a5paper,showframe}
\usepackage[protrusion=true,factor=2000]{microtype}
\SetProtrusion[context=footnote]{encoding=T1}{1={,650}}    

\makeatletter
\newcommand*\new@makefnmark{\hbox{\@textsuperscript{\normalfont
    \microtypecontext{protrusion=footnote}\@thefnmark}}}
\renewcommand*\@footnotemark{%
    \leavevmode \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
    \new@makefnmark \ifhmode\spacefactor\@x@sf\fi \relax}
\makeatother

\begin{document}
Here's some text to show the behaviour of footnote marker at%
%
\footnote{A footnote}
%
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.
\end{document}

这是脚注的 MWE,其符号定义为\fnsymbol

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}
\geometry{a5paper,showframe}
\usepackage[protrusion=true,factor=2000]{microtype}
\SetProtrusion[context=footnote]{encoding=T1}{*={,650}}    
%\SetProtrusion[context=footnote]{encoding=T1}{\ast={,650}}    
%\SetProtrusion[context=footnote]{encoding=T1}{\textasteriskcentered={,650}}    
% None of the above work

\makeatletter
\newcommand*\new@makefnmark{\hbox{\@textsuperscript{\normalfont
    \microtypecontext{protrusion=footnote}\@thefnmark}}}
\renewcommand*\@footnotemark{%
    \leavevmode \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
    \new@makefnmark \ifhmode\spacefactor\@x@sf\fi \relax}
\makeatother

\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
Here's some text to show the behaviour of footnote marker at%
%
\footnote{A footnote}
%
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.
\end{document}

但是,根据的定义\@fnsymbol,我知道第一个脚注的符号是*

\fnsymbol=macro:
#1->\expandafter \@fnsymbol \csname c@#1\endcsname

\@fnsymbol=macro:
#1->\ensuremath {\ifcase #1\or *\or \dagger \or \ddagger \or \mathsection \or     mathparagraph \or \|\or **\or \dagger \dagger \or \ddagger \ddagger \else \@ctr
err \fi }

所以我的问题是,如何microtype正确配置才能使其工作?请注意,我使用的是microtypev2.5。以下是我运行不工作的 MWE 时遇到的错误:

Package microtype Warning: I cannot find a protrusion list for font
(microtype)                `OT1/lmr/m/n/7' (context: `footnote'). Switching off
(microtype)                protrusion for this font on input line 20.


Package microtype Warning: I cannot find a protrusion list for font
(microtype)                `OT1/lmr/m/n/5' (context: `footnote'). Switching off
(microtype)                protrusion for this font on input line 20.


Package microtype Warning: I cannot find a protrusion list for font
(microtype)                `OT1/lmr/m/n/10' (context: `footnote'). Switching off
(microtype)                protrusion for this font on input line 20.

答案1

首先,让我们使它与 一起工作hyperrefhyperref重新定义\@footnotemark自身,因此我们不需要覆盖它,而是只需用etoolbox包对其进行修补。

\usepackage{etoolbox}
...
\makeatletter
\newcommand*\new@makefnmark{\hbox{\@textsuperscript{\normalfont
    \microtypecontext{protrusion=footnote}\@thefnmark}}}
\patchcmd{\@footnotemark}
  {\@makefnmark}
  {\new@makefnmark}{}{}
\makeatother

接下来,让我们突出脚注标记。我们定义要突出的字体。我选择了默认设置alltext,加上脚注符号的字体:

\DeclareMicrotypeSet{alltextAndFootnotes}{%
  encoding = {OT1,T1,T2A,LY1,OT4,QX,T5,TS1,EU1,EU2}, %% alltext
  font     = {OMS/lmsy/m/n/scriptsize},
}

接下来,我们告诉microtype它这是我们想要突出的字体集:

\microtypesetup{protrusion=alltextAndFootnotes}

现在我们可以定义实际的突起:

\SetProtrusion[context=footnote]{encoding=OMS, family=lmsy,series=m, shape=n, size=scriptsize}{%
  "03={,650},%% *
  "78={,650},%% \mathsection
  "79={,650},%% \dagger
  "7A={,650},%% \ddagger
  "7B={,650},%% \mathparagraph
  "6B={,650},%% \|
  }

这已经足够了,但是microtype抱怨它没有等的突起设置T1/lmr/m/n/7OT1/lmr/m/n/7所以让我们提供一些:

\SetProtrusion[context=footnote,load=lmr-T1,factor = 700]
  {encoding=T1, family=lmr, series=m, shape=n, size=scriptsize}
  {  }
\SetProtrusion[context=footnote,load=cmr-OT1,factor = 700]
  {encoding=OT1, family=lmr, series=m, shape=n}
  {  }

我们只是使用 T1 编码的 Latin Modern Roman 和 OT1 编码的 Computer Modern 的默认凸出设置,并稍微缩小一点。根据自己的喜好进行更改。

完成 MWE:

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{etoolbox}

\usepackage{geometry}
\geometry{a5paper,showframe}

\usepackage[colorlinks]{hyperref}


\usepackage[protrusion=alltext,factor=2000]{microtype}

\DeclareMicrotypeSet{alltextAndFootnotes}{%
  encoding = {OT1,T1,T2A,LY1,OT4,QX,T5,TS1,EU1,EU2}, %% alltext
  font     = {OMS/lmsy/m/n/scriptsize},
}

\microtypesetup{protrusion=alltextAndFootnotes}
\SetProtrusion[context=footnote]{encoding=OMS, family=lmsy,series=m, shape=n, size=scriptsize}{%
  "03={,650},%% *
  "78={,650},%% \mathsection
  "79={,650},%% \dagger
  "7A={,650},%% \ddagger
  "7B={,650},%% \mathparagraph
  "6B={,650},%% \|
  }
\SetProtrusion[context=footnote,load=lmr-T1,factor = 700]
  {encoding=T1, family=lmr, series=m, shape=n, size=scriptsize}
  {  }
\SetProtrusion[context=footnote,load=cmr-OT1,factor = 700]
  {encoding=OT1, family=lmr, series=m, shape=n}
  {  }

\makeatletter
\newcommand*\new@makefnmark{\hbox{\@textsuperscript{\normalfont
    \microtypecontext{protrusion=footnote}\@thefnmark}}}
\patchcmd{\@footnotemark}
  {\@makefnmark}
  {\new@makefnmark}{}{}
\makeatother

\renewcommand{\thefootnote}{\fnsymbol{footnote}}

%% --------------------------------------------------------------
%% --------------------------------------------------------------
\begin{document}
Here's some text to show the behaviour of footnote marker at%
\footnote{A footnote}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{B}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{C}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{D}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{E}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{F}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{G}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{H}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.

Here's some text to show the behaviour of footnote marker at%
\footnote{I}
the end of a line, which disappears when the code for setting  microtypecontext is used in fnmark redefinition.
\end{document}

这使

示例输出

相关内容