重复列标题错误

重复列标题错误

我想重复列标题并添加页脚,但遇到错误。请帮我制作表格的标题。以下是代码:

\documentclass{article} 

\usepackage[english]{babel} 
\usepackage{longtable} 
\usepackage{microtype} 
\usepackage{ragged2e} 
\usepackage{array} 
\usepackage{lscape} 
\usepackage{caption}

\begin{document}

\begin{landscape}
\newpage

%\begin{center}
%   \begin{adjustbox}{width=1\textwidth}
    %   \small
    \begin{center}
    %   \begin{adjustbox}{width=1\textwidth}
            \small

    \begin{longtable}{|p{3cm}|p{2.2cm}|p{1.8cm}|p{1.8cm}|p{1.8cm}|p{1.8cm}|p{1.8cm}|p{.8cm}|}
     \caption{ \bf New Wormhole Detection Methods } %\\ 
     \hline 
     \bf Protocol & \bf Requirement & \bf Routing Protocol & \bf Clock synchronization & \bf Remove wormhole & \bf Out of band Wormhole & \bf Extra Hardw-are & \bf QoS\\
     \hline \hline 
    \endfirsthead



  \hline 
 \multicolumn{8}{|r|}{{Continued on next page}} \\ \hline
 \endfoot

  \hline 
 \endlastfoot
     \bf Protocol & \bf Requirement & \bf Routing Protocol & \bf Clock synchronization & \bf Remove wormhole & \bf Out of band Wormhole & \bf Extra Hardw-are & \bf QoS\\
     \hline \hline
  \endhead


    \hline

      %  \tabularnewline[.5ex] \hline

        Cluster Based \citep{banerjee2014wormhole}
        & No special requirement & DSR & No & Yes & No & No & no \tabularnewline \hline

        Analytical Hierachy Process  \citep{shi2013countermeasure}
        & No special requirement & AODV & No & Yes & No & No & yes \tabularnewline \hline

         Path Tracing \citep{sakthivel2012detection}
         & No special requirement & DSR & No & Yes & No & No & \tabularnewline \hline


         Path Tracing \citep{anitha2012detection}
         & No special requirement & AODV & No & Yes & No & No & \tabularnewline \hline


         RTT Estimation \citep{raju2012simple}
         & No special requirement & AODV & No & Yes & No & No & \tabularnewline \hline

    WARP \citep{su2010warp} & 
    Hardware is enabling one-bit Message and immediate replies without CPU Involvement
    & AODV & No & Yes & Yes & No & \tabularnewline \hline

     Wormhole Intrusion Detection \citep{roy2010new}
     & No special requirement & DSR & No & Yes & No & No & \tabularnewline \hline

      Multi-path Hop-count Analysis \citep{jen2009hop}
      & No special requirement & AODV & No & Yes & YES & No & \tabularnewline \hline

    \citep{nait2008detecting}
    & No special requirement & OLSR & No & Yes & No & No & \tabularnewline[.5ex] \hline

    WORMERS\citep{vu2008wormeros}
    & No special requirement & - & No & Yes & No & No & \tabularnewline[.5ex] \hline

    WAP\citep{choi2008wap}
    & No special requirement & DSR & No & Yes & No & No & \tabularnewline[.5ex] \hline

    , MOBIWORP \citep{khalil2008mobiworp} & No special requirement & DSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline

    EDWA \citep{wang2007end} & Geographical devices & AODV & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline

      \citep{su2007mitigating}& 
      Authentic-\ ation by each hop during RREQ propagation and end-to-end
      & Ariadne & No &  Yes & No & No &
      \tabularnewline \hline

       DelPHI\par (Chiu and Lui, 2006)
       &  A novel scheme based on an intuitive method
       & AODV & No & No & Yes & No & \tabularnewline \hline

    LITE\ WORP \citep{khalil2007liteworp}
    ,  & No special requirement & DSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline

        HMTI \citep{gorlatova2006detecting} & None & OLSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline

        DeLPHI \citep{chiu2006delphi} & None & OLSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline

    SAM \citep{qian2005detecting}& None & DSR & No & Yes & Yes & No & \tabularnewline \hline

    Packet Leashes \citep{hu2003packet}& Need hardware and clock synchronisation & DSR & No & Yes & Yes & No & \tabularnewline \hline


    \end{longtable}
%    \end{table}
  \end{center}      



\end{landscape} 

\end{document}

答案1

取消注释\\之后\caption基本上可以解决问题。

在下面的代码中,我添加了一个缺失的natbib包,但没有引用,longtable通过使用转发器模式简化了格式行*{N}{format},并在重复标题上提供了缺失\hline。我还按照 Barbara Beeton 的建议设置了标题,并通过将两个命令合并为单个本地命令来\RaggedRight替换这些标题中已弃用\bf的。\bfseries\hd

