4

I am trying to make the table with tabularray package I tried

\documentclass[12pt,a4paper]{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\UseTblrLibrary{diagbox}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{varwidth}
\usepackage{lipsum}
\begin{document}
\lipsum[1-5]

\begin{tblr}{colspec={X[r]X[r]X[r]X[r]X[r]X[r]X[r]X[r]X[r]X[r]}}
 5 & 2 & 4 & 4 & 2 & 3 & 1 & 2
   & 4 & 1 \\
 3 & 3 & 1 & 2 & 3 & 4 & 2 & 2
   & 4 & 2 \\
 1 & 1 & 1 & 2 & 4 & 2 & 3 & 2
   & 4 & 3 \\
 2 & 3 & 1 & 3 & 2 & 1 & 4 & 2
   & 4 & 4 \\
 3 & 4 & 1 & 5 & 2 & 4 & 5 & 2
   & 4 & 5 \\
\end{tblr}
\end{document} 

I got

enter image description here

How can I reduce the code and fit the table?

2
  • 2
    Put \noindent\begin{tblr}....
    – cfr
    Commented Jun 15 at 2:35
  • You can use *{n}{X[r]} to repeat n times your X[r] columns
    – Mane32
    Commented Jun 15 at 4:14

1 Answer 1

4

Reducing your code:

\documentclass[12pt,a4paper]{article}
\usepackage{tabularray}
\UseTblrLibrary{siunitx,diagbox,booktabs,varwidth}
\usepackage{lipsum}
\begin{document}
\lipsum[1-5]

\noindent
\begin{tblr}{colspec=*{10}{X[r]}}
 5 & 2 & 4 & 4 & 2 & 3 & 1 & 2
   & 4 & 1 \\
 3 & 3 & 1 & 2 & 3 & 4 & 2 & 2
   & 4 & 2 \\
 1 & 1 & 1 & 2 & 4 & 2 & 3 & 2
   & 4 & 3 \\
 2 & 3 & 1 & 3 & 2 & 1 & 4 & 2
   & 4 & 4 \\
 3 & 4 & 1 & 5 & 2 & 4 & 5 & 2
   & 4 & 5 \\
\end{tblr}
\end{document} 

What did I do:

  • Compact loading of table libraries
  • Compact repeating of column specifications.
  • Added \noindent

You must log in to answer this question.

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