我無法使用以下程式碼將 PDF 文件插入到 LaTeX 文件中。當我運行以下程式碼時,我在日誌檔案中收到以下錯誤訊息:
"! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next
{\calc@error #1}\fi \fi \f...
l.20 \addtocontents{toc}{\setcounter{tocdepth}{0}}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined."
如何將 PDF 文件插入文件中?
\documentclass[12pt,oneside]{book}
\usepackage{hyperref}
\usepackage{titletoc}
\usepackage[toc]{appendix}
\usepackage{pdfpages}
\renewcommand{\appendixtocname}{APPENDICES}
\begin{document}
\includepdf[pages=-]{myfile.pdf}
\tableofcontents
\chapter{CHAPTERR}
\section{Sectionn}
Some stuff.
\chapter{CHAPTERRR}
\section{Sectionnn}
Other stuff.
\begin{appendices}
\addtocontents{toc}{\setcounter{tocdepth}{0}}
\chapter{TABLESS}
\section{DATA}
\chapter{FIGURESS}
\section{CODE}
\end{appendices}
\end{document}
我想要以下輸出:
答案1
這與包無關pdfpages
,但它加載了calc
,這就是問題,可能calc
會導致\setcounter
不健壯或其他什麼...
如果您想更改該位置的計數器,只需使用
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
防止\setcounter
過早擴張。很多巨集使用時需要保護\addtocontents