图像是第二页的顶部。

示例输出

\documentclass{article} 

\usepackage[english]{babel} 
\usepackage{longtable} 
\usepackage{microtype} 
\usepackage{ragged2e} 
\usepackage{array} 
\usepackage{lscape} 
\usepackage{caption}
\usepackage{natbib}

\begin{document}

\begin{landscape}
\newpage

\begin{center}
  \small
  \newcommand{\hd}{\bfseries\RaggedRight}
  \begin{longtable}{|p{3cm}|p{2.2cm}|*{5}{p{1.8cm}|}p{.8cm}|}
     \caption{ \bf New Wormhole Detection Methods } \\ 
     \hline 
     \hd Protocol & \hd Requirement & \hd Routing Protocol & \hd Clock
     synchronization & \hd Remove wormhole & \hd Out of band Wormhole
     & \hd Extra Hardw-are & \hd QoS\\ 
     \hline \hline 
    \endfirsthead
    \hline 
    \multicolumn{8}{|r|}{{Continued on next page}} \\ \hline
    \endfoot
    \hline 
    \endlastfoot
    \hline
    \hd Protocol & \hd Requirement & \hd Routing Protocol & \hd Clock
    synchronization & \hd Remove wormhole & \hd Out of band Wormhole &
    \hd Extra Hardw-are & \hd QoS\\ 
    \hline \hline
    \endhead
    \hline
    Cluster Based \citep{banerjee2014wormhole}
    & No special requirement & DSR & No & Yes & No & No & no
    \tabularnewline \hline 
    Analytical Hierachy Process  \citep{shi2013countermeasure}
    & No special requirement & AODV & No & Yes & No & No & yes
    \tabularnewline \hline 
    Path Tracing \citep{sakthivel2012detection}
    & No special requirement & DSR & No & Yes & No & No &
    \tabularnewline \hline 
    Path Tracing \citep{anitha2012detection}
    & No special requirement & AODV & No & Yes & No & No &
    \tabularnewline \hline 
    RTT Estimation \citep{raju2012simple}
    & No special requirement & AODV & No & Yes & No & No &
    \tabularnewline \hline 
    WARP \citep{su2010warp} & 
    Hardware is enabling one-bit Message and immediate replies without
    CPU Involvement 
    & AODV & No & Yes & Yes & No & \tabularnewline \hline
    Wormhole Intrusion Detection \citep{roy2010new}
    & No special requirement & DSR & No & Yes & No & No & \tabularnewline \hline
    Multi-path Hop-count Analysis \citep{jen2009hop}
    & No special requirement & AODV & No & Yes & YES & No &
    \tabularnewline \hline 
    \citep{nait2008detecting}
    & No special requirement & OLSR & No & Yes & No & No &
    \tabularnewline[.5ex] \hline 
    WORMERS\citep{vu2008wormeros}
    & No special requirement & - & No & Yes & No & No &
    \tabularnewline[.5ex] \hline 
    WAP\citep{choi2008wap}
    & No special requirement & DSR & No & Yes & No & No &
    \tabularnewline[.5ex] \hline 
    , MOBIWORP \citep{khalil2008mobiworp} & No special requirement &
    DSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline 
    EDWA \citep{wang2007end} & Geographical devices & AODV & Yes & Yes
    & Yes & Yes & \tabularnewline[.5ex] \hline 
    \citep{su2007mitigating}& 
    Authentic-\ ation by each hop during RREQ propagation and end-to-end
    & Ariadne & No &  Yes & No & No &
    \tabularnewline \hline
    DelPHI\par (Chiu and Lui, 2006)
    &  A novel scheme based on an intuitive method
    & AODV & No & No & Yes & No & \tabularnewline \hline
    LITE\ WORP \citep{khalil2007liteworp}
    ,  & No special requirement & DSR & Yes & Yes & Yes & Yes & \tabularnewline[.5ex] \hline
    HMTI \citep{gorlatova2006detecting} & None & OLSR & Yes & Yes &
    Yes & Yes & \tabularnewline[.5ex] \hline 
    DeLPHI \citep{chiu2006delphi} & None & OLSR & Yes & Yes & Yes &
    Yes & \tabularnewline[.5ex] \hline 
    SAM \citep{qian2005detecting}& None & DSR & No & Yes & Yes & No &
    \tabularnewline \hline 
    Packet Leashes \citep{hu2003packet}& Need hardware and clock
    synchronisation & DSR & No & Yes & Yes & No & \tabularnewline
    \hline 
    \end{longtable}
  \end{center}      
\end{landscape} 

\end{document}

相关内容