lvjr / tabularray

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

longtblr and itemize #400

Open Aljumaily opened 1 year ago

Aljumaily commented 1 year ago

Related to tabularray and itemize compatibility. This is the solution provided:

\documentclass{article}

\usepackage{tabularray}
\UseTblrLibrary{varwidth}

\begin{document}

\begin{tblr}{
  colspec = {Xl}, hlines, vlines,
  measure = vbox,
}
  text & text \\
  \begin{itemize}
    \item text 1
    \item text 2
  \end{itemize} & text 3 \\
\end{tblr}

% set "measure=vbox" as default
\SetTblrInner{measure=vbox}

\begin{tblr}{ % Changing this to longtblr generates Something's wrong--perhaps a missing \item
  colspec = {Xl}, hlines, vlines,
}
  text & text \\
  \begin{itemize}
    \item text 1
    \item text 2
  \end{itemize} & text 3 \\
\end{tblr} % longtblr

\end{document}

Changing the second tblr to longtblr generates Something's wrong--perhaps a missing \item. What is the fix?

lvjr commented 1 year ago

It is a strange bug: when I pass outer option long to make it a long table, no error occurs:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\begin{document}
% set "measure=vbox" as default
\SetTblrInner{measure=vbox}
\begin{tblr}[long]{ % Changing this to longtblr generates Something's wrong--perhaps a missing \item
  colspec = {Xl}, hlines, vlines,
}
  text & text \\
  \begin{itemize}
    \item text 1
    \item text 2
  \end{itemize} & text 3 \\\pagebreak
  text & text
\end{tblr} % longtblr
\end{document}
muzimuzhi commented 1 year ago

By default \SetTblrInner only influence tblr environment. What's needed here is

\SetTblrInner[tblr,longtblr]{measure=vbox}

https://github.com/lvjr/tabularray/blob/690e67ee175ff7601d0144c84f9a7e9c67573e0b/tabularray.sty#L2623-L2629

Also see package doc (2023A (2023-03-01)), sec. 3.3 "Default Specifications": https://github.com/lvjr/tabularray/blob/690e67ee175ff7601d0144c84f9a7e9c67573e0b/manual/manual-3.tex#L312-L337

muzimuzhi commented 1 year ago

There're more tblr envs predefined in either the base package or one of its libraries (just searching for \NewTblrEnviron in tabularray.sty) hence enumerating full list of them in \SetTblrInner[<list of tblr-envs>]{...} is a bit of a pain.

Perhaps tabularray could add a pair of clists storing (real) default inner and outer styles which is applied before per-tblr-env styles and can be set by starred \SetTblrInner/\SetTblrOuter.

lvjr commented 1 year ago

By default \SetTblrInner only influence tblr environment. What's needed here is

\SetTblrInner[tblr,longtblr]{measure=vbox}

Also see package doc (2023A (2023-03-01)), sec. 3.3 Default Specifications:

Sorry, obviously I forgot what I have written. ^_^

lvjr commented 1 year ago

There're more tblr envs predefined in either the base package or one of its libraries (just searching for \NewTblrEnviron in tabularray.sty) hence enumerating full list of them in \SetTblrInner[<list of tblr-envs>]{...} is a bit of a pain.

Perhaps tabularray could add a pair of clists storing (real) default inner and outer styles which is applied before per-tblr-env styles and can be set by starred \SetTblrInner/\SetTblrOuter.

I ever considered this (see #37), but decided not to do it becauae it is a little complicated when users need to apply it only to text tables (but not math tables). The real problem is that I am not satisfied with the interfaces.

muzimuzhi commented 1 year ago

I ever considered this (see #37), but decided not to do it becauae it is a little complicated when users need to apply it only to text tables (but not math tables).

True. I thought about this too, when editing my previous comment. Adding env families or conditional options like if math={<true options>}{<false options>} are possible choices.

lvjr commented 1 year ago

I think the interfaces could be the following:

And we need four new clists.

muzimuzhi commented 1 year ago

Then users should be informed that \SetAllTblrInner actually calls \SetTextTblrInner and \SetMathTblrInner, to understand the combined affect of interchanging use like \SetTextTblrInner{...} \SetAllTblrInner{...} \SetTextTblrInner{...}.

Plus, I'm a bit preferable to stick to prefix \SetTblr....

lvjr commented 1 year ago

Then users should be informed that \SetAllTblrInner actually calls \SetTextTblrInner and \SetMathTblrInner, to understand the combined affect of interchanging use like \SetTextTblrInner{...} \SetAllTblrInner{...} \SetTextTblrInner{...}.

Yes.

Plus, I'm a bit preferable to stick to prefix \SetTblr....

SetAllTblr is a little easier to understand: "set all tabularray tables".