mdframed 상자 및 테이블 사용자 정의

mdframed 상자 및 테이블 사용자 정의

현재 저는 테이블을 둘러싸기 위해 mdframed 상자를 사용하고 있습니다.

\documentclass{article}

\usepackage{array}
\usepackage{mdframed}
\usepackage{multirow}
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{float}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{longtable}

\newmdenv[%
linecolor=ocre,
backgroundcolor=ocre!10,
linewidth=1pt]
{Tablebox}   


\newenvironment{mytablebox}
{
    \begin{Tablebox}
        
    }
    {
    \end{Tablebox}
}



\begin{document}
        The various activities which are performed in the Crane shop are given in table \ref{table:crane_shop_activities}.
        \begin{mytablebox}
            \centering
            
            \begin{longtable}{|m{2cm}| m{4cm}| m{4cm}|}
                \caption{Crane shop activities.}
                \label{table:crane_shop_activities}\\
                \hline
                \textbf{Category} & \textbf{Types} & \textbf{Activities}\\
                \hline
                \multirow{3}{*}{Tower Car} & Mark II, III, IV & \multirow{3}{4cm}{Earlier Manufacturing, currently only POH}\\
                \cline{2-2}
                & DHTC (Diesel Hydraulic Tower Car) & \\
                \cline{2-2}
                & 8 Wheeler &\\
                \hline
                \multirow{2}{*}{20T Crane} & Mechanical & \multirow{2}{4cm}{Both Manufacturing and POH}\\
                \cline{2-2}
                & Hydraulic (retrofitting of mechanical superstructure with hydraulic one) & \\
                \hline
                \multirow{2}{*}{140T Crane} & Old Design Crane & POH, MLR, SP MLR\\
                \cline{2-3}
                & New Design Crane & Manufacturing, POH, MLR, SP MLR\\
                \hline
            
            \end{longtable}
        \end{mytablebox}
\end{document}

그리고 다음과 같은 출력을 생성합니다. 이미지1

하지만 다음과 같이 출력을 얻으려고합니다. 이미지 2

이것에 가까운 것은 무엇이든 작동합니다. 어떻게 진행하나요?

나는 다음을 시도했습니다.

    \newenvironment{mytablebox}[1]
    {
        \begin{Tablebox}
            \textcolor{ocre}{#1~}
        }
        {
        \end{Tablebox}
    }

\begin{mytablebox}{\captionof{table}{Crane shop activities.}}
        \centering
        
        \begin{longtable}{|m{2cm}| m{4cm}| m{4cm}|}
            %\caption{Crane shop activities.}
            \label{table:crane_shop_activities}\\
            \hline
            \textbf{Category} & \textbf{Types} & \textbf{Activities}\\
            \hline
            \multirow{3}{*}{Tower Car} & Mark II, III, IV & \multirow{3}{4cm}{Earlier Manufacturing, currently only POH}\\
            \cline{2-2}
            & DHTC (Diesel Hydraulic Tower Car) & \\
            \cline{2-2}
            & 8 Wheeler &\\
            \hline
            \multirow{2}{*}{20T Crane} & Mechanical & \multirow{2}{4cm}{Both Manufacturing and POH}\\
            \cline{2-2}
            & Hydraulic (retrofitting of mechanical superstructure with hydraulic one) & \\
            \hline
            \multirow{2}{*}{140T Crane} & Old Design Crane & POH, MLR, SP MLR\\
            \cline{2-3}
            & New Design Crane & Manufacturing, POH, MLR, SP MLR\\
            \hline
        
        \end{longtable}
    \end{mytablebox}

그러나 그것은 작동하지 않았습니다. 또한 Longtable에서 captionof를 사용하는 것은 올바른 일이 아니라는 것을 배웠습니다.

답변1

다음은 사용자 정의된 라벨 형식의 짧은 버전입니다. 정의에서 :제거 를 원하지 않는 경우 .#2

표 캡션

\documentclass{article}

\usepackage{array}
\usepackage{mdframed}
\usepackage{multirow}
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{float}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{longtable}

\newmdenv[%
linecolor=ocre,
backgroundcolor=ocre!10,
linewidth=1pt]
{Tablebox}   

\DeclareCaptionFormat{myformat}{\parbox{\linewidth}{
    \centering #1#2\\
    #3}}
\DeclareCaptionFont{lfont}{\color{orange}\Large\bfseries}
\DeclareCaptionFont{tfont}{\color{orange}}
\captionsetup[table]{labelfont=lfont,font=tfont,format=myformat}

\newenvironment{mytablebox}
{
    \begin{Tablebox}

    }
    {
    \end{Tablebox}
}



\begin{document}
        The various activities which are performed in the Crane shop are 
given in table \ref{table:crane_shop_activities}.
        \begin{mytablebox}
            \centering

            \begin{longtable}{|m{2cm}| m{4cm}| m{4cm}|}
                \caption{Crane shop activities.}
                \label{table:crane_shop_activities}\\
                \hline
                \textbf{Category} & \textbf{Types} & 
\textbf{Activities}\\
                \hline
                \multirow{3}{*}{Tower Car} & Mark II, III, IV & 
\multirow{3}{4cm}{Earlier Manufacturing, currently only POH}\\
                \cline{2-2}
                & DHTC (Diesel Hydraulic Tower Car) & \\
                \cline{2-2}
                & 8 Wheeler &\\
                \hline
                \multirow{2}{*}{20T Crane} & Mechanical & 
\multirow{2}{4cm}{Both Manufacturing and POH}\\
                \cline{2-2}
                & Hydraulic (retrofitting of mechanical superstructure 
with hydraulic one) & \\
                \hline
                \multirow{2}{*}{140T Crane} & Old Design Crane & POH, 
MLR, SP MLR\\
                \cline{2-3}
                & New Design Crane & Manufacturing, POH, MLR, SP MLR\\
                \hline

            \end{longtable}
        \end{mytablebox}
\end{document}

관련 정보