ロングテーブルのキャプションの周りに色付きのフレームを配置するにはどうすればよいですか?

ロングテーブルのキャプションの周りに色付きのフレームを配置するにはどうすればよいですか?

tcolorbox私は、 に入れた長い表のキャプションの周りに、色で塗りつぶされたフレーム(たとえば、パッケージ付き)を配置したいと思います\endlastfoot。私はこの質問への回答を使用しました:枠付きキャプションと図、色付きキャプション付き他の図や表ではうまく機能しましたが、longtable環境では機能しません。この質問に対する回答を使用しました長テーブルに色を付けるキャプションの複数行に色を付けようとしましたが、見栄えがよくフレーム化されません。

\documentclass[a4paper, 12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}
\usepackage[margin=2cm]{geometry}
\setlength{\parindent}{5mm}

%Tabels:
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{caption}

%Adjusted Command to color the caption from https://tex.stackexchange.com/questions/345589/color-a-longtable/345602#345602
\definecolor{lightGray}{gray}{0.95}
\def\ColorTabelHeader{lightGray}

\newcommand*{\BeginHeadcolor}{%
  \arrayrulecolor{gray}\toprule[0.7pt]
  \rowcolor{\ColorTabelHeader}%
  \noalign{%
    \kern-\belowrulesep
    \begingroup
      \color{\ColorTabelHeader}\hrule height\belowrulesep
    \endgroup
  }%
}
\newcommand*{\EndHeadcolor}{%
  \noalign{%
    \begingroup
      \color{\ColorTabelHeader}%
      \hrule height\aboverulesep
    \endgroup
    \kern-\aboverulesep
  }%
  \toprule[0.7pt] \arrayrulecolor{black}
}
\makeatletter
\newcommand*{\LTBeginHeadcolor}{%
  \arrayrulecolor{gray}\toprule[0.7pt]
    \vadjust pre{\kern-\belowrulesep}%
    \begingroup
      \color{\ColorTabelHeader}%
      \leaders\hrule height\belowrulesep\hfill
    \endgroup
  \cr
  \rowcolor{\ColorTabelHeader}%
}
\newcommand*{\LTEndHeadcolor}{%
  \multispan\LT@cols
    \begingroup
      \color{\ColorTabelHeader}%
      \leaders\hrule height\aboverulesep\hfill
    \endgroup
  \cr
  \noalign{%
    \kern-\aboverulesep
  }%
 \toprule[0.7pt] \arrayrulecolor{black}
}
\makeatother


% Settings for Longtable
\setlength\LTleft{0pt} 
\setlength\LTright{0pt}
\setlength{\LTcapwidth}{\columnwidth}
% To make it load faster
\setcounter{LTchunksize}{50}

\begin{document}

\renewcommand\arraystretch{0.8}
\begin{longtable}{c|c >{\columncolor[gray]{.9}}c c >{\columncolor[gray]{.9}}c c}
\LTBeginHeadcolor
\caption[]{\textbf{Caption:}
some information describing the content}\\
\LTEndHeadcolor \endfoot
\LTBeginHeadcolor
\caption[]{\textbf{Caption:}
this is a very long caption with some additional information regarding the parameters.\label{tab:Sample}}\\*
\rowcolor{\ColorTabelHeader}
\multicolumn{6}{c}{\parbox{\LTcapwidth}{{\footnotesize This Information is so long, that I had to put it in an extra paragraph with a smaller font}}}\\
\LTEndHeadcolor
\endlastfoot 
    \toprule
   \multirow{2}[2]{*}[2mm]{\textbf{Parameter}} &      & \textbf{BLH} & \textbf{0h} & \textbf{4h} & \textbf{8h} \\
          &       & Median (SD) & Median (SD) & Median (SD) & Median (SD) \\
    \midrule  \endfirsthead
     \toprule    
   \multirow{2}[2]{*}[2mm]{\textbf{Parameter}} &      & \textbf{BLH} & \textbf{0h} & \textbf{4h} & \textbf{8h} \\
          &       & Median (SD) & Median (SD) & Median (SD) & Median (SD) \\
    \midrule     \endhead
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \\[0,3cm]    
    \bottomrule
\end{longtable}%%


\end{document}

答え1

