행 사이의 거리를 조정하고 각 페이지의 머리글을 반복하시겠습니까?

행 사이의 거리를 조정하고 각 페이지의 머리글을 반복하시겠습니까?

longtable각 열이 길어서 그림과 같이 한 페이지에 인쇄되고 다음 페이지로 이동할 때 첫 번째 행 머리글 반복이 필요하다는 문제에 직면했습니다 .

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{array}
\usepackage{lscape}
\usepackage{caption}
\newcounter{temp}
\newcommand{\first}{\setcounter{temp}{1}\thetemp- }
\newcommand{\following}{\stepcounter{temp}\par\thetemp- }

\begin{document}
%\begin{landscape}
    \begin{center}
        \captionof{table}{Comparison Between the Wormhole Attacks}
        \begin{longtable}{|p{1.8cm}|>{\RaggedRight}p{2.5cm}|>{\RaggedRight}p{2.4cm}|>{\RaggedRight}p{2.1cm}|>{\RaggedRight}p{2.2cm}|>{\RaggedRight}p{2.2cm}|} 
            \hline
            \textbf{Wormhole types} & \textbf{Encapsulation} & \textbf{Out of Band} & \textbf{High Power} & \textbf{Packet Relay} & \textbf{Protocol Deviations} \\\hline      
            Advantages  
            & \first there is a smaller probability of RREQ being discarded than other RREQs which are repeatedly received by intermediate nodes.
                \following RREQ packet arriving to destination, does not keep middle nodes as hops, and then it appears to have passed through minimum number of hops. 
            & \first Control packet arrives faster due to no process from middle nodes
                \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
                \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops 
            & \first Control packets arrive faster
                \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
                \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops    
            & \first Two nodes think they are neighbors although they are not, and every RREQ to be sent to neighbors will arrive to relay nodes invisibility.
                \following Control packet seems to arrive using minimum number of hops   
            & control packet arrives faster \\\hline  
            Advantages  
            & \first there is a smaller probability of RREQ being discarded than other RREQs which are repeatedly received by intermediate nodes.
            \following RREQ packet arriving to destination, does not keep middle nodes as hops, and then it appears to have passed through minimum number of hops. 
            & \first Control packet arrives faster due to no process from middle nodes
            \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
            \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops 
            & \first Control packets arrive faster
            \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
            \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops    
            & \first Two nodes think they are neighbors although they are not, and every RREQ to be sent to neighbors will arrive to relay nodes invisibility.
            \following Control packet seems to arrive using minimum number of hops   
            & control packet arrives faster \\\hline   

        \end{longtable}
    \end{center}
%\end{landscape}
\end{document}

답변1

제목을 반복하려면 \endfirsthead및 를 사용하세요 \endhead. 행 사이의 간격을 늘리려면 그룹 내부에서 makecell및 its \setcellgaps및 을 사용할 수 있습니다 . 기본적으로 중앙에 있으므로 환경이 \makegapedcells필요하지 않습니다 . 그런데 테이블이 너비에 맞지 않습니다(그리고 수정하지 않았습니다).centerlongtale

\documentclass{article}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{microtype}
\usepackage{ragged2e}
\usepackage{array}
\usepackage{lscape}
\usepackage{caption}
\newcounter{temp}
\newcommand{\first}{\setcounter{temp}{1}\thetemp- }
\newcommand{\following}{\stepcounter{temp}\par\thetemp- }
\usepackage{makecell}
\setcellgapes{5pt}


\begin{document}
%\begin{landscape}
%    \begin{center}  longtable is centered by default
        %\captionof{table}{Comparison Between the Wormhole Attacks}
{\makegapedcells        \begin{longtable}{|p{1.8cm}|>{\RaggedRight}p{2.5cm}|>{\RaggedRight}p{2.4cm}|>{\RaggedRight}p{2.1cm}|>{\RaggedRight}p{2.2cm}|>{\RaggedRight}p{2.2cm}|}
           \caption{Comparison Between the Wormhole Attacks}\\ \hline
            \textbf{Wormhole types} & \textbf{Encapsulation} & \textbf{Out of Band} & \textbf{High Power} & \textbf{Packet Relay} & \textbf{Protocol Deviations} \\\hline
\endfirsthead
\hline
\textbf{Wormhole types} & \textbf{Encapsulation} & \textbf{Out of Band} & \textbf{High Power} & \textbf{Packet Relay} & \textbf{Protocol Deviations} \\\hline
\endhead
            Advantages
            & \first there is a smaller probability of RREQ being discarded than other RREQs which are repeatedly received by intermediate nodes.
                \following RREQ packet arriving to destination, does not keep middle nodes as hops, and then it appears to have passed through minimum number of hops.
            & \first Control packet arrives faster due to no process from middle nodes
                \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
                \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops
            & \first Control packets arrive faster
                \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
                \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops
            & \first Two nodes think they are neighbors although they are not, and every RREQ to be sent to neighbors will arrive to relay nodes invisibility.
                \following Control packet seems to arrive using minimum number of hops
            & control packet arrives faster \\\hline
            Advantages
            & \first there is a smaller probability of RREQ being discarded than other RREQs which are repeatedly received by intermediate nodes.
            \following RREQ packet arriving to destination, does not keep middle nodes as hops, and then it appears to have passed through minimum number of hops.
            & \first Control packet arrives faster due to no process from middle nodes
            \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
            \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops
            & \first Control packets arrive faster
            \following Less probability of discarding compare to RREQs which are repeatedly received by middle nodes.
            \following Control packets arrive at destination, middle nodes not use as hops, pass through less number of hops
            & \first Two nodes think they are neighbors although they are not, and every RREQ to be sent to neighbors will arrive to relay nodes invisibility.
            \following Control packet seems to arrive using minimum number of hops
            & control packet arrives faster \\\hline

        \end{longtable}
}
%    \end{center}
%\end{landscape}
\end{document}

관련 정보