在 xltabular 环境之外有标题

在 xltabular 环境之外有标题

是否可以在xltabular环境之外定义标题?

\documentclass[a4paper,10pt,notitlepage]{article}   % papersize, fontsize, documentclass; 
\usepackage{xltabular}
\usepackage[flushleft]{threeparttablex}     % to have a dedicated notes section after tables
\usepackage[font=small, margin=0pt]{caption}            % table and figure captions
\usepackage[table]{xcolor}                  % used for table alternatively colors
\usepackage{booktabs}                       % use package booktabs for easy creating tables

% Spacing and margin rules
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{1pt}%
\setlength{\abovecaptionskip}{7pt}
\setlength{\belowcaptionskip}{10pt}
\setlength{\textfloatsep}{5pt}
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

% CAPTION STYLE
%-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
\DeclareCaptionFormat{labelstyle}{%
    \setlength\fboxsep{3pt}%
    \colorbox{blue}{{#1}}#2#3
} 

\captionsetup[table]{singlelinecheck=false, labelfont={color=white}}    % Rechtsbündige Tabellen und Bildbeschreibung
\captionsetup[figure]{singlelinecheck=false, labelfont={color=white}, justification = raggedright, format=labelstyle}

% ------------------------------------------------------------------------------------------------------------------------
% TABLE
\newcommand{\tablestyle} { 
    \captionsetup{type=table, format=labelstyle}
    \renewcommand{\arraystretch}{1.25}
    \arrayrulecolor{blue} 
    \aboverulesep = 0mm 
    \belowrulesep = 0mm 
    }

\newenvironment{tableenv}[2]{
    \par\vspace{0.5cm}
    \def\tablecaption{#1}
    \def\tablelabel{tab:#2}
        \small
        \tablestyle
        \begin{ThreePartTable}
}{
        % \setlength{\abovecaptionskip}{0pt}
        \caption{\tablecaption}
        \label{\tablelabel}
    \end{ThreePartTable}
}

\begin{document}

\section{Section with long table}
\begin{tableenv}{test}{test}
\begin{xltabular}{\linewidth}{@{} X @{}}

    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
    awdafgawfgawfa\\
\end{xltabular}
\end{tableenv}

\end{document}

这样就使得标题随着每个新表格而获得 +2 的增量......

相关内容