lvjr / tabularray

Typeset tabulars and arrays with LaTeX3
https://ctan.org/pkg/tabularray
259 stars 22 forks source link

Unexpected new page in long tabularray #536

Open Rmano opened 1 week ago

Rmano commented 1 week ago

First of all, sorry for the contrived example --- I could not reduce it anymore. The problem is that the third "long" tblr in this document is split even if all the page is available.

I can fix it quite easily by adding * to the lines (I do not know if there is an option to "undo" the long in the template), but I thought it could be useful to pin it down --- maybe I did something wrong.

The result is this one:

image

\documentclass[10pt,a4paper]{article}
\usepackage[a4paper,top=3cm,bottom=3cm,left=3cm,right=3cm,headheight=36pt]{geometry}

\usepackage{tabularray}
\NewTblrEnviron{MyTblr}
\SetTblrInner[MyTblr]{rowhead=1, rowfoot=0, hlines, vlines}
\SetTblrOuter[MyTblr]{long, label=none, entry=none}
%
\newcommand{\lineadatos}[1]{% linea, left aligned, with a full-size underline
    \begingroup
    \parindent=0pt\parskip=-3pt\baselineskip=1pt
    \strut #1\par
    \hrulefill\par
    \endgroup
    \nobreak\medskip
}
\newcommand{\lineatitle}[1]{%
    \par\bigbreak\goodbreak
    \textbf{#1}\par%
    \nobreak\medskip\nobreak
    }
\begin{document}

\lineatitle{Start}

\vspace{3cm}

\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}
\lineadatos{}

\vspace{0.25cm}

\lineatitle{} Education
\begin{MyTblr}{X[1,l]*3{X[0.5,l]}}
    {Degrees} & {School} & {Date} & mark (when available)\\
    %% data starts here
    {\strut \\ \strut \\ \strut \\ \strut}& & & \\
    {\strut \\ \strut \\ \strut \\ \strut}& & & \\
    {\strut \\ \strut \\ \strut \\ \strut}& & & 
\end{MyTblr}

Additional info on Ph.D. thesis:
\begin{MyTblr}{*{2}{X[1,l]}}
    Title & Tutor/School \\
    {\strut \\ \strut }& &
\end{MyTblr}

% this is exploding... I need to force it not to break!
\lineatitle{} Language Proficiency
\begin{MyTblr}[
    note{*}={\textbf{B}= Basic, \textbf{M}= Moderate, \textbf{H}=High}
    ]{Xllll}
    {Language} & {Speaking\TblrNote{*}} & {Listening\TblrNote{*}} &
    {Reading\TblrNote{*}} & {Writing\TblrNote{*}} \\
    Italian  & H & H & H & H \\
    Spanish  & H & H & H & H \\
    English  & H & M & H & M \\
    Frrench  & B & B & M & B \\
\end{MyTblr}

\end{document}
lvjr commented 1 week ago

Maybe this bug could be fixed together with #184. In #184, tabularray fails to pagebreak after first body row. And here tabularray pagebreaks wrongly after first body row.

PS: At least some \usepackage lines could be removed from the example.

Rmano commented 1 week ago

PS: At least some \usepackage lines could be removed from the example.

Yes, you're right. I'll try to minimize the MWE as soon as I have some time (RL kicking in...)

Rmano commented 1 week ago

PS: At least some \usepackage lines could be removed from the example.

Yes, you're right. I'll try to minimize the MWE as soon as I have some time (RL kicking in...)

Done. It seems that both geometry and my awful messing with break penalties are needed to trigger the bug...

lvjr commented 6 days ago

Adding \SetTblrTracing{-step,+page} to the example I get from the log file:

> \pagegoal=674.33032pt. > \pagetotal=311.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=323.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=323.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=341.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=341.27136pt.
> \l__tblr_curr_i_int=2.
> \l__tblr_curr_i_int=3.
> \l__tblr_curr_i_int=4.
> \pagegoal=674.33032pt. > \pagetotal=545.27133pt.
> \pagegoal=674.33032pt. > \pagetotal=552.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=552.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=570.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=570.21577pt.
> \l__tblr_curr_i_int=2.
> \pagegoal=674.33032pt. > \pagetotal=639.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=651.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=651.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=671.3602pt.
> \pagegoal=674.33032pt. > \pagetotal=671.3602pt.
> \l__tblr_curr_i_int=2.
> \pagegoal=674.33032pt. > \pagetotal=661.3602pt.
> \l__tblr_curr_i_int=3.
[1]
[2]
> \pagegoal=674.33032pt. > \pagetotal=0.0pt.
> \l__tblr_curr_i_int=4.
> \l__tblr_curr_i_int=5.
[3]

It is strange there are no tracing messeges between [1] and [2].

lvjr commented 6 days ago

With version 2023A I get two-page output:

> \pagegoal=674.33032pt. > \pagetotal=311.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=323.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=323.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=341.27136pt.
> \pagegoal=674.33032pt. > \pagetotal=341.27136pt.
> \l__tblr_curr_i_int=2.
> \l__tblr_curr_i_int=3.
> \l__tblr_curr_i_int=4.
> \pagegoal=674.33032pt. > \pagetotal=545.27133pt.
> \pagegoal=674.33032pt. > \pagetotal=552.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=552.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=570.21577pt.
> \pagegoal=674.33032pt. > \pagetotal=570.21577pt.
> \l__tblr_curr_i_int=2.
> \pagegoal=674.33032pt. > \pagetotal=639.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=651.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=651.41576pt.
> \pagegoal=674.33032pt. > \pagetotal=671.3602pt.
> \pagegoal=674.33032pt. > \pagetotal=671.3602pt.
> \l__tblr_curr_i_int=2.
[1]
> \pagegoal=674.33032pt. > \pagetotal=0.0pt.
> \l__tblr_curr_i_int=3.
> \l__tblr_curr_i_int=4.
> \l__tblr_curr_i_int=5.
[2]
image
lvjr commented 6 days ago

It might be related to https://github.com/lvjr/tabularray/pull/366.