2

I want to change the color of my footnotes, but I'm running into a problem with long footnotes

I'm using memoir and to change the color of footnotes, I can use \renewcommand{\foottextfont}{\color{gray}\footnotesize}. However, with footnotes that overflow to the next page, the color disappears in the next page.

So MWE gives:

\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}

gives enter image description here

Update 2: Using the solution provided in the answer below, using the package pdfcolfoot, creates a new problem when there are more than two footnotes on the page. The color will overflow to the main text of the next page until the [n-2]th footmarker on the next page where n is the number of footnotes on the previous page. So when there are three footnotes, the color stops at the first maker, when there are four, it stops at the second, etc.

MWE reproducing the problem:

\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}

Creates: enter image description here

Seeing as how this problem is consistent with the number of footnotes on the previous page, it seems as it should be fixable, but I have no idea how.

1
  • 2
    Package pdfcolfoot is designed for this situation and works with pdftex and luatex, but it seems to be incompatible with memoir. Dec 16 '20 at 2:29
1

Use the pdfcolfoot package which works with memoir when processed by at least pdflatex and lualatex.

% 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}
4
  • I didn't menton this in the MWE because I didn't think it'd matter, but I'm using xelatex. I've updated the question. (Also using both bigfoot and pdfcolfoot throws an error in lualatex and pdflatex)
    – cktai
    Dec 16 '20 at 20:19
  • @cktai I can't get xelatex installed so I can't check what that does but I have a suspicion that it might not like the pdfcolfoot package as I have no recollection of complaints about using xelatex to process the memoir class. Dec 17 '20 at 18:36
  • 1
    I thought I needed xelatex for fontspec but I don't. So I switched to lualatex and now the solution works as expected.
    – cktai
    Dec 27 '20 at 11:50
  • I encountered a new problem where the colouring overflows to the text of the next page. I updated the question.
    – cktai
    Dec 27 '20 at 19:06
1

The solution is to use fontspec to set a font with a color instead of using xcolor directly.

So the working MWE becomes:

\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}

Changing the font does not change the color of the footnotemarker but that is easily fixed in memoir with \footmarkstyle.

ADDED LATER: Two issues came up while using this solution.

The first is that in the original solution, TeX shortcuts like -- for an en-dash did not work. To fix this, add the option Ligatures=TeX when calling the colored font (I added this to the MWE because I expect this to be standard desired behaviour)

The second is that colors did not work in the footnotes. For colorlinks in the hyperref package specifically, you can solve this by adding the following lines in the preamble:

    \makeatletter
    \def\HyColor@@@@UseColor#1\@nil{\addfontfeatures{Color=#1}}
    \makeatother
1
  • Please note that it will give problems if you want to use colors within the colored footnotes now
    – cktai
    Dec 28 '20 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.