[Tex/LaTex] cross referencing papers in a table

captionscross-referencingtables

I have trouble referencing papers in a table. I want to reference papers in a table, where the caption's font is defined using the "caption" package. However, I get ?? in the references in the following code:

\documentclass{article}
\usepackage[numbers,sort]{natbib}
\usepackage[backref,pageanchor=true,plainpages=false, pdfpagelabels, bookmarks,bookmarksnumbered]{hyperref}
\usepackage[font=footnotesize, labelfont=bf]{caption}

\begin{document}

\begin{table}[t]
\centering
\begin{tabular}{ c | l } 
    \citep{citation1} & cell\\
\end{tabular}

\caption[short caption]{long caption}
\label{tab:label}
\end{table}

citation in text \citep{citation1}.

\bibliographystyle{plainnat}
\bibliography{cite}

\end{document}

It also gives me warnings that say "Package caption Warning: \label without proper \caption on input line 13" and "LaTex Warning" Reference '??' on page 1 undefined on input line 12. The generated text looks like
enter image description here

If I comment out the \usepackage[font=footnotesize, labelfont=bf]{caption} command the result looks like
enter image description here
, where the reference generate a pointer only to the text not to the table.

Ultimately, I want to use the "caption" package to define the caption fonts.

Best Answer

I think egreg is correct that the back-referencing gets confused but it does not seem to be a result of back-referencing a citation in a float per se.

The problem occurs only if the relevant counter needed for the reference has not yet been incremented by the \caption... command. Placing this before the table resolves the referencing issue:

working back-reference to citation in float

Note that the 'document' tag is the back-reference for the citation in the text; the '1' is the back-reference for the citation in the table, as can be seen if the citation in the text is removed:

working back-reference to citation in float without distractors

I don't know much about back-referencing, but I assume the complete lack of document structure is part of the problem since adding a \section{section} command also makes it disappear:

example with working back-reference and sectioning command

\documentclass{article}
\usepackage[numbers, sort]{natbib}
\usepackage[font=footnotesize, labelfont=bf]{caption}
\usepackage[backref, pageanchor=true, plainpages=false, pdfpagelabels, bookmarks, bookmarksnumbered]{hyperref}
\begin{document}
%\section{Section}\label{sec:sec}% uncomment this to eliminate the back-reference tagged 'document'
\begin{table}[t]
\centering
\caption[short caption]{long caption}
\label{tab:label}
\begin{tabular}{ c | l }
  \citep{article-full} & cell\\
\end{tabular}
\end{table}
citation in text \citep{article-full}.% or comment this line instead
\bibliographystyle{plainnat}
\bibliography{xampl}
\end{document}

Note that I've moved the \label as well, but this isn't actually important: what matters is the move of the \caption command.

Heiko Oberdiek suggests that if your document doesn't have the structure of sectional divisions at all, then pagebackref may be a better option than backref:

\usepackage[pagebackref, pageanchor=true, plainpages=false, pdfpagelabels, bookmarks, bookmarksnumbered]{hyperref}

In that case, a document with the table on page 2 and a citation in the text on page 3 produces these back-references:

back-referencing pages

This is clearly preferable as far as in-text citations are concerned. However, in this case the reference to the citation in the table is linked to the relevant page rather than to the table specifically. Moreover, this option produces two back-references rather than just one, as would be the case with the same content within a sectional division. This might be an advantage or a disadvantage, of course, depending on your requirements.