5

How can I modify the following code to also make the footnote text blue (globally, for all footnotes), like the body text?

\documentclass{article}
\usepackage{color}
\begin{document}
\color{blue}

This is sample text.\footnote{See page 1.}

\end{document}

I'm weaving Rnw files with knitr and typesetting LaTeX into PDF using pdfLaTeX.

  • 1
    Welcome to TeX.sx! – Peter Jansson Apr 23 '13 at 20:32
  • 1
    @azetina that doesn't fix the footnotemarker as the color comes too late – Frank Mittelbach Apr 23 '13 at 20:52
  • 1
    For what it's worth: KOMA-Script classes offer \addtokomafont{footnote}{\color{blue}} and \addtokomafont{footnoterule}{\color{blue}} – cgnieder Apr 23 '13 at 21:11
7

Open the class file you use, e.g., article.cls and search for the definition of the command \@makefntext. Copy that to the preamble of your document and modify it to add some color command to it, e.g., for the article class:

\makeatletter
\newcommand\@makefntext[1]{%
    \parindent 1em%
    \noindent
    \color{blue}%                        % <----
    \hb@xt@1.8em{\hss\@makefnmark}#1}
\makeatother

However, I guess you aren't just interested in getting the footnotes in the right color, but perhaps all of the text? If so then there is a much simpler way: put your \color{blue} before \begin{document} then blue will be used whenever \normalcolor is called and that means in \marginpar, \footnote...

  • I wish one did not have to hack into the original definition of core commands for simple changes like changing color or style. I completely understand why this is the case (limited CPU resources when LaTeX started), but wish backward compatibility did not have such a huge price. – Aditya Apr 23 '13 at 20:56
  • 2
    @Aditya you don't really, you only need to if you stick to the basic compatibility classes (which most people do) ... perhaps we should put out a really comprehensive class compared to memoir or others and stick it into the base distribution – Frank Mittelbach Apr 23 '13 at 21:01
  • 1
    I believe that introducing an official (i.e., something in base) comprehensive class (and, of course, updating all introductory guides to ask users to use such a class) will go a long with in getting rid of the misconception that LaTeX is hard to use. – Aditya Apr 23 '13 at 21:06
  • @FrankMittelbach Putting \color{blue} before \begin{document} solved the issue. Thank you. – Adam Smith Apr 23 '13 at 21:21
  • @AdamSmith if one or the other answer solve sour problem you may want to checkmark it to indicate this – Frank Mittelbach Apr 24 '13 at 7:22
4

For comparison, ConTeXt provides a \setupnotation[footnote] command that can be used to change the color of the footnote (and the footnote symbol).

\setuppapersize[S3]

\setupcolors[textcolor=blue]
\setupnotation[footnote][color=blue, headcolor=blue]

\starttext
This is sample text.\footnote{See page 1.}
\stoptext

enter image description here

  • 3
    yep clearly better interface compared to what was designed a decade or two earlier. – Frank Mittelbach Apr 23 '13 at 20:58
4
\documentclass{article}
\usepackage{xcolor, footmisc, bigfoot}
\def\footnotelayout{\color{blue}}
\begin{document}
\color{blue}

This is sample text.\footnote{See page 1.}

\end{document}

bigfoot, because it deals with the colour stack in case of page breaks. footmisc, because it offers the command footnotelayout. And this answer comes from robin fairbairns, see here: http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2008-05/msg01367.html

  • I tried this first and it almost did what I needed, but the color of the actual number in the footnote text was left unchanged. Thanks for the input and the package suggestions. – Adam Smith Apr 23 '13 at 21:22
  • I haven't got time right now, but search this forum for colour and footnote and you'll get quite a lot suggestions how to get the marks colored as well. – Keks Dose Apr 24 '13 at 6:28

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.