3

For tables or figures with footnote in their caption, through footnote package for example, the use footnotebackref would remove the text in \autoref{...}. Is there a way to fix that?

(Note: footnote in table content does not cause problems)

Minimal working code as follows.

\documentclass[12pt, 
twoside]{article}
\usepackage{footnote} % enables footnote in captions of floats
\usepackage{hyperref} % add hyperlinks 
\usepackage{footnotebackref} % add backward link from footnote
\usepackage[font=footnotesize]{caption} % adjust caption font size

\begin{document}

\savenotes
\begin{table}
    \centering
    \begin{tabular}{|c|}
        \hline
        la \\\hline
    \end{tabular}
    \caption[la]{asdfasd\footnote{sadfas}}
    \label{tab:table1}
\end{table}
\spewnotes

autoref: \autoref{tab:table1}

regular ref: Table~\ref{tab:table1}

\end{document}

Example

Note: the author of footnotebackref does not leave any contact info in the documentation. I would have pointed him to this post otherwise.

  • ALWAYS pay attention to the warnings that LaTeX emits. Half the time they're useless, so I'm not going to say you should always fix them (although personally I do) but you should always know what warnings your document generates. In this case, your document generates two warnings. One of them indeed looks pretty useless. But the other one answers your question! The \autoref command is trying to generate a reference to your footnote, instead of your table! The solution is to make the label earlier: \caption[la]{\label{table}as\footnote{ba}}. – Mark May 18 '16 at 4:51
  • actually, the other warning seems to be a problem with my setup, not your document – Mark May 18 '16 at 5:07
  • Sorry about my tone in my comment. – Mark May 19 '16 at 3:33
  • 1
    \label needs to happen after \caption. That's why I put it after the whole phrase. I didn't know you could put it in the argument. Are you sure this wouldn't break other things? And would you like to put your comment into an answer? I bet that would be helpful for many in the future – Argyll May 19 '16 at 21:14
1

A very useful tip when debugging (La)TeX: first, get the problem down to a minimal working example. You did this. Second, compile the example and look at the warnings LaTeX emits. If you had done that, you would have seen that \autoref is trying to generate a reference to your footnote, instead of your table! The solution is to make the label earlier:

\caption[cap]{\label{tab}cap\footnote{foot}}

Warning: make sure that there are no spaces to either side of the label:

\caption[cap]{ \label{tab}cap\footnote{foot}} is BAD

\caption[cap]{\label{tab} cap\footnote{foot}} is BAD

If you do either of those, there will be too much space between the colon and the actual caption. (Actually, it doesn't look so bad, except it will be inconsistent with your other captions.)

|improve this answer|||||
  • It turns out the solution works for footnotes in the caption but breaks cross-references to tables with footnotes in the table... – Argyll May 30 '16 at 12:44
  • can you post an example that doesn't work? – Mark May 30 '16 at 22:29
  • I will do that shortly. – Argyll May 31 '16 at 4:48

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.