
\documentclass{book}
\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}
%\begin{table}[H]
\centering
\captionof{table}{Crane shop activities.}
\label{table:crane_shop_activities}
\begin{longtable}{|m{2cm}| m{4cm}| m{4cm}|}
\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{table}
\end{mytablebox}
Activities related to 140T crane are given in detail in table \ref{table:140T_activities}.
\begin{mytablebox}
\begin{table}[H]
\caption{140T Crane activities.}
\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}
\hline
1$^{st}$ POH & After 8 yrs\\
\hline
2$^{nd}$ POH & After 16 yrs\\
\hline
MLR & After 22 yrs\\
\hline
SP MLR & After 30 yrs\\
\hline
SR (Special Repair) & Accidental and unpredictable\\
\hline
\end{tabular}
\label{table:140T_activities}
\end{table}
\end{mytablebox}
\end{document}
Таблица номер 2 идет как 3-я таблица. Как это исправить?
решение1
Боюсь, что нет мягкого способа заявить об этом: вы неправильно используете окружение longtable
иtable
имакрос \captionof
.
Если вы используете
longtable
среду,не использоватьзаявление\captionof{table}{...}
. Вместо этого используйте стандартное\caption
заявление.Если вы собираетесь поместить какой-то табличный материал в
mytablebox
среду,не использоватьокружениеtable
вместе с\caption
оператором. Вместо этого избавьтесь отtable
оболочки, примените\centering
директиву и используйте\captionof
оператор.
\documentclass{book}
\usepackage{array}
\setlength\extrarowheight{2pt} % for a more "open" look
\usepackage{mdframed}
\usepackage{multirow}
\usepackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{243,102,25}
\usepackage{float}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{booktabs}
\usepackage{longtable}
\newmdenv[%
linecolor=ocre,
backgroundcolor=ocre!10,
linewidth=1pt]
{Tablebox}
\newenvironment{mytablebox}
{\begin{Tablebox}}{\end{Tablebox}}
\begin{document}
Various activities performed in the Crane shop are given in table \ref{table:crane_shop_activities}.
\begin{mytablebox}
\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}
Activities related to 140T crane are given in detail in table \ref{table:140T_activities}.
\begin{mytablebox}
\centering % <-- new!
%\begin{table}[H] %% do NOT use a 'table' env.
\captionof{table}{140T Crane activities.} %% use '\captionof', not '\caption'
\label{table:140T_activities}
\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}
\hline
1$^{st}$ POH & After 8 yrs\\
\hline
2$^{nd}$ POH & After 16 yrs\\
\hline
MLR & After 22 yrs\\
\hline
SP MLR & After 30 yrs\\
\hline
SR (Special Repair) & Accidental and unpredictable\\
\hline
\end{tabular}
%\end{table}
\end{mytablebox}
\end{document}
решение2
решение сlongtabular
Вам нужно написать \caption
и \label
внутри longtabular
.
\documentclass{book}
\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}
Activities related to 140T crane are given in detail in table \ref{table:140T_activities}.
\begin{mytablebox}
\begin{table}[H]
\caption{140T Crane activities.}
\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}
\hline
1$^{st}$ POH & After 8 yrs\\
\hline
2$^{nd}$ POH & After 16 yrs\\
\hline
MLR & After 22 yrs\\
\hline
SP MLR & After 30 yrs\\
\hline
SR (Special Repair) & Accidental and unpredictable\\
\hline
\end{tabular}
\label{table:140T_activities}
\end{table}
\end{mytablebox}
\end{document}
решение безlongtabular
Если вы используете tabular
вместо longtable
это работает. Чтобы избежать разного интервала, вы должны использовать \captionof
также для второй таблицы.
\documentclass{book}
\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
\captionof{table}{Crane shop activities.}
\label{table:crane_shop_activities}
\begin{tabular}{|m{2cm}| m{4cm}| m{4cm}|}
\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{tabular}
\end{mytablebox}
Activities related to 140T crane are given in detail in table \ref{table:140T_activities}.
\begin{mytablebox}
\captionof{table}{140T Crane activities.}
\label{table:140T_activities}
\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}
\hline
1$^{st}$ POH & After 8 yrs\\
\hline
2$^{nd}$ POH & After 16 yrs\\
\hline
MLR & After 22 yrs\\
\hline
SP MLR & After 30 yrs\\
\hline
SR (Special Repair) & Accidental and unpredictable\\
\hline
\end{tabular}
\end{mytablebox}
\end{document}