Axel のおかげで、私の問題に対する可能な解決策を見つけることができました。私は Latex に比較的慣れておらず、マクロにもあまり慣れていないので、私が犯した間違いがあれば教えてください。または、回答を編集してください。

色で塗りつぶされたフレーム付き LTcaptionbox のコード:

\usepackage[many]{tcolorbox}

    \makeatletter
    \newtcolorbox{LTcaptionbox}[7][]{enhanced, colframe=gray, colback=gray!30, arc=0pt, outer arc=0pt, boxrule=0.7pt, before={}, #1}
    \DeclareCaptionOption{stuffforbox}{\def\caption@stuffforbox{#1}}

    \DeclareCaptionBox{myLTbox}{%
      \begin{LTcaptionbox}[code={\pgfkeysalsofrom{\caption@stuffforbox}}]
        #2%
      \end{LTcaptionbox}%
    }
    \makeatother
    \captionsetup[longtable]{stuffforbox={}, box={myLTbox}, slc=off}

そして、編集した表(ページ全体を埋めるために「tabu」パッケージを追加し、「\bottomrule」とLTCaptionboxを同じ幅に調整しました)

\documentclass[a4paper, 12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,ngerman]{babel}
\usepackage[margin=2cm]{geometry}
\setlength{\parindent}{5mm}

%Tabels:
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{caption}
\usepackage{tabu}


\usepackage[many]{tcolorbox}

\makeatletter
\newtcolorbox{LTcaptionbox}[7][]{enhanced, colframe=gray, colback=gray!30, arc=0pt, outer arc=0pt, boxrule=0.7pt, before={}, #1}
\DeclareCaptionOption{stuffforbox}{\def\caption@stuffforbox{#1}}

\DeclareCaptionBox{myLTbox}{%
  \begin{LTcaptionbox}[code={\pgfkeysalsofrom{\caption@stuffforbox}}]
    #2%
  \end{LTcaptionbox}%
}
\makeatother
\captionsetup[longtable]{stuffforbox={}, box={myLTbox}, slc=off}

% Settings for Longtable
\setlength\LTleft{0pt} 
\setlength\LTright{0pt}
\setlength{\LTcapwidth}{\glueexpr(\textwidth-10mm-1,4pt)\relax} % minus Distance text- to outer edge of the bounding-box on both sides
% To make it load faster
\setcounter{LTchunksize}{50}

\begin{document}



\begin{longtabu}{X|X X X X X}
\caption[]{\textbf{Caption:} some information describing the content}\endfoot
\caption[CaptionLOT]{\textbf{Caption:} this is a very long caption with some additional information regarding the parameters.\label{tab:Sample}\\*
{\footnotesize This Information is so long, that I had to put it in an extra paragraph with a smaller font}}
\endlastfoot 
    \toprule
   \multirow{2}[2]{*}[2mm]{\textbf{Parameter}} &      & \textbf{BLH} & \textbf{0h} & \textbf{4h} & \textbf{8h} \\
          &       & Median (SD) & Median (SD) & Median (SD) & Median (SD) \\
    \midrule  \endfirsthead
     \toprule    
   \multirow{2}[2]{*}[2mm]{\textbf{Parameter}} &      & \textbf{BLH} & \textbf{0h} & \textbf{4h} & \textbf{8h} \\
          &       & Median (SD) & Median (SD) & Median (SD) & Median (SD) \\
    \midrule     \endhead
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\
    Parameter & Group1 & 1 & 2 & 3 & 4 \\*
    {[unit]} & Group2 & 1 & 2 & 3 & 4 \vspace{0,3cm}\\    
    \bottomrule \addlinespace[1pt]
\end{longtabu}%%


\end{document}

PS: 'Longtabu' の X 列で '\columncolor' を使用できませんでした。この問題の解決策を知っている人はいますか?
'Longtable' 環境を維持したい場合は、次のコードを使用できます:

\newlength\q
\setlength\q{\dimexpr 0.166\textwidth -2\tabcolsep\relax}

そして

\begin{longtable}{p{\q}|p{\q} >{\columncolor[gray]{.95}\centering\arraybackslash}p{\q} >{\centering\arraybackslash}p{\q} >{\columncolor[gray]{.95}\centering\arraybackslash}p{\q} >{\centering\arraybackslash}p{\q}}

関連情報