为 talltblr 创建 \NewTblrEnviron 以制定标准的全局表头和规则

为 talltblr 创建 \NewTblrEnviron 以制定标准的全局表头和规则

是否可以基于talltblr(从tabularray-package)创建自定义环境?类似\NewTblrEnvironfor tblr,但可以添加脚注和标题。

我想为文本和数学表创建一个标准的全局表布局(表头字体、空格和 toprule\midrule\bottomrule),这样我就不必为每个表设置所有设置。我可以通过 来添加设置talltblr\SetTblrInner但我需要包含数学内容的表的其他默认设置。因此,我想知道如何基于 创建一个新环境talltblr

请参见下面的 MWE 和 MWE 结果图。

\documentclass{article}

\usepackage{tabularray}%
    \UseTblrLibrary{amsmath,booktabs}%

% Standard text header setup
\SetTblrInner[talltblr]{%
        hline{1,Z}  = {1pt,purple},% top & bottomrule
        hline{2}    = {0.3pt,purple},% midrule
        row{1}      = {font=\sffamily\bfseries\color{teal}, halign=c, abovesep+=2pt},% header
        row{2}      = {abovesep+=1pt},% extra space under midrule
        stretch     = 1.3,% vertical stretch
}

% Math header setup
% \SetTblrInner[mathtalltblr]{%
        % hline{1,Z}  = {1pt,purple},% top & bottomrule
        % hline{2}    = {0.3pt,purple},% midrule
        % row{1}      = {mode=text, font=\sffamily\bfseries\color{teal}, halign=c, abovesep+=2pt},% header
        % row{2}      = {abovesep+=1pt},% extra space under midrule
        % row{2-Z}    = {mode=dmath, rowsep+=7pt},% table content
        % stretch     = 1.3,% vertical stretch
% }

%--------------------------------------------------------------%
\begin{document}
%--------------------------------------------------------------%

%---------------------------%
\section{Text table}

Referencing tables automatically by \ref{tblr:talltabfntest}.

\bigskip

\noindent\begin{talltblr}[
    caption = {Footnote table with caption footnote\TblrNote{a}},
    entry   = {Caption for LoT without footnote},
    label   = {tblr:talltabfntest},
    note{a} = {It is the footnote text.},
]{
    colspec = { *{4}{l} },
}
% Header
            Treatments &
            Response\TblrNote{a} &
            Num \\
% Table
            Treatment 1 & 0.0003262 & 0.562 \\
            Treatment 2 & 0.0015681 & 0.910 \\
            Treatment 3 & 0.0009271 & 0.296 \\
            Treatment 1 & 0.0003262 & 0.562 \\
            Treatment 2 & 0.0015681 & 0.910 \\
            Treatment 3 & 0.0009271 & 0.296 \\
\end{talltblr}

\bigskip

%---------------------------%
\section{Math table}

Referencing tables automatically by \ref{tblr:talltabmathtest}.

\bigskip

\noindent$\begin{talltblr}[
    caption = {A math mode table with a lot of display-\-style columns},
    label   = {tblr:talltabmathtest},
    note{*} = {It is the footnote text.},
]{
    colspec = { *{4}{X[c,m]} },
% Math header extra setup
    row{1}  = {mode=text},% header
    row{2-Z}= {mode=dmath, rowsep+=7pt},% table content
}
% Header
        Head 1 &
        Head 2 &
        Head 3 &
        Head 4 \\
% Table
        \int\cos{x} \; dx &
        \sin{x} + c &
        \int\limits_{x\in C}\! x \; dx &
        \dfrac{1}{4} 
    \\
        \int_0^2x^2 \; dx\TblrNote{*} &
        e^x + c &
        \prod_{i=1}^ni=n! &
        \tfrac{1}{4}
    \\
        \int\sec^2{x} \; dx &
        \frac{[f(x+h) - f(x)}{h} & 
        \sqrt{y} &
        \frac{2}{4} \\
\end{talltblr}$

\end{document}

例子

答案1

事实上,longtblrtalltblr的定义如下:

\NewTblrEnviron{longtblr}
\SetTblrOuter[longtblr]{long}
\NewTblrEnviron{talltblr}
\SetTblrOuter[talltblr]{tall}

因此您需要的是以下定义:

\NewTblrEnviron{mathtalltblr}
\SetTblrOuter[mathtalltblr]{tall}
\SetTblrInner[mathtalltblr]{
  hline{1,Z} = {1pt,purple},
  %% more specs
}

相关内容