更改长脚注的脚注文本颜色

更改长脚注的脚注文本颜色

我想更改脚注的颜色,但遇到了长脚注的问题

我正在使用memoir和 来更改脚注的颜色,我可以使用\renewcommand{\foottextfont}{\color{gray}\footnotesize}。但是,如果脚注溢出到下一页,颜色会在下一页消失。

因此 MWE 给出:

\documentclass[a5paper]{memoir}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fontspec}
    \setmainfont{Linux Libertine O} 
\renewcommand{\foottextfont}{\color{gray}\footnotesize}
\begin{document}
\lipsum[1]\footnote{\lipsum[2-4]}\lipsum[5]\footnote{\lipsum[6]}
\end{document}

给出 在此处输入图片描述

更新 2:使用下面答案中提供的解决方案(使用包pdfcolfoot)会在页面上有两个以上的脚注时产生新问题。颜色将溢出到下一页的正文,直到下一页的第 [n-2] 个脚注标记,其中 n 是上一页的脚注数量。因此,当有三个脚注时,颜色会在第一个标记处停止,当有四个脚注时,颜色会在第二个标记处停止,依此类推。

MWE 重现了该问题:

\documentclass[a5paper]{memoir}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fontspec}
\setmainfont{Linux Libertine O} 
\usepackage{pdfcolfoot}
\renewcommand{\foottextfont}{\color{gray}\footnotesize}
\begin{document}
\lipsum[1]\footnote{footnote 1} This works fine.\footnote{footnote 2} This creates problems.\footnote{footnote 3} This creates even more problems.\footnote{footnote 4}

\lipsum[6-7]\footnote{first footmarker on next page} More text.\footnote{second footmarker on next page} 

\lipsum[9]
\end{document}

创建: 在此处输入图片描述

看到这个问题与上一页的脚注数量一致,似乎应该可以修复,但我不知道如何修复。

答案1

解决方法是使用fontspec设置颜色的字体而不是xcolor直接使用。

因此,工作的 MWE 变为:

\documentclass[a5paper]{memoir}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{fontspec}
\setmainfont{Linux Libertine O} 
\footmarkstyle{\color{gray}\textsuperscript{#1}}
\renewcommand{\foottextfont}{\fontspec[Color=gray,Ligatures=TeX]{Linux Libertine O}\footnotesize}

\begin{document}
    \lipsum[1]\footnote{\lipsum[2-4]}\lipsum[5]\footnote{\lipsum[6]}
\end{document}

更改字体不会改变脚注标记的颜色,但这可以在回忆录中轻松修复\footmarkstyle

后来补充:使用此解决方案时出现了两个问题。

首先,在原始解决方案中,TeX 快捷键(例如--en-dash)不起作用。要解决此问题,请Ligatures=TeX在调用彩色字体时添加选项(我将其添加到 MWE 中,因为我希望这是标准期望行为)

第二个问题是脚注中的颜色不起作用。具体到hyperref包中的颜色链接,您可以通过在序言中添加以下几行来解决这个问题:

    \makeatletter
    \def\HyColor@@@@UseColor#1\@nil{\addfontfeatures{Color=#1}}
    \makeatother

答案2

使用至少由和处理时pdfcolfoot与之一起工作的包。memoirpdflatexlualatex

% colfootprob.tex  SE 575204  process with pdflatex or lualatex

\documentclass[a5paper]{memoir}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{pdfcolfoot}
\renewcommand{\foottextfont}{\color{gray}\footnotesize}
\begin{document}
\lipsum[1]\footnote{\lipsum[2-4]}\lipsum[5]\footnote{\lipsum[6]}
\end{document}

相关内容