패키지 "caption" 및 documentclass "revtex4"를 사용하여 "longtable*이 이미 정의되었습니다" 오류를 해결하는 방법은 무엇입니까?

패키지 "caption" 및 documentclass "revtex4"를 사용하여 "longtable*이 이미 정의되었습니다" 오류를 해결하는 방법은 무엇입니까?

다음 코드를 컴파일하는 데 심각한 문제가 있습니다.

\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

음, 귀하의 코드에는 세 가지 문제가 있습니다.

  1. 클래스가 revtex4오래되었습니다. 현재 클래스는 입니다 revtex4-2. 바꿀 수 있나요?
  2. 패키지를 로드하면 class 및 class 에 대해 caption여러 가지 오류/경고가 발생합니다 . 그냥로드하지 마십시오!revtex4revtex4-2
  3. \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}

클래스 revtex4revtex4-2 결과를 오류 없이 컴파일할 수 있습니다.

결과 테이블

관련 정보