[Tex/LaTex] floatrow: Changing the formatting of table footnotes

floatrowfloatsfootnotesformattingtables

The floatrow package, which is useful for customizing the layout of floats, also allows to add footnotes as well as additional explanations (besides the caption) to tables. (The main commands are \mpfootnotemark, \footnotetext and \floatfoot, see p. 25–26 of the manual.) One may also configure the formatting of the actual table content (to, say, \sffamily\small) and the explanations (to say, \sffamily\scriptsize). However, I have not found a way to change the formatting of footnote marks and footnote texts with floatrow. Any ideas?

(Notes: The \ttabbox command in my example, while not strictly necessary, will adapt the width of footnotes/explanations to the width of the actual table material and will also place the caption above instead of below the table. The caption package, which cooperates with floatrow, is used to change the formatting of captions.)

\documentclass[12pt]{article}

\usepackage[font={sf,small}]{floatrow}
\floatsetup[table]{footnoterule=none,footskip=0.5\skip\footins}

\usepackage[font=sf]{caption}
\captionsetup{footfont=scriptsize}% "footfont" defined by floatrow package

\begin{document}

\begin{table}
\ttabbox{%
  % \centering% Default for floatrow package
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book\mpfootnotemark[1] \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}%
  \footnotetext[1]{\TeX\ only}%
  \floatfoot{All books listed are indispensable reading.}%
}{%
  \caption{\TeX/\LaTeX\ books}%
}
\end{table}

\end{document}

enter image description here

Best Answer

Having rummaged through floatrow.sty for a few hours, I think that it is a matter of omission. Footnotes in floats still use the "normal" mechanism for minipage footnotes, i.e. the formatting is not adapted to \captionfootfont (used for additional explanations) or \floatfont (used for the actual table material). Solution: Inside of floats, (EDIT:) \@makefntext and \@makefnmark need to be redefined. (For convenience, I used the etoolbox package to do so.)

Note: I added a minipage to my example to show that footnotes inside minipages are not affected.

\documentclass[12pt]{article}

\usepackage[font={sf,small}]{floatrow}
\floatsetup[table]{footnoterule=none,footskip=0.5\skip\footins}

\usepackage[font=sf]{caption}
\captionsetup{footfont={sf,scriptsize}}% "footfont" defined by floatrow package

\usepackage{etoolbox}

\makeatletter
\FR@everyfloat={%
  \ifundef{\KOMAClassName}{% NEW
    \patchcmd{\@makefnmark}{\normalfont}{}{}{}% NEW
    \pretocmd{\@makefntext}{\captionfootfont}{}{}% NEW
  }{% NEW
    \renewcommand*{\ftn@font}{\captionfootfont}% NEW; for KOMA-Script-classes
  }% NEW
  \let\@footnotetext\@mpfootnotetext
  \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
  \floatobjectset\floatfont
}
\makeatother

\begin{document}

\begin{table}
\ttabbox{%
  % \centering% Default for floatrow package
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book\mpfootnotemark[1] \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}%
  \footnotetext[1]{\TeX\ only}%
  \floatfoot{All books listed are indispensable reading.}%
}{%
  \caption{\TeX/\LaTeX\ books}%
}
\end{table}

\begin{minipage}{\textwidth}
Some text inside a minipage.\footnote{And a footnote.}
\end{minipage}

\end{document}

enter image description here

EDIT: Changed code example in order to also work with package hyperref.

EDIT 2: Added code for the special footnote definition of the KOMA-Script-classes.

EDIT 3: Instead of duplicating the original content of the \FR@everyfloat token list, one may also use the LaTeX kernel macro \addto@hook to append code to the list's definition. See How does one append material to a token list? for details.

\makeatletter
\addto@hook{\FR@everyfloat}{%
  \ifundef{\KOMAClassName}{% NEW
    \patchcmd{\@makefnmark}{\normalfont}{}{}{}% NEW
    \pretocmd{\@makefntext}{\captionfootfont}{}{}% NEW
  }{% NEW
    \renewcommand*{\ftn@font}{\captionfootfont}% NEW; for KOMA-Script-classes
  }% NEW
}
\makeatother