1

I created such config

\SetTblrTemplate{middlehead, lasthead, foot}{empty}
\SetTblrStyle{head, caption}{halign=l}

\newlength\lwidth
\setlength\lwidth{0.7pt}

\NewDocumentEnvironment{tabl}{m +b}{
    \begin{longtblr}[caption=#1]{hlines={\lwidth}, hline{2}={2\lwidth}, vlines={\lwidth}, columns={halign=c, valign=m, co=1}, width=\linewidth}
        #2
    \end{longtblr}
}{}

Usage:

        \begin{tabl}{caption}
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
        \end{tabl}

It should align caption left but setting \SetTblrStyle{head, caption}{halign=l}, but it doesn't do. I get: enter image description here

I wonder if I understood something wrong, or is it a bug? I found that someone wrote his own config to do this here.

1 Answer 1

1

You can use caption package to configure your captions and tblr-extras caption library to make tabularray longtblr and talltblr use those captions.

\documentclass{article}
\usepackage{tabularray,tblr-extras}
\UseTblrLibrary{caption}

\captionsetup[table]{singlelinecheck=false,position=above,justification=raggedright}

\newlength\lwidth
\setlength\lwidth{0.7pt}
\SetTblrTemplate{middlehead, lasthead, foot}{empty}

\begin{document}
    \begin{longtblr}[
        caption={A caption example}
        ]{
        colspec=ccc,
        hlines={\lwidth},
        hline{2}={2\lwidth},
        vlines={\lwidth},
        columns={halign=c, valign=m, co=1}, width=\linewidth,
        }
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
            1 & 1 & 1 \\
    \end{longtblr}
    
    \bigskip
    
    \captionsetup[table]{justification=raggedleft}
    
    \begin{longtblr}[
    caption={A caption example}
    ]{
        colspec=ccc,
        hlines={\lwidth},
        hline{2}={2\lwidth},
        vlines={\lwidth},
        columns={halign=c, valign=m, co=1}, width=\linewidth,
    }
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
    \end{longtblr}
    
    
    
    \captionsetup[table]{justification=centering}
    
    \begin{longtblr}[
        caption={A caption example}
        ]{
            colspec=ccc,
            hlines={\lwidth},
            hline{2}={2\lwidth},
            vlines={\lwidth},
            columns={halign=c, valign=m, co=1}, width=\linewidth,
        }
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
        1 & 1 & 1 \\
    \end{longtblr}
\end{document}

enter image description here

You must log in to answer this question.

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