![程序包数组错误:非法前缀标记(\caption):使用了‘c’](https://linux22.com/image/476054/%E7%A8%8B%E5%BA%8F%E5%8C%85%E6%95%B0%E7%BB%84%E9%94%99%E8%AF%AF%EF%BC%9A%E9%9D%9E%E6%B3%95%E5%89%8D%E7%BC%80%E6%A0%87%E8%AE%B0%EF%BC%88%5Ccaption%EF%BC%89%EF%BC%9A%E4%BD%BF%E7%94%A8%E4%BA%86%E2%80%98c%E2%80%99.png)
我遇到这个错误
Package array Error: Illegal pream-token (\caption): `c' used."
请帮我修复它。谢谢
\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage[letterpaper,top=2cm,bottom=2cm,
left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage{afterpage}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{array}
\usepackage{graphicx}
\usepackage{makecell}
\afterpage{
\begin{longtable}[h!]
\caption{Table 1: Features comparison}
\label{tab:my_label} \\
\begin{tabularx}{\textwidth}{|%
>{\centering\arraybackslash}X|>{\centering\arraybackslash}X|
>{\centering\arraybackslash}X|>{\centering\arraybackslash}X|
>{\centering\arraybackslash}X|>{\centering\arraybackslash}X|}
\hline
Authors & Topic & Scalability & Comparison & Theoretical Value & Application\\
\hline
\cite{alzahrani2018detection}Alzahrani et al. 2018 & DDoS attack & No & No & No & \\
\hline
\cite{biggio2011support}Biggio et al. 2011 & Adversarial attack & No & No & No & \\
\hline
\cite{biggio2012poisoning}Biggio et al. 2012 & Poisoning attacks & No & No & No & \\
\hline
\cite{chen2018detecting}Chen et al. 2018 & Activation clustering & No & No & No & \\
\hline
\cite{fredrikson2015model}Fredrikson et al. 2015 & Inversion attacks & No & No & No & \\
\hline
\cite{fredrikson2014privacy}Fredrikson et al. 2014 & Inversion attacks & No & No & No & \\
\hline
\cite{goodfellow2014explaining}Goodfellow, et al. 2014 & & & & & \\
\hline
\cite{gu2017badnets}Gu, et al. 2017 & & & & & \\
\hline
\cite{hu2021artificial}Hu, et al. 2021 & & & & & \\
\hline
\cite{jaszcz2022aimm}Jaszc, et al. 2022 & & & & & \\
\hline
\cite{alzahrani2018detection}Alzahrani et al. 2018 & DDoS attack & No & No & No & \\
\hline
\cite{biggio2011support}Biggio et al. 2011 & Adversarial attack & No & No & No & \\
\hline
\cite{biggio2012poisoning}Biggio et al. 2012 & Poisoning attacks & No & No & No & \\
\hline
\cite{chen2018detecting}Chen et al. 2018 & Activation clustering & No & No & No & \\
\hline
\cite{fredrikson2015model}Fredrikson et al. 2015 & Inversion attacks & No & No & No & \\
\hline
\cite{fredrikson2014privacy}Fredrikson et al. 2014 & Inversion attacks & No & No & No & \\
\hline
\cite{goodfellow2014explaining}Goodfellow, et al. 2014 & & & & & \\
\hline
\cite{gu2017badnets}Gu, et al. 2017 & & & & & \\
\hline
\cite{hu2021artificial}Hu, et al. 2021 & & & & & \\
\hline
\cite{jaszcz2022aimm}Jaszc, et al. 2022 & & & & & \\
\hline
\end{tabularx}
\end{longtable}
}
\afterpage{
\bibliographystyle{splncs04}
\bibliography{splncs04}
}
\end{document} %This is the error location
答案1
您不能将tabularx
环境嵌套在longtable
环境中。此外,由于longtable
不是浮点数(在 LaTeX 特定意义上),因此提供诸如 之类的定位说明符毫无意义[h!]
。
我假设你真正想要使用的是一个xltabular
环境(由板状的longtable
包),它将和的功能结合tabularx
在一起单一环境. 观察xltabular
,例如tabularx
,需要二参数:(i)目标宽度(此处:)\textwidth
和(ii)列规范组。
\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage[letterpaper,vmargin=2cm,hmargin=3cm,
marginparwidth=1.75cm]{geometry}
\usepackage{amsmath}
%\usepackage{longtable}
%\usepackage{tabularx}
%\usepackage{array}
\usepackage{xltabular}
\newcolumntype{C}{>{\centering\arraybackslash\hspace{0pt}}X} % centered
\newcolumntype{L}{>{\raggedright\arraybackslash\hspace{0pt}}X}% left-aligned
\usepackage{caption}
\begin{document}
\setlength\extrarowheight{2pt} % for a less-cramped "look"
\begin{xltabular}{\textwidth}{|L|C|c|c|C|C|}
% headers and footers
\caption{Comparison of features} \label{tab:my_label} \\
\hline
Authors & Topic & Scalability & Comparison & Theoretical Value & Application\\
\hline
\endfirsthead
\multicolumn{6}{l}{\tablename\ \thetable, continued} \\[1ex]
\hline
Authors & Topic & Scalability & Comparison & Theoretical Value & Application\\
\hline
\endhead
\hline
\multicolumn{6}{r}{\footnotesize (continued on next page)}\\
\endfoot
\endlastfoot
% body of table
\cite{alzahrani2018detection}Alzahrani et~al.\ 2018 & DDoS attack & No & No & No & \\
\hline
\cite{biggio2011support}Biggio et~al.\ 2011 & Adversarial attack & No & No & No & \\
\hline
\cite{biggio2012poisoning}Biggio et~al.\ 2012 & Poisoning attacks & No & No & No & \\
\hline
\cite{chen2018detecting}Chen et~al.\ 2018 & Activation clustering & No & No & No & \\
\hline
\cite{fredrikson2015model}Fredrikson et~al.\ 2015 & Inversion attacks & No & No & No & \\
\hline
\cite{fredrikson2014privacy}Fredrikson et~al.\ 2014 & Inversion attacks & No & No & No & \\
\hline
\cite{goodfellow2014explaining}Goodfellow et~al.\ 2014 & & & & & \\
\hline
\cite{gu2017badnets}Gu et~al.\ 2017 & & & & & \\
\hline
\cite{hu2021artificial}Hu et~al.\ 2021 & & & & & \\
\hline
\cite{jaszcz2022aimm}Jaszc et~al.\ 2022 & & & & & \\
\hline
\cite{alzahrani2018detection}Alzahrani et~al.\ 2018 & DDoS attack & No & No & No & \\
\hline
\cite{biggio2011support}Biggio et~al.\ 2011 & Adversarial attack & No & No & No & \\
\hline
\cite{biggio2012poisoning}Biggio et~al.\ 2012 & Poisoning attacks & No & No & No & \\
\hline
\cite{chen2018detecting}Chen et~al.\ 2018 & Activation clustering & No & No & No & \\
\hline
\cite{fredrikson2015model}Fredrikson et~al.\ 2015 & Inversion attacks & No & No & No & \\
\hline
\cite{fredrikson2014privacy}Fredrikson et~al.\ 2014 & Inversion attacks & No & No & No & \\
\hline
\cite{goodfellow2014explaining}Goodfellow et~al.\ 2014 & & & & & \\
\hline
\cite{gu2017badnets}Gu et~al.\ 2017 & & & & & \\
\hline
\cite{hu2021artificial}Hu et~al.\ 2021 & & & & & \\
\hline
\cite{jaszcz2022aimm}Jaszc et~al.\ 2022 & & & & & \\
\hline
\end{xltabular}
\end{document}