5

If I invoke \cite within a tabularx environment and biblatex is loaded with defernumbers=true and sorting=none, references do not get a number.

I get these warnings:

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please (re)run Biber on the file:
(biblatex)                file
(biblatex)                and rerun LaTeX afterwards.

But nothing changes no matter how many times I rerun biber and pdflatex.

If I change the tabularx environment to plain tabular references do get a number.

I have already brought this to PLK's (biblatex maintainer) attention on the biblatex bug tracker and he has said that:

This is because sorting=none invokes a special check to see if citation order has changed so that re-run messages can be issued for biber. For some reason, tabularx is triggering this every time. You can see something strange going on by just runing latex once and they you get, in the .bcf:

<bcf:citekey order="1">gob</bcf:citekey>
<bcf:citekey order="3">michael</bcf:citekey>
<bcf:citekey order="4">tobias</bcf:citekey>

There is a missing "2" order. With plain tabular, it is there. So tabularx is doing something strange like processing the \cite twice. I think it's worth asking this as a TSE question as the tabularx people are around on there.

Issue:

Issue

MWE:

\documentclass[10pt]{article}

\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@Article{gob,
  title           = {I've Made a Huge Mistake: The Hermano Story},
  author          = {Bluth, Gob},
  journal         = {Journal of Magicians},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{michael,
  title           = {Her?},
  author          = {Bluth, Michael},
  journal         = {Sudden Valley},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{tobias,
  title           = {Never-nudism},
  author          = {F{\"u}nke, Tobias},
  journal         = {Blue Man Group},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[%
  backend=biber,
  defernumbers=true,
  style=numeric,
  sorting=none,
]{biblatex}
\addbibresource{bibliography.bib}

\usepackage{tabularx}

\begin{document}

\section{A section}
Check this out~\cite{gob}.

\section{A section}
% With plain tabular, it works with sorting=none or no sorting option.
% \begin{tabular}{ll}
  % \textbf{The term \enquote{issue} is used to refer to:} & \textbf{Reference(s)} \\ \hline
  % An issue. & \cite{michael}
% \end{tabular}

% With tabularx, it does not work with sorting=none.
\begin{tabularx}{\textwidth}{ll}
  \textbf{The term \enquote{issue} is used to refer to:} & \textbf{Reference(s)} \\ \hline
  An issue. & \cite{michael}
\end{tabularx}

\nocite{tobias}
\printbibliography
\end{document}

Extra information: With the latest stable biblatex release, numbers are omitted altogether and only the brackets are shown. With the dev 3.0 version, all bibliography entries are assigned the number 0. But this is irrelevant because the same .bcf issue is seen in both cases:

This numbering in the .bcf issue also occurs with the released 2.9 version of biblatex. Further runs throw an error with 2.9 due to issues already fixed in in 3.0 but this strange tabularx behaviour is there. — PLK

7
  • Just to be picky: what's the meaning of using tabularx with just l columns?
    – egreg
    Jun 10, 2014 at 18:09
  • @egreg It was to avoid questions of the sort 'have you tried this without X-type columns?'. :-)
    – sudosensei
    Jun 10, 2014 at 18:10
  • Well, the problem is quite certainly in the fact that tabularx squashes the table body a few times in order to measure the columns' widths. At least an X column is necessary for the example to be meaningful, or the answer would be “use tabular”.
    – egreg
    Jun 10, 2014 at 18:21
  • @egreg Yes, of course. The actual tables I use are more complicated than that. So plain tabular is not really an option.
    – sudosensei
    Jun 10, 2014 at 18:30
  • With biblatex 2.8a it works fine Jun 10, 2014 at 18:43

1 Answer 1

5

You can just do the cite on the final run (it means the cite text isn't used in the column widths calculation, but mostly it isn't too important. (a more careful definition could use the text without duplicating whatever information biblatex is using)

\documentclass[10pt]{article}

\usepackage{filecontents}
\begin{filecontents}{bibliography.bib}
@Article{gob,
  title           = {I've Made a Huge Mistake: The Hermano Story},
  author          = {Bluth, Gob},
  journal         = {Journal of Magicians},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{michael,
  title           = {Her?},
  author          = {Bluth, Michael},
  journal         = {Sudden Valley},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}

@Article{tobias,
  title           = {Never-nudism},
  author          = {F{\"u}nke, Tobias},
  journal         = {Blue Man Group},
  year            = {2003},
  volume          = {1},
  number          = {1},
  pages           = {1--10},
}
\end{filecontents}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[%
  backend=biber,
  defernumbers=true,
  style=numeric,
  sorting=none,
]{biblatex}
\addbibresource{bibliography.bib}

\usepackage{tabularx}

\begin{document}

\section{A section}
Check this out~\cite{gob}.

\section{A section}
% With plain tabular, it works with sorting=none or no sorting option.
% \begin{tabular}{ll}
  % \textbf{The term \enquote{issue} is used to refer to:} & \textbf{Reference(s)} \\ \hline
  % An issue. & \cite{michael}
% \end{tabular}

% With tabularx, it does not work with sorting=none.
\let\zz\hfuzz
\begin{tabularx}{\textwidth}{ll}
  \textbf{The term \enquote{issue} is used to refer to:} & \textbf{Reference(s)} \\ \hline
  An issue. & \ifx\zz\hfuzz\cite{michael}\fi
\end{tabularx}

\nocite{tobias}
\printbibliography
\end{document}
15
  • Thanks, David! I can confirm that this works, even under a fairly complicated setup that includes refsegments, custom bibliography environments, and tabularx in tcolorboxes. I won't accept this just yet in case PLK can solve the issue from biblatexs side of things (which would be more convenient). Marco Daniel commented above that the issue does not exist with biblatex 2.8a so it may be a biblatex bug after all.
    – sudosensei
    Jun 10, 2014 at 21:48
  • I think that this was a biblatex regression. I don't quite understand this strange interaction with tabularx but I think this is now fixed in the 3.0 dev version.
    – PLK
    Jun 11, 2014 at 10:51
  • @PLK tabularx evaluates its body several times, it takes some precautions to stop for example labels being written multiple times, or latex counters being incremented multiple times, but depending on the coding style it can't catch everything. (AMS alignments are similar but always typeset twice, tabularx iterates towards a final width so can take several passes) Jun 11, 2014 at 11:11
  • Ah, ok, that explains the non-contiguous cite order counter in the .bcf. This should not normally cause problems.
    – PLK
    Jun 11, 2014 at 18:44
  • 1
    @moewe it's pretty scary trying to guess in tabularx how to patch every possible citation package (or how to patch any without breaking the rest) it might be better if I add a hook to tabularx to allow packages to add commands that are redefined during trial runs, and then leave it to biblatex to use whatever definitions it needs as it (or you:-) probably have a better idea than tabularx (or I:-) do... Jan 5, 2019 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .