无法使用 minitoc 中的 ToC 名称引用

无法使用 minitoc 中的 ToC 名称引用

我正在尝试minitoc通过更改标题来定制生成的目录,以便不让我的书周围有太多的“目录”页面。

但是,当我尝试使用\mtcsettitle引用时,会出现最奇怪的错误;特别是,我试图实现这样的目标:

\mtcsettitle{parttoc}{\ref{somepartref} -- \nameref{somepartref}}

这里出现了一个 MWE,尽管出现了错误,但至少\ref命令被正确接受了:

% !TEX program = lualatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en_GB
\documentclass[a4paper, 11pt, titlepage, oneside]{book}

\usepackage[british]{babel}
\usepackage{minitoc}

\begin{document}
  \selectlanguage{british}

  \frontmatter

  \mtcaddchapter[\contentsname]
  \dominitoc
  \doparttoc
  \mtcsetdepth{parttoc}{0}
  \noptcrule
  \tableofcontents
  \clearpage

  \mtcaddchapter[\listfigurename]
  \listoffigures
  \clearpage

  \mainmatter
  \part{First part}
  \label{part:first}
  \mtcsettitle{parttoc}{\ref{part:first} -- \nameref{part:first}}
  \parttoc
  \chapter{Introduction}
  \minitoc
  \mtcskip

  This is some sort of joke introduction, for demo purposes only.
  \begin{figure}[h!]
    \centering
    \caption{This is a fake image}
    \label{fig:fakeimage}
  \end{figure}

  \chapter{Conclusion}
  \minitoc
  \mtcskip
  Is this the real life? Or is this fantasy?

  \section{Look, I'm a section too!}
  \ldots

\end{document}

错误如下:

...
! Undefined control sequence.
\ptctitle ->\ref {part:first} -- \nameref 
                                          {part:first}
l.31   \chapter
             {Introduction}
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.

! Undefined control sequence.
\ptctitle ->\ref {part:first} -- \nameref 
                                          {part:first}
l.31   \chapter
             {Introduction}
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.


\openout3 = fake.mtc
! Incomplete \iffalse; all text was ignored after line 31.
<inserted text> 
\fi 
l.31   \chapter
             {Introduction}
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

! Incomplete \iffalse; all text was ignored after line 31.
<inserted text> 
\fi 
l.31   \chapter
             {Introduction}
A forbidden control sequence occurred in skipped text.
This kind of error happens when you say `\if...' and forget
the matching `\fi'. I've inserted a `\fi'; this might work.

Runaway text?
\protect \let 
! Forbidden control sequence found while scanning text of \write.
<inserted text> 
}
l.31   \chapter
             {Introduction}
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Text line contains an invalid character.
<read 1> \protect \let  
                  
l.31   \chapter
             {Introduction}
A funny symbol that I can't read has just been input.
Continue, and I'll forget that it ever happened.


\openout3 = fake.mtc
! Undefined control sequence.
\ptctitle ->\ref {part:first} -- \nameref 
                                          {part:first}
l.31   \chapter
             {Introduction}
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.
...

所以,我不确定我是否实际上不能在\mtcsettitle命令中使用引用,或者我是否缺少一些更大的图景。

相关内容