如何将现有表转换为 longtable 中的相同格式?

如何将现有表转换为 longtable 中的相同格式?

longtable需要扩展到 3 页。我查看了许多过去的答案,longtable但尝试过但没有成功。我需要在这里发帖征求建议。以下是我现有的 Latex 代码:

\begin{table*}[!htbp]
    \centering
    \tiny
    \renewcommand{\arraystretch}{1.3}
    \caption{State-of-the-art based on the taxonomy.}
    %\label{table}
    \begin{tabular}{l|p{7.5cm}|p{1.5cm}|p{2.5cm}|p{1.5cm}}
        %\hline 
        Item& Sota & DummyA & DummyB & DummyC\\
        \hline 
        \hline 
        A & ASota & AA & AB&AC\\
        \hline 
        B & BSota& BA & BB & BC\\
        \hline
        C & CSota& CA& CB &CC\\
        \hline
        D & DSota& DA& DB &DC \\
        \hline  
        E & ESota& EA& EB &EC \\
        \hline 
        F & FSota& FA& FB &FC \\
        \hline
        G & GSota& GA& GB &GC \\
        \hline
        H & HSota& HA& HB &HC \\
        \hline
        I & ISota& IA& IB &IC \\
        \hline
        J & JSota& JA& JB &JC \\
        \hline
        K & KSota& KA& KB &KC \\
        \hline
        L & LSota& LA& LB &LC \\
        \hline
        M & MSota& MA& MB &MC \\
        \hline
    \end{tabular}
\end{table*}

提前致谢。

答案1

table从一tabular对环境转换为一个(单一)环境时,请务必通过、、和指令longtable定义表的页眉和页脚。\endfirsthead\endhead\endfoot\endlastfoot

如果您需要更改字体大小longtable(例如,更改为\tiny),请将整个longtable环境包含在一对\begingroupand\endgroup语句中。这将保持本地的范围\tiny

在此处输入图片描述

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably
\usepackage{longtable,array}
\usepackage{caption}
\begin{document}

\begingroup 
%\tiny %% is this really necessary?
%\renewcommand{\arraystretch}{1.3}
\setlength\extrarowheight{3pt}
\captionsetup{font=normalsize,skip=0.333\baselineskip}

\begin{longtable}{@{}l|p{7.5cm}|p{1.5cm}|p{2.5cm}|p{1.5cm}@{}}
%% headers and footers

\caption{State-of-the-art based on the taxonomy.}
\label{table}\\
Item & Sota & DummyA & DummyB & DummyC \\
\hline \hline 
\endfirsthead

\multicolumn{5}{@{}l}{\em Table \ref{table}, continued}\\[1ex]
Item& Sota & DummyA & DummyB & DummyC\\
\hline\hline
\endhead

\multicolumn{5}{r@{}}{\em (Continued on following page)}\\
\endfoot

\hline
\endlastfoot

%% body of longtable env.
        A & ASota& AA& AB &AC \\
        \hline 
        B & BSota& BA& BB &BC \\
        \hline
        C & CSota& CA& CB &CC \\
        \hline
        D & DSota& DA& DB &DC \\
        \hline  
        E & ESota& EA& EB &EC \\
        \hline 
        F & FSota& FA& FB &FC \\
        \hline
        G & GSota& GA& GB &GC \\
        \hline
        H & HSota& HA& HB &HC \\
        \hline
        I & ISota& IA& IB &IC \\
        \hline
        J & JSota& JA& JB &JC \\
        \hline
        K & KSota& KA& KB &KC \\
        \hline
        L & LSota& LA& LB &LC \\
        \hline
        M & MSota& MA& MB &MC \\
        \hline
        A & ASota& AA& AB &AC \\
        \hline 
        B & BSota& BA& BB &BC \\
        \hline
        C & CSota& CA& CB &CC \\
        \hline
        D & DSota& DA& DB &DC \\
        \hline  
        E & ESota& EA& EB &EC \\
        \hline 
        F & FSota& FA& FB &FC \\
        \hline
        G & GSota& GA& GB &GC \\
        \hline
        H & HSota& HA& HB &HC \\
        \hline
        I & ISota& IA& IB &IC \\
        \hline
        J & JSota& JA& JB &JC \\
        \hline
        K & KSota& KA& KB &KC \\
        \hline
        L & LSota& LA& LB &LC \\
        \hline
        M & MSota& MA& MB &MC \\
        \hline
        A & ASota& AA &AB &AC \\
        \hline 
        B & BSota& BA &BB &BC \\
        \hline
        C & CSota& CA& CB &CC \\
        \hline
        D & DSota& DA& DB &DC \\
        \hline  
        E & ESota& EA& EB &EC \\
        \hline 
        F & FSota& FA& FB &FC \\
        \hline
        G & GSota& GA& GB &GC \\
        \hline
        H & HSota& HA& HB &HC \\
        \hline
        I & ISota& IA& IB &IC \\
        \hline
        J & JSota& JA& JB &JC \\
        \hline
        K & KSota& KA& KB &KC \\
        \hline
        L & LSota& LA& LB &LC \\
        \hline
        M & MSota& MA& MB &MC \\
        \hline 
        F & FSota& FA& FB &FC \\
        \hline
        G & GSota& GA& GB &GC \\
        \hline
        H & HSota& HA& HB &HC \\
        \hline
        I & ISota& IA& IB &IC \\
        \hline
        J & JSota& JA& JB &JC \\
        \hline
        K & KSota& KA& KB &KC \\
        \hline
        L & LSota& LA& LB &LC \\
        \hline
        M & MSota& MA& MB &MC \\

\end{longtable}
\endgroup

\end{document}

相关内容