我在編譯以下程式碼時遇到嚴重問題:
\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
會導致 classrevtex4
和 class出現多個錯誤/警告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
結果: