Open hvoss49 opened 1 month ago
ping ...
I'll look, note that longtable 4.x as distributed on ctan is in the latex2e repository (core tools release) this repo has a more speculative longtable v5 code that may or may not get released one day.
I'll move this to tools, even though it needs additional packages it is certainly a change in longtable. hmm I can't move the issue.
the new longtable has extended caption support (from ltcaption) which was needed for tagging, this has adjusted \refstepcounter
usage and means xltabulars
patch to make \refstepcounter
do nothing on the first call is stopping the enumeration counter rather than the table counter. If you comment out this part
\def\LT@array{%
% make the call of \refstepcounter inside of \XLT@LT@array ineffective
% \renewcommand*\refstepcounter[2][]{%
% make next calls effective again
% \let\refstepcounter=\XLT@refstepcounter
%}%
\XLT@LT@array
The example works with the list starting at 1, but I haven't traced everything xltabular
is doing here. Looking....
@hvoss49 I'm not entirely sure if you need that refstepcounter patch at all with the new version, it would need some adjustment as longtable doesn't call \refstepcounter
caption code generallly (not just longtable) is being adjusted to separately set the anchor and increment the counter to get better linking and tagging without requiring hyperref to patch everything.
See the discussion at https://github.com/latex3/latex2e/issues/1377 (as I mentioned the extended caption support is based on that discussion)
Thanks David,
it looks like a useful patch. I had to remember why we had the redefinition of \refstepcounter
.
anyway, with some further tests I'll apply your fix.
David, it solved one issue, but creates a new one (caption starts at "Table 2"):
\documentclass{book}
\usepackage{xltabular}
\begin{document}
\begin{longtable}{c}
\caption{caption}
\endfirsthead
xxx\\xxx
xxx\\xxx
\end{longtable}
\end{document}
Do you have another idea? The current TL2024 xltabular has your above patch:
\def\LT@array{%
% make the call of \refstepcounter inside of \XLT@LT@array ineffective
% \renewcommand*\refstepcounter[2][]{%
% make next calls effective again
% \let\refstepcounter=\XLT@refstepcounter
% }%
\XLT@LT@array
}%
Reverting it, solves the new problem but has the old one with enumerate.
@hvoss49 I just wanted to comment in the issue: It seems to work if one reinstate the default caption definition of longtable (or avoid to change it):
\documentclass{book}
\usepackage{xltabular}
\makeatletter
\def\LT@caption{%
\noalign\bgroup
\@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
\makeatother
\begin{document}
\begin{longtable}{c}
\caption{caption}
\endfirsthead
xxx\\xxx
xxx\\xxx
\end{longtable}
\end{document}
We have to revert the patch from David, it has other problems. After that your example will work without modifying \LT@caption
what problems? Be aware that if you patch longtable in a way that removes recent additions you probably break the tagging code or hyperref links.
With David's patch it counts with step 2. Table 2, Table 4
\listfiles
\documentclass{article}
\usepackage{xltabular}
\begin{document}
\begin{xltabular}[l]{.7\linewidth}{|c|X|X|}
\caption{A table with a caption\label{tab:A}} \\\hline
1 & \hrulefill 2 \hrulefill & \hrulefill 3 \hrulefill \\
4 & \hrulefill 5 \hrulefill & \hrulefill 6 \hrulefill \\
\hline
\end{xltabular}
\begin{xltabular}[r]{.7\linewidth}{|c|X|X|}
\caption{A table with a caption\label{tab:B}} \\\hline
\hline
1 & \hrulefill 2 \hrulefill & \hrulefill 3 \hrulefill \\
4 & \hrulefill 5 \hrulefill & \hrulefill 6 \hrulefill \\
\hline
\end{xltabular}
\end{document}
sure that is my issue. But it works with the original caption command:
\documentclass{article}
\usepackage{xltabular}
\makeatletter
\def\LT@caption{%
\noalign\bgroup
\@ifnextchar[{\egroup\LT@c@ption\@firstofone}\LT@capti@n}
\makeatother
\begin{document}
\begin{xltabular}[l]{.7\linewidth}{|c|X|X|}
\caption{A table with a caption\label{tab:A}} \\\hline
1 & \hrulefill 2 \hrulefill & \hrulefill 3 \hrulefill \\
4 & \hrulefill 5 \hrulefill & \hrulefill 6 \hrulefill \\
\hline
\end{xltabular}
\begin{xltabular}[r]{.7\linewidth}{|c|X|X|}
\caption{A table with a caption\label{tab:B}} \\\hline
\hline
1 & \hrulefill 2 \hrulefill & \hrulefill 3 \hrulefill \\
4 & \hrulefill 5 \hrulefill & \hrulefill 6 \hrulefill \\
\hline
\end{xltabular}
\end{document}
Uhh, I See. I used the wrong test files. Will discuss it with Rolf ...
We'll upload a new version. We deleted the complete code which fixes the problem with the table counter inside longtable (no caption but counter is still incremented). Then we do not need any of the above patches ...
Wrong counter with latest long table:
The counter starts at 0, without loading
xltabular
at the expected 1. If I loadlongtable
from 2020 (needs also the change inltablex.sty
) all is fine! I cannot see why the latestlongtable
maybe a problem.xltabular
only loadstabularx
,longtable
andltablex
Tested with Up-to-date TL2024