I want to add the caption above the table. There is no information on the package documentationhere. The documentation only explains adding caption to long table which is not the case of mine. Any help appreciated!
This is the code:
\usepackage{tabularray}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\begin{document}
\scalebox{0.8}{
\begin{tblr}{
colspec={cccccccc},
rowspec={Q[gray!20]Q[]Q[gray!10]Q[]Q[gray!10]Q[]Q[gray!10]Q[]},
rowhead = 1,
vline{2-8} = {0-1}{0.3pt,gray!50},
vline{2-8} = {2-7}{0.3pt,gray!30},
hline{1,2,8} = {0.1pt,azure5}}
header & header & header & header & header & header & header & header\\
1 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
2 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
3 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
4 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
5 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
6 & Beta & Gamma & Alpha & Beta & Gamma & Beta & Gamma\\
\end{tblr}
}
\end{document}
Best Answer
I think you are confusing the
tblr
environment with thetable
environment. The former is for creating a tabular like structure, while the latter is the floating environment. Thecaption
(andlabel
) have to go in the floating environment.I also made some further improvements to your code
table
option forxcolor
is not needed when usingtabularray
rowhead
option, as it is only needed forlongtblr
\scalebox
as it leads to inconsistent font sizes*{8}{c}
incolspec
to repeat thec
column8
timesrowspec
definition withodd
option for row coloring. This is far more flexible, as it doesn't depend on the number of rowsvline
andhline
definition: you can use the lettersX
,Y
andZ
to refer to the last threecolumns
(orrows
) respectively. This makes your code more readable and is also more flexible should you change the number of columns later