我对以下代码的编译存在严重问题:
\documentclass[a4paper,reprint,aps,unsortedaddress]{revtex4}
\usepackage{longtable}
\usepackage{caption}
\begin{document}
\captionof{table}{This is a very nice table}
\begin{longtable}{c|c|c|c}
A & B & A & B \\ \hline
\end{longtable}
\addtocounter{table}{-1}
\captionof{table}{This is a very nice table}
\begin{longtable}{c|c|c|c}
A & B & A & B \\ \hline
\end{longtable}
\end{document}
错误信息是
! LaTeX Error: Command \longtable* already defined. Or name \end... illegal, see p.192 of the manual. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help.
您能帮我解决这个错误吗?
答案1
嗯,您的代码有三个问题:
- 类别
revtex4
已过时,当前类别为revtex4-2
。可以更改吗? - 加载包
caption
会导致类revtex4
和类的多个错误/警告revtex4-2
。不要加载它! \captionof{table}{This is a very nice table}
caption
仅在加载包时才有可能,但longtable
定义其自己的标题\caption{This is a very nice table}\\
(请参阅结尾\\
!)
使用以下代码
\documentclass[a4paper,reprint,aps,unsortedaddress]{revtex4}
\usepackage{longtable}
%\usepackage{caption}
\begin{document}
\begin{longtable}{c|c|c|c}
\caption{This is a very nice table}\\
A & B & A & B \\ \hline
\end{longtable}
\addtocounter{table}{-1}
\begin{longtable}{c|c|c|c}
\caption{This is a very nice table}\\
A & B & A & B \\ \hline
\end{longtable}
\end{document}
我可以使用类进行无错误编译revtex4
,revtex4-2
结果如下: