
Derzeit verwende ich MD-Framed-Boxen, um meine Tabellen zu umgeben.
\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}
Aber ich versuche, die Ausgabe folgendermaßen zu erhalten:
Alles in der Nähe davon funktioniert auch. Wie gehe ich vor?
Ich habe Folgendes versucht:
\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}
Aber es hat nicht funktioniert. Außerdem habe ich gerade gelernt, dass die Verwendung von „captionof“ mit „longtable“ nicht das Richtige ist.
Antwort1
Hier ist eine Kurzversion eines benutzerdefinierten Etikettenformats. Wenn Sie dies nicht möchten, :
entfernen Sie es #2
aus der Definition.
\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}