13

Is tabularray package incompatible with itemize environment? Simple MWE is:

\documentclass{article}
\usepackage{tabularray}

\begin{document}

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

\end{document}

I get many errors like "Something's wrong--perhaps a missing \item. \end", but the output is produced somehow. Could this be fixed?

Thank you.

4 Answers 4

11

I can offer a workaround:

\documentclass{article}
\usepackage{tabularray,varwidth,enumitem}

\begin{document}

\noindent
\begin{tblr}{
  colspec={Xl}, hlines, vlines
}
text & text\\
\begin{varwidth}[t]{\linewidth}
\begin{itemize}[topsep=0pt,parsep=0pt]
    \item abc def abc def abc def abc def
          abc def abc def abc def abc def
          abc def abc def abc def abc def
    \item abc def abc def abc def abc def
          abc def abc def abc def abc def
          abc def abc def abc def abc def\strut
\end{itemize}
\end{varwidth} & text 3 \\
abc def abc def abc def abc def
abc def abc def abc def abc def
abc def abc def abc def abc def
 & xyz
\end{tblr}

\end{document}

enter image description here

2
  • This solution justifies the text inside the enumerate rather, while @L.J.R.'s solution flushes it left. Commented Oct 5, 2023 at 10:10
  • @ChristophThiede Add \raggedright at the appropriate spot.
    – egreg
    Commented Oct 5, 2023 at 10:23
10

From https://github.com/lvjr/tabularray/issues/36

I have added varwidth library and measure option to tabularray package. You can put vertical material inside cells with \UseTblrLibrary{varwidth} and option measure=vbox. You can also set measure=vbox as default option.

\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}{
  colspec = {Xl}, hlines, vlines,
}
  text & text \\
  \begin{itemize}
    \item text 1
    \item text 2
  \end{itemize} & text 3 \\
\end{tblr}

\end{document}

enter image description here

You may download the latest package file from https://github.com/lvjr/tabularray/raw/main/tabularray.sty or wait for version 2021N scheduled on September 1st. I need to update the manual before next release.

But it is better to use @egreg's solution, because there is extra vertical space around itemized cells (the same is true for tabular and tabularx environments).

4
  • thank you! I checked new version, works almost perfect :). Almost, because if I add another string of text (make multi-row) in that cell via {\begin{itemize} ... \end{itemize} \\ Next string of text} it gives errors, but egreg's solution works in this case.
    – Alx
    Commented Aug 25, 2021 at 14:07
  • 1
    Like a normal document, you don't need \\ after \end{itemize}. Just remove it.
    – L.J.R.
    Commented Aug 25, 2021 at 14:51
  • ah I see, thanks.
    – Alx
    Commented Aug 25, 2021 at 14:56
  • 1
    To avoid this vertical space, I discovered this workaround: use package enumitem, then \vspace*{-\baselineskip} right before the itemize environment, the last with the option \begin{itemize}[nosep].
    – benjamin
    Commented Dec 13, 2021 at 13:50
6

Enclose the itemize environment within a minipage of width \hsize.

enter image description here

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\noindent
\begin{tblr}{%
colspec={Xl}, hlines, vlines
}
text & text\\
\begin{minipage}{\hsize}
  \begin{itemize}
    \item text 1
    \item text 2
  \end{itemize}
\end{minipage}
& text 3 \\
\end{tblr}

\end{document}
1
  • Didn't work for me, caused issues with vertical alignment in the other rows. The other offered solution worked (using \varwidth) Commented Sep 26, 2023 at 9:20
3

This is the recommended solution for using itemize inside tabularray from the official documentation:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\usepackage{enumitem}

\begin{document}

\noindent
\begin{tblr}{
  colspec={Xl}, measure=vbox, hlines, vlines, stretch=-1
}
text & text\\
\begin{itemize}[nosep]
    \item abc def abc def abc def abc def
          abc def abc def abc def abc def
          abc def abc def abc def abc def
    \item abc def abc def abc def abc def
          abc def abc def abc def abc def
          abc def abc def abc def abc def
\end{itemize} & text 3 \\
abc def abc def abc def abc def
abc def abc def abc def abc def
abc def abc def abc def abc def
 & xyz
\end{tblr}

In particular, note that the stretch=-1 option avoids vertical space above and below the list.

If you also want to avoid horizontal space before the list like me, set \setlength{\leftmargini}{.25cm} anywhere before the itemize.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .