lvjr / tabularray

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

Overfull hbox with parskip option (KOMA-Script) and longtblr #252

Open marvlg opened 2 years ago

marvlg commented 2 years ago

When using the parskip option of a KOMA-Script class, using longtblr leads to overfull hbox errors. See the following example

\documentclass[parskip=half]{scrartcl}

\usepackage{tabularray}

\begin{document}

%%%-----None of these options change the result------%%%

%\SetTblrTemplate{caption}{empty}
%\SetTblrTemplate{contfoot}{empty}
%\SetTblrTemplate{middlefoot}{empty}
%\SetTblrTemplate{foot}{empty}

\begin{longtblr}{cc}
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
\end{longtblr}

\vspace*{12cm} % To force pagebreak

\begin{longtblr}{cc}
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
    test test test  & test test test \\
\end{longtblr}

\end{document}

The issue seems to appear at the "end" of a table, i. e. when the table ends or a pagebreak happens. The second example leads to two overfull errors.

I tried settting different templates to empty since I noticed some \par tokens in their definitions, but the result remained unchanged.

Maybe related: #210 and https://tex.stackexchange.com/questions/628871/how-to-solve-the-apparent-incompatibility-between-longtblr-from-the-tabularray-p

marvlg commented 2 years ago

I have found the solution myself. When using the option parskip=half (or parskip=full), TeX is required to leave at least a 1em space at the end of a line. More background information can be found here (in german). This somehow conflicts with the way longtblr typesets the end of a table.

There are two solutions to this. Either use parskip=half- (or full-), which does not have the 1em requirement. My preferred solution is to use \AddToHook{env/longtblr/begin}{\KOMAoptions{parskip=half-}}, which keeps the change local to longtblr environment. This requires a somewhat recent LaTeX kernel.

I am not closing this issue, in case there is a easy way to modify the tabularray code such that this issue does not happen. If not, feel free to close.

lvjr commented 2 years ago

These lines in the log file are warnings but not errors:

Overfull \hbox (10.95pt too wide) in paragraph at lines 35--35

From the link you give, we can see even the following code leads to a warning

\documentclass[parskip=true,draft]{scrartcl}
\begin{document}
\begin{minipage}{\textwidth}%
Inhalt%
\end{minipage}%
\end{document}

I think maybe it can not be treated as a bug of tabularray package.