이 매우 간단한 MWE에서 왜 이 오류가 발생합니까?

이 매우 간단한 MWE에서 왜 이 오류가 발생합니까?

이 매우 간단한 MWE에서 왜 이 오류가 발생합니까? 두 클래스 에도 같은 오류가 나타나는 것 같습니다 book.

\documentclass[notoc]{tufte-book}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\begin{document}

\tableofcontents
\chapter{Introduction}

\startcontents[chapters]
\printcontents[chapters]{}{1}{}

\section{Historical Overview}
\section{The CUDA Model}
\section{A Lattice Boltzmann Solver}

\addtocontents{toc}{text}

\chapter{chap3}
\section{My Overview}
\end{document}

답변1

장 줄 앞에 단락 나누기를 삽입해야 합니다. \par를 직접 사용할 수 없으므로 \endgraf를 사용하세요.

\documentclass[notoc]{tufte-book}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\begin{document}

\tableofcontents
\chapter{Introduction}

\startcontents[chapters]
\printcontents[chapters]{}{1}{}

\section{Historical Overview}
\section{The CUDA Model}
\section{A Lattice Boltzmann Solver}

\addtocontents{toc}{text\endgraf}

\chapter{chap3}
\section{My Overview}
\end{document}

답변2

.toc이는 다음을 통해 파일 내부에 임의의 텍스트가 도입되었기 때문에 발생합니다.

\addtocontents{toc}{text}

그렇게 하려면 \par나중에 a를 실행하여 텍스트가 자체적으로 존재하는지 확인하십시오.

다음 최소 예는 문제를 재현합니다.

\documentclass{article}

\begin{document}

\tableofcontents

\section{A section}

\addcontents{toc}{text}% Error
%\addtocontents{toc}{text\par}% No error

\section{Another section}

\end{document}

관련 정보