Text FormattingColored Footnotes

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jagged
Posts: 4
Joined: Sun Sep 04, 2011 12:35 pm

Colored Footnotes

Post by jagged »

High all,

this is a copy of an email I've sent to the author of the footmisc package already. Probably he's laughing at me, cos I do something completely senseless here...

Anyway, if anyone has a good advice, I'd be quite grateful.

Best regards,
Jagged
Actually this happens in V. 5.4a, but I took a look at the 5.5b docs and there is no use of the word "color" other than those in the source snippets, so I guess the problem still persists.

Since an image says more than 1000 words, I have included a minimal example latex file and the corresponding dvi (in case it compiles okay on your system).

In a few words, the problem occurs when in a footnote paragraph any footnote is followed by another one, which makes use of the \color makro in its footnote text, the former one(s) will not be typeset correctly, i. e.

1) if it is longer than a line, that line will not be broken,
2) the footnotes are positioned completely wrong (including overlapping the footnote separator)

and maybe more...

One funny point is that not (necessarily) the colored footnotes are typed incorrectly, but those preceding a colored one.

I can't imagine it has to do with \color being a fragile command, though I don't know; I'm not that much a TeXnician...

Also because I'm not such a TeXnician, it would be great to have a workaround in some time. My application is as follows: I make use of comments in my text, which are slightly lighter than the actual text body. They are not so aside that I put them in footnotes themselves. Now I come across a comment that takes up a while page, and I don't want the footnotes to drag the readers attention by being (in this scenario) notably darker than the actual page's text...

Well, if you could help me out, I'd be quite grateful...

Code: Select all

\documentclass[russian,english,10pt,a5paper,draft]{scrbook}
\usepackage{color}
  \definecolor{darkred}{rgb}{0.4,0,0}
\usepackage[para]{footmisc}

\begin{document}

\setlength{\parindent}{12pt}
\setlength{\parskip}{0\baselineskip}

When a \emph{long} footnote...\footnote{%
  like this one, which should serve at least one good purpose, to show how messed up things get...
} is followed by a colored one\footnote{%
  \color{darkred}like this... the strange thing is that the first one, with no custom color, is messed up, but not this one
}, really strange things happen...

\vfill
Let's create a real paragraph just to show that the page boundaries are actually okay. Two lines should be enough, but three aren't worse, are they?

\newpage

Strange things also happen with very short footnotes\footnote{like this...}
when followed by a colored one\footnote{\color{darkred}like this...}.

\vfill
Both scenarios together will even give more chaotic results (see next page).

\newpage

When a \emph{long} footnote...\footnote{%
  like this one, which should serve at least one good purpose, to show how messed up things get...
} is followed by a colored one\footnote{%

  \color{darkred}like this... the strange thing is that the first one, with no custom color, is messed up, but not this one
}, really strange things happen...

Strange things also happen with very short footnotes\footnote{like this...}
when followed by a colored one\footnote{\color{darkred}like this...}.

\vfill
Let's create a real paragraph just to show that the page boundaries are actually okay. Two lines should be enough, but three aren't worse, are they?

\end{document}

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Colored Footnotes

Post by cgnieder »

Either you should use \textcolor:

Code: Select all

\footnote{\textcolor{darkred}{<footnote text>}}
or put the footnote in a group:

Code: Select all

\footnote{{\color{darkred}<footnote text>}}
Regards
site moderator & package author
jagged
Posts: 4
Joined: Sun Sep 04, 2011 12:35 pm

Re: Colored Footnotes

Post by jagged »

That's easy as fun :-)

But I don't get it: when the colored notes are to be set, the preceding ones have been processed already. And even though the --- what is it called again? --- paragraph builder(?) hasn't done it's work yet, how could the use of the \color macro influence it in such a way?

Maybe this is not that important, but quite interesting.

Anyway, thanks a lot!
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Colored Footnotes

Post by cgnieder »

I don't know for sure but I suspect this has something to do with TeX's modes(*). The main difference between \color and \textcolor is a \leavevmode. Its definition is (basically):

Code: Select all

\leavevmode{\color{#1}#2}
Regards

(*) maybe someone else knows more...
site moderator & package author
Post Reply