我无法使用以下代码将 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