1

I'm trying to use the trim option with tabularray, and I can't understand why it's not working. I read another thread about it which didn't help me. What am I doing wrong?

    \usepackage{tabularx}
    \usepackage{array}
    \usepackage{booktabs}
    \usepackage{tabularray}
    \UseTblrLibrary{booktabs}
        \begin{document}
        \begin{table}[t]
        \begin{tblr}{colspec={X[l] *{6}{X[c]}}}
            &\multicolumn{2}{c|}{multicol1} &\multicolumn{2}{c|}{multicol2} &\multicolumn{2}{c|}{multicol3}\\
          \cmidrule[r]{2-3} \cmidrule[lr]{4-5} \cmidrule[r]{6-7}
        \end{tblr}
        \caption{Caption}
        \end{table}
        \end{document}

This is the output I get:

this is the output

8
  • Welcome to TeX.SX! Please post a full and compilable example. You should place \usepackage{tabularray} \UseTblrLibrary{booktabs} in your preamble. Dec 8, 2021 at 22:56
  • My bad, edited. Thanks
    – D.Milani
    Dec 8, 2021 at 22:59
  • Well, if I add \documentclass{article} (just my guess) before and \end{document} after your code, it compiles fine. I don't get the output you get, but the lines are rendered correctly. Dec 8, 2021 at 23:00
  • I had \documentclass{report}, switched to article and still same result. If it can help, I am using overleaf as compiler.
    – D.Milani
    Dec 8, 2021 at 23:05
  • 1
    You may find the latest tabularray.sty file in this github respiratory. Put this file in your Overleaf project folder (where your tex file is).
    – Imran
    Dec 9, 2021 at 7:37

1 Answer 1

2

Edit:

  • Overleaf have so far installed old tabularray package version 2021L, which not support \cmidrule[r]{2-3} from your code fragment (see comment of @L.J.R., who is package author).
  • Support for trim option (shortening) of \cmidrule is available with tabularray version 2021N and latter (see package author answer).
  • Transcript of your code fragment to MWE (Minimal Working Example) with pure tabularray syntax is:
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
    
\begin{document}
\begin{table}[ht]
\begin{tblr}{colspec={X[l] *{6}{X[c]}}}
    & \SetCell[c=2]{c}  multicol1   &
        & \SetCell[c=2]{c}  multicol2   &
            & \SetCell[c=2]{c}  multicol3   &   \\
  \cmidrule[r]{2-3} \cmidrule[lr]{4-5} \cmidrule[r]{6-7}
1   & 2 & 3 & 4 & 5 & 6 & 7 \\      % <--- added row
\end{tblr}
\caption{Caption}
\end{table}
\end{document}

which gives after compilation with recent tabularray package version (2021Q) the following result:

enter image description here

This result you will get also with use of older version of the tabularray package, but not older as 2021N.

4
  • I tested it recently and found that Overleaf had tabularray 2021L (2021-07-01) which was too old.
    – L.J.R.
    Dec 9, 2021 at 1:34
  • @L.J.R., interestingly. I tested showed MWE in my Overleaf account and got error LaTeX Error: File *tabularray.sty* not found. The compiler cannot find the file you want to include. Make sure that you have uploaded the file and specified the file location correctly.
    – Zarko
    Dec 9, 2021 at 1:39
  • Overleaf won't change TeX Live version for old projects. You may try to create a new project and test it again.
    – L.J.R.
    Dec 9, 2021 at 1:42
  • @L.J.R., yo are right. I use an old project for text. With creating a new project I have the same result as you noted. Thank you very much for info.
    – Zarko
    Dec 9, 2021 at 1:57

You must log in to answer this question.

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