0

Currently I am using mdframed boxes to surround my tables.

\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}

And it produces the output: image1

But I am trying to get the output as: image2

Anything close to this will also work. How do I proceed?

I tried doing:

    \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}

But it did not work, also I have just leanrt that using captionof with longtable is not the right thing to do.

  • Read the caption package's manual and you'll know what to do. With that package you can customize nearly everything of a caption. – TeXnician Jun 29 '17 at 18:03
1

Here's a short version of a customized label format. If you do not want the : remove #2 from the definition.

table caption

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.