# cross referencing papers in a table

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

If I comment out the \usepackage[font=footnotesize, labelfont=bf]{caption} command the result looks like , 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.

• Welcome to TeX.SX! The caption package should be loaded before hyperref. Sep 8, 2015 at 20:02
• Thanks @egreg, but I don't find any difference by loading the caption package before hyperref. Sep 8, 2015 at 21:00
• I think that the backreferencing gets confused when a citation is in a float. Sep 8, 2015 at 21:15

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:

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:

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:

\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:

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.

• Well, “document” doesn't seem to be a sensible back reference. Sep 8, 2015 at 23:20
• @egreg I don't know anything about back references. Isn't the number rather than the question marks the relevant bit?
– cfr
Sep 8, 2015 at 23:23
• @egreg The 'document' thing is not the link to the citation in the table, but the link to the citation in the text. If you add a \section{} command, it disappears. Isn't the 'document' just because the back-referencing is thrown by the fact that the document has no structure whatsoever? At any rate, it seems to be a different issue... ?
– cfr
Sep 8, 2015 at 23:26
• @cfr The (document) is just a dummy for the missing section reference. backref uses section numbers. If the real document does not have a structure, then pagebackref might be the better choice. Sep 8, 2015 at 23:29
• @HeikoOberdiek I was assuming that the original document probably does have a structure since this is common practice. I guess this can't be known unless the OP says one way or another, though. But the back-reference for the citation in the table works even if the document has no sectional structure, doesn't it? At least, it works when I do some admittedly minimal testing.
– cfr
Sep 8, 2015 at 23:38