# How can I use a short key to automatic math mode all rows of a table in tabularray package?

I am trying make this table. My code

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{diagbox}
\usepackage{siunitx}
\usepackage{ninecolors}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tblr}{
colspec={|c|c|},row{1}={olive9},
} \hline \text { Interval } & \text { Frequency } \\
\hline $\left[a_1 ; a_2\right)$ & $n_1$ \\
{$\left[a_2 ; a_3\right)$} & $n_2$ \\
$\ldots$ & $\ldots$ \\
{$\left[a_m ; a_{m+1}\right)$} & $n_m$ \\
\hline & $n$ \\
\hline
\end{tblr}
\caption{}
\end{table}
\end{document}


In each row of the table, I use $$. How can I use a short key, e.g \newcolumntype{C}{>{\displaystyle}c<{}} to all mathmode of the table to remove all $$ in rows?

You can use cells={mode=imath} to change all cells to inline math mode (or use dmath to get display style math):

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{diagbox}
\usepackage{siunitx}
\usepackage{ninecolors}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tblr}{
colspec={cc},
row{1}={olive9},
vlines,
hline{1,2,Y,Z} = {solid},
cells={mode=dmath},
row{1}={mode=text}
}
Interval & Frequency\\
\left[a_1 ; a_2\right)  &  n_1  \\
\left[a_2 ; a_3\right)  &  n_2  \\
\ldots  &  \ldots  \\
\left[a_m ; a_{m+1}\right) &  n_m  \\
&  n  \\
\end{tblr}
\caption{}
\end{table}
\end{document}


• Please explain for me this line hline{1,2,Y,Z} = {solid} and how can I use dmath? Jan 26 at 13:13
• The line hline{1,2,Y,Z} = {solid} will automatically insert horizontal lines for the first two and last two rows so you don't need all the \hlines in the code. You can use dmath as in cells={mode=dmath} (but for your example I doubt this will make much difference) Jan 26 at 13:14
• Thank you very much. Jan 26 at 13:22
• @JohnPaulPeter You're welcome! You could simplify your table further by using row{1}={mode=text} so you don't need the \text{...} in your first row Jan 26 at 13:26