Text Formattingfootnote coloring

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
tuttoweb
Posts: 2
Joined: Fri May 13, 2011 12:26 pm

footnote coloring

Post by tuttoweb »

Hello guys,
I'm a brandnew latex user and I dont have any clue how to put some color in footnotes. I'm not refering at the text itself, but I want to colorize the footnote's number.
In addition, footnotes have different numerations for different chapters. I would like ti keep the same numeration for the whole document.
Thank you very much in advance.
vg

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

footnote coloring

Post by Stefan Kottwitz »

Hi,

welcome to the board!
  • One way is to redefine the internal macro \@makefnmark using color.
  • Regarding the counter, you could use the chngcntr package to customize it.
Here's a complete small example demonstrating both:

Code: Select all

\documentclass{book} 
\usepackage[svgnames]{xcolor}
\newcommand*{\footnotemarkcolor}{red}
\makeatletter
\renewcommand*{\@makefnmark}{\hbox{\@textsuperscript{%
  \color{\footnotemarkcolor}\normalfont\@thefnmark}}}
\makeatother
\usepackage{chngcntr}
\counterwithout{footnote}{chapter}
\begin{document}
\chapter{One}
Text\footnote{example}
\chapter{Two}
Text\footnote{second example}
\end{document}
Stefan
LaTeX.org admin
tuttoweb
Posts: 2
Joined: Fri May 13, 2011 12:26 pm

Re: footnote coloring

Post by tuttoweb »

thank you stefan. Everything is seems alright now, even though I didnt catch thoroughly the syntax. Could you possibly explain it please?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

footnote coloring

Post by Stefan Kottwitz »

Code: Select all

\usepackage[svgnames]{xcolor}
loads the package xcolor, which is more capable than the color package. The option svgnames allows to use many names such as Beige, Aqua, DarkViolet and a lot more.

Code: Select all

\newcommand*{\footnotemarkcolor}{red}
just defines a macro for the color, it's easier to change here than within another complex macro.

Code: Select all

\makeatletter
...
\makeatother
is necessary to use macros with an @ in the name, which usually mark internal macros.

Code: Select all

\renewcommand*{\@makefnmark}{\hbox{\@textsuperscript{%
  \color{\footnotemarkcolor}\normalfont\@thefnmark}}}
is a redefinition of the original LaTeX macro which prints out the footnote number. I just inserted the \color command.

Code: Select all

\usepackage{chngcntr}
\counterwithout{footnote}{chapter}
loads the chngcntr package, the second command removed the dependency of the footnote counter on the chapter counter.

Stefan
LaTeX.org admin
Post Reply