Abstand zwischen den Zeilen anpassen und Kopfzeile auf jeder Seite wiederholen?

Abstand zwischen den Zeilen anpassen und Kopfzeile auf jeder Seite wiederholen?

Ich hatte dabei ein Problem longtable, da jede Spalte lang ist und wie im Bild gezeigt auf einer Seite gedruckt wird. Außerdem muss beim Weitergehen zur nächsten Seite die Kopfzeile der ersten Zeile wiederholt werden.

Bildbeschreibung hier eingeben

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

Antwort1

Für sich wiederholende Überschriften verwenden Sie \endfirstheadund \endhead. Um den Abstand zwischen den Zeilen zu vergrößern, können Sie makecellund dessen \setcellgapsund \makegapedcellsinnerhalb einer Gruppe verwenden. Sie benötigen keine centerUmgebung, da longtalestandardmäßig zentriert ist. Übrigens passt Ihre Tabelle nicht in die Breite (und ich habe es nicht korrigiert).

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

verwandte Informationen