Longtable의 캡션 주위에 색상이 채워진 프레임을 배치하는 방법은 무엇입니까?

Longtable의 캡션 주위에 색상이 채워진 프레임을 배치하는 방법은 무엇입니까?

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}

추신: '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}}

관련 정보