samcarter
While looking for a workaround for [CarLaTeX's recent question](https://topanswers.xyz/tex?q=2217) I was wondering if it is possible for a user to define a new horizontal alignment in tabularray.
My naive attempt was to look into the source for `\TblrAlignRight`, copy these lines and and give them a new name:
```
\documentclass{article}
\usepackage{tabularray}
\NewDocumentCommand\TblrAlignSam{}{\raggedleft}
\ExplSyntaxOn
\cs_new_eq:NN \__tblr_halign_command_s: \TblrAlignSam
\ExplSyntaxOff
\begin{document}
\begin{tblr}{colspec={Q[s,t]Q[c,m]Q[l,b]}, hlines}
{The baseline is\\ at the top\\ (right aligned)} &
{The baseline is\\ in the middle\\ (centered)} &
{The baseline is\\ at the bottom\\ (left aligned)}\\
\end{tblr}
\end{document}
```
However this results in the error
```
! Undefined control sequence.
<argument> \color
{\l__tblr_b_tl }\vrule width \dim_use:N \l_tmpa_dim heigh...
l.16 \end
{tblr}
```
Is there a way for an user to define additional horizontal alignments?
Top Answer
samcarter
Rubber duck debugging worked great and as soon as I posted the question, I found a solution :)
I also need to add it to the tblr-column keys:
```
\documentclass{article}
\usepackage{tabularray}
\NewDocumentCommand\TblrAlignSam{}{\raggedleft}
\ExplSyntaxOn
\cs_new_eq:NN \__tblr_halign_command_s: \TblrAlignSam
\keys_define:nn { tblr-column } { s.meta:n = { halign = s } }
\ExplSyntaxOff
\begin{document}
\begin{tblr}{colspec={Q[s,t]Q[c,m]Q[l,b]}, hlines}
{The baseline is\\ at the top\\ (right aligned)} &
{The baseline is\\ in the middle\\ (centered)} &
{The baseline is\\ at the bottom\\ (left aligned)}\\
\end{tblr}
\end{document}
```
Or alternatively explicitly use `halign=s` in the column instead of the shorthand:
```
\documentclass{article}
\usepackage{tabularray}
\NewDocumentCommand\TblrAlignSam{}{\raggedleft}
\ExplSyntaxOn
\cs_new_eq:NN \__tblr_halign_command_s: \TblrAlignSam
\ExplSyntaxOff
\begin{document}
\begin{tblr}{colspec={Q[halign=s,t]Q[c,m]Q[l,b]}, hlines}
{The baseline is\\ at the top\\ (right aligned)} &
{The baseline is\\ in the middle\\ (centered)} &
{The baseline is\\ at the bottom\\ (left aligned)}\\
\end{tblr}
\end{document}
```