
\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가 세 번째 테이블로 제공됩니다. 이를 수정하는 방법은 무엇입니까?
답변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
and 를 적어야 합니다 .\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}