Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

longtable, xltabular and enumerate #57

Open
hvoss49 opened this issue Oct 7, 2024 · 14 comments
Open

longtable, xltabular and enumerate #57

hvoss49 opened this issue Oct 7, 2024 · 14 comments

Comments

@hvoss49
Copy link

hvoss49 commented Oct 7, 2024

Wrong counter with latest long table:

\documentclass{article}
%\usepackage{longtable-2020-01-07}
\usepackage{longtable}
\usepackage{xltabular}

\begin{document}

\begin{longtable}{ | l | p{5in} |}\hline
    Rev 1 &
    \begin{enumerate} %\setcounter{enumi}{1}
        \item 9/20/2024: AA
        \item 9/24/2024: BB
    \end{enumerate}
    \\ \hline
  \end{longtable}

\end{document}

The counter starts at 0, without loading xltabular at the expected 1. If I load longtable from 2020 (needs
also the change in ltablex.sty) all is fine! I cannot see why the latest longtable maybe a problem.
xltabular only loads tabularx, longtable and ltablex

Tested with Up-to-date TL2024

@hvoss49
Copy link
Author

hvoss49 commented Oct 28, 2024

ping ...

@davidcarlisle
Copy link
Owner

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.

@davidcarlisle
Copy link
Owner

davidcarlisle commented Oct 28, 2024

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.

@davidcarlisle
Copy link
Owner

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....

@davidcarlisle
Copy link
Owner

@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 latex3/latex2e#1377 (as I mentioned the extended caption support is based on that discussion)

@hvoss49
Copy link
Author

hvoss49 commented Oct 28, 2024

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.

@hvoss49
Copy link
Author

hvoss49 commented Nov 12, 2024

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.

@u-fischer
Copy link
Contributor

@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}

@hvoss49
Copy link
Author

hvoss49 commented Nov 13, 2024

We have to revert the patch from David, it has other problems. After that your example will work without modifying \LT@caption

@u-fischer
Copy link
Contributor

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.

@hvoss49
Copy link
Author

hvoss49 commented Nov 13, 2024

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}

@u-fischer
Copy link
Contributor

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}

image

@hvoss49
Copy link
Author

hvoss49 commented Nov 13, 2024

Uhh, I See. I used the wrong test files. Will discuss it with Rolf ...

@hvoss49
Copy link
Author

hvoss49 commented Nov 13, 2024

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 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants