Minitoc 未自行更新

Minitoc 未自行更新

以下 MWE 使用 minitoc。

\documentclass[a4paper]{book}
\usepackage{lipsum}
\usepackage{hyperref}

\usepackage{minitoc}
\dominitoc

\begin{document}
\include{TOC}
\include{chap1}
\include{chap2}
\end{document}

目录.tex:

\tableofcontents

第 1 章.tex:

\chapter{One}
\minitoc

\section{One One}
\lipsum[1-10]

\section{One Two}
\lipsum[20-30]

第2章.tex:

\chapter{Two}
\section{Two One}
\section{Two Two}
\minitoc

\lipsum[2]

它按预期正常工作,并创建了 mini tocs。但是,当使用 \includeonly{chap1} 作为示例时,问题就开始了。当文件中添加其他部分时,chap1.tex 的 minitoc 不会自行更新。此外,当我从终端运行以下命令时:

pdflatex -jobname=thechap01 "\includeonly{chap1}\input{tmp}"

我收到以下错误。

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
 restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, et
hiopic, farsi, arabic, pinyin, croatian, bulgarian, ukrainian, russian, slovak,
 czech, danish, dutch, usenglishmax, ukenglish, finnish, french, basque, ngerma
n, german, swissgerman, ngerman-x-2012-05-30, german-x-2012-05-30, monogreek, g
reek, ibycus, ancientgreek, hungarian, bengali, tamil, hindi, telugu, gujarati,
 sanskrit, malayalam, kannada, assamese, marathi, oriya, panjabi, italian, lati
n, latvian, lithuanian, mongolian, mongolianlmc, nynorsk, bokmal, indonesian, e
speranto, coptic, welsh, irish, interlingua, serbian, serbianc, slovenian, friu
lan, romansh, estonian, romanian, armenian, uppersorbian, turkish, afrikaans, i
celandic, kurmanji, polish, portuguese, galician, catalan, spanish, swedish, th
ai, loaded.
(./tmp.tex (/usr/share/texlive/texmf-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/lipsum/lipsum.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(/usr/share/texlive/texmf-dist/tex/latex/minitoc/minitoc.sty
(/usr/share/texlive/texmf-dist/tex/latex/minitoc/mtcmess.sty) (./thechap01.mtc0
) (/usr/share/texlive/texmf-dist/tex/latex/minitoc/english.mld)
(/usr/share/texlive/texmf-dist/tex/latex/minitoc/english.mld)) (./thechap01.aux
 (./TOC.aux) (./chap1.aux) (./chap2.aux))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./thechap01.out) (./thechap01.out)

Package minitoc(hints) Warning: W0030
(minitoc(hints))                --- The \part command is altered 
(minitoc(hints))                after minitoc.


Package minitoc(hints) Warning: W0023
(minitoc(hints))                --- It may be the consequence 
(minitoc(hints))                of loading the ``hyperref'' package.


Package minitoc(hints) Warning: W0028
(minitoc(hints))                --- The \chapter command is altered 
(minitoc(hints))                after minitoc.


Package minitoc(hints) Warning: W0023
(minitoc(hints))                --- It may be the consequence 
(minitoc(hints))                of loading the ``hyperref'' package.


! LaTeX Error: No counter 'Hy@AnnotLevel' defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.12 \include{TOC}

? x
No pages of output.
Transcript written on thechap01.log.

任何帮助都将受到赞赏。

答案1

在您当前设置中,\tableofcontents调用时不会调用该命令,\includeonly{chap1}因为您已将其隐藏TOC.tex

如果你稍微简化你的文档

...
\begin{document}
\tableofcontents
\include{chap1}
\include{chap2}
\end{document}

然后\tableofcontents每次都会调用该命令,并且您的.toc和小toc文件将根据您的意愿进行更新。

相关内容