rolfn / xltabular

LaTeX package which combines longtable and tabularx.
Other
10 stars 3 forks source link

strange behaviour in combniation with cleveref #3

Closed dg3gfs closed 5 years ago

dg3gfs commented 5 years ago

Thank you so much for this package.

There is a strange behaviour in combination with celveref, however: While \ref gives the correct numbering of the references, but \cref gives Tabellen 1.0 und 1.1 instead of Tabellen 1.1 und 1.2 with my texlive-full version 2017.20180305-1. It is the same with PdfLaTexx and LuaLaTeX. Using the xltabular.sty from github \cref gives Kapitel 1 instead of Tabellen 1.1 und 1.2. The source code and the results are shown below. The same happens when using longtable with \usepackage{longtable,xltabular} while giving correct results using only \usepackage{longtable}.

I don't know what is the reason for this strange behaviour. Do you have an idea what causes this and how to fix it? Thanks!

source code:

\documentclass[ngerman]{scrbook}
\usepackage{cleveref,xltabular,babel}

\begin{document}
\listoftables

\chapter{Kapitel X}
\begin{xltabular}{\linewidth}{l} 
\caption{erste Tabelle}\label{tab:eins}\\
a \\
\end{xltabular}
\begin{xltabular}{\linewidth}{r} 
\caption{zweite Tabelle\label{tab:zwei}}\\
bb\\
\end{xltabular}

Tabellen \ref{tab:eins} und \ref{tab:zwei} mit \emph{ref 1+2}\\
\cref{tab:eins,tab:zwei} mit \emph{cref 1+2}\\
\cref{tab:eins} mit \emph{cref 1}\\
\cref{tab:zwei} mit \emph{cref 2}\\
\end{document}

output with texlive-full version 2017.20180305-1 of xltabular.sty'

Tabellen 1.1 und 1.2 mit ref 1+2
Tabellen 1.0 und 1.1 mit cref 1+2
Tabelle 1.0 mit cref 1
Tabelle 1.1 mit cref 2

output with github version of xltabular.sty'

Tabellen 1.1 und 1.2 mit ref 1+2
Kapitel 1 mit cref 1+2
Kapitel 1 mit cref 1
Kapitel 1 mit cref 2
rolfn commented 5 years ago

I hope I have found the reason. The call of \refstepcounter occur inside a group. The result (in this case \cref@currentlabel) must be additionally assigned as global. Please test the new version 0.2b. Thanks for the bug report.

dg3gfs commented 5 years ago

Thanks for the prompt reaction and the new version. It works fine as long as cleveref is loaded before xltabular. Otherwise the problem stays the same.

rolfn commented 5 years ago

I changed the code again. The order of the two packages is now hopefully indifferent. Please test again.

dg3gfs commented 5 years ago

Thanks for the prompt reaction and the second version. It works fine now for both sequences of cleveref and xltabular.