6

Original situation: I have several documents with text color changging in various frequency (few lines to many pages for each color). There are numerous footnotes in between, that should be colored identical to from where they are referenced. Recolor text, such that floats and footnotes are affected correctly points to a way how to accomplish this.

This does work in principle, unless a footnote is wrapped to the next page: then, both the color of the footnote and the main text get lost on the next page.

Color and pagebreaks with footnotes points to the pdfcolfoot package, that should fix this issue (via an extra pdftex color register for footnotes). But even if I do use it, the next page after the end of the footnote loses its colors.

The (inevitably Kantian) MWE:

\documentclass[a6paper,12pt]{article}
\usepackage{kantlipsum}
\usepackage{xcolor}
%\usepackage{pdfcolfoot} % Un-commented for the figure below.

\begin{document}
\color{blue}
\kant[3-4]
foo\footnote{\color{red}\kant[9-11]}
\kant[4-5]
\color{.}
\kant[5]
foo\footnote{\color{red}\kant[9-11]}
\kant[4-6]
\end{document}

Coloration gets lost after the end of multi-page footnotes, even with loaded pdfcolfoot

Expected result: the text on page 3 (and 5) should be in all blue. Text color nowhere got reset. It's only when I add a \color{.} (which should be a no-op), the engine remembers that text should be actually colored.

Obviously, the promise of pdfcolfoot is not satisfied, so this might also be a bug over there.

My low-level question: Is there some (proper or hacky) way to convince pdftex to start every page with active text coloration, irrespective on how many footnotes ended on the previous page?

A semantic solution would be some code or package that automagically synchronises footnotes with the font formatting state of the main text.

2
  • it's pretty tricky to get this right in tex, as the low level support just isn't there, luatex has more tools, or failing that you can get the right output if you are prepared to do some hand tuning of the markup, stopping and re-starting the footnote colour at the split point.. Jan 13, 2019 at 0:08
  • this is issue 1 raised on latex (by Frank, who's the leader of the latex project) the discussion there suggests that you might try the bigfoot package github.com/latex3/latex2e/issues/1 Jan 13, 2019 at 22:01

1 Answer 1

5

Update: in the newest version (1.4) of pdfcolfoot the bug has been resolved.

Old answer: A bit late to the party, but this is a bug in pdfcolfoot: It switches in the footnotes to the new color stack, but then forgets to add a group, and that means that the reset code after the footnote takes the color from the main stack.

\documentclass[a6paper,12pt]{article}
\usepackage{kantlipsum}
\usepackage{xcolor}
\usepackage{pdfcolfoot} % Un-commented for the figure below.
\makeatletter
\AtBeginDocument{%
  \renewcommand{\@makefntext}[1]{%
    \pdfcolfoot@makefntext{%
      \if@minipage
      \else
        \pdfcolfoot@switch
      \fi
      \color@begingroup %missing
      #1
      \color@endgroup% missing
    }%
  }%
}
\makeatother
\begin{document}
\color{blue} \kant[3-4] foo\footnote{\color{red}\kant[9-11]} \kant[4-5] 
\color{.} \kant[5] foo\footnote{\color{red}\kant[9-11]} \kant[4-6] 
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .