memoir + biblatex + 2 TOCs 错误

memoir + biblatex + 2 TOCs 错误

https://tex.stackexchange.com/a/512752/13492展示了如何在memoir。这样两个目录中的每一个都在另一个目录中列出为条目,但不是本身。(此方法保留了pagestyle作者使用的任何内容。)

然而,当我加载biblatex这样的文档时,在第二次 pdflatex 传递时,它会在创建目录中产生错误。

错误:

(./test.toc

./test.toc:9: LaTeX Error: Something's wrong--perhaps a missing \item.
 ...                                                                                                
l.9 ...hapter}{Detailed Contents}{iii}{section*.2}
                                                  %

文件toc

\boolfalse {citerequest}\boolfalse {citetracker}\boolfalse {pagetracker}\boolfalse {backtracker}\relax 
\defcounter {refsection}{0}\relax 
\@nameuse {MurderShort}
\defcounter {refsection}{0}\relax 
\contentsline {chapter}{Short Contents}{i}{section*.1}% 
\defcounter {refsection}{0}\relax 
\@nameuse {MurderLong}
\defcounter {refsection}{0}\relax 
\contentsline {chapter}{Detailed Contents}{iii}{section*.2}% 
\defcounter {refsection}{0}\relax 
\contentsline {chapter}{\chapternumberline {1}Chap}{1}{chapter.1}% 
\defcounter {refsection}{0}\relax 
\contentsline {section}{\numberline {1.1}Test}{1}{section.1.1}% 
\defcounter {refsection}{0}\relax 
\contentsline {subsection}{\numberline {1.1.1}Test}{1}{subsection.1.1.1}% 

来源:

\documentclass{memoir}

%% Same error created even if no bibresource
%\begin{filecontents}{mybib.bib}
%@article{wombat,
%   author   = {Walther Wombat},
%   title    = {The meaning of 42},
%   journal  = {Journal of skepticism},
%   date     = {2016},
%}
%\end{filecontents}

%%% SECTIONING:
\setsecnumdepth{subsection}

%% BIB:
% ERROR WITH biblatex used!
\usepackage[backend=bibtex,style=numeric]{biblatex}
%\addbibresource{mybib.bib}

%% CROSS-REF:
\usepackage[pdftex]{hyperref}
\hypersetup{colorlinks, citecolor=red}

% Short and detailed TOCs:
% daleif (https://tex.stackexchange.com/a/512752/13492)
\makeatletter
\newcommand\MurderShort{}
\newcommand\MurderLong{}
\newcommand{\longcontentsname}{Detailed Contents}
\newcommand{\shortcontentsname}{Short Contents}
\newcommand{\shorttableofcontents}[1][1]{%
  \begingroup
  \setcounter{tocdepth}{#1}
  \let\contentsname\shortcontentsname
  \addtocontents{toc}{\protect\@nameuse{MurderShort}}
  % only works with hyperref
  \renewcommand\MurderShort[5]{}
  \tableofcontents
  \endgroup
}
\newcommand{\longtableofcontents}[1][3]{%
  \begingroup
  \setcounter{tocdepth}{#1}
  \let\contentsname\longcontentsname
    \addtocontents{toc}{\protect\@nameuse{MurderLong}}
  % only works with hyperref
  \renewcommand\MurderLong[5]{}
  \tableofcontents
  \endgroup
}
\makeatother

%% FOR THIS TEST:
\usepackage{kantlipsum}

\begin{document}

\frontmatter
\shorttableofcontents[1]
\cleardoublepage
\longtableofcontents

\mainmatter
\chapter{Chap}\kant[1]
\section{Test}\kant[1]
\subsection{Test}\kant[1]

%\backmatter
%\printbibliography

\end{document}

请注意,我故意注释掉了该\bibresource行、fileconents创建.bib文件的块以及\backmatter...——\printbibliography因为即使取消注释它们,也会发生完全相同的错误。

如果 \usepackage[...]{biblatex} 被省略了!biblatex因此,对我来说,这两个 TOC 代码之间存在一些非常奇怪的相互作用。

这里是.toc所有内容相同的文件除了加载biblatex行已被注释掉(并且一切正常):

\@nameuse {MurderShort}
\contentsline {chapter}{Short Contents}{i}{section*.1}% 
\@nameuse {MurderLong}
\contentsline {chapter}{Detailed Contents}{iii}{section*.2}% 
\contentsline {chapter}{\chapternumberline {1}Chap}{1}{chapter.1}% 
\contentsline {section}{\numberline {1.1}Test}{1}{section.1.1}% 
\contentsline {subsection}{\numberline {1.1.1}Test}{1}{subsection.1.1.1}% 

软件包版本:

目前,CTAN 上有最新版本。

  • memoir2018/12/12 v3.7h
  • biblatex2019/08/31 3.13a
  • hyperref2019/09/28 v7.00a

答案1

您发布的目录解释了发生了什么(感谢您发布它们)。

biblatex似乎\defcounter {refsection}{0}\relax到处都插入了。不知道为什么。大概是biblatex修补了 toc 编写宏以包含这些行。所以现在我们有

\@nameuse {MurderShort}
\defcounter {refsection}{0}\relax 
\contentsline {chapter}{Short Contents}{i}{section*.1}% 

而不是

\@nameuse {MurderShort}
\contentsline {chapter}{Short Contents}{i}{section*.1}% 

凶手就是为此而设计的。

幸运的是,只需要多 4 个代币

所以你应该能够改变

  \renewcommand\MurderShort[5]{}

要么

\renewcommand\MurderShort[9]{}

或者这条线实际上用于什么

\renewcommand\MurderShort[9]{##1{##2}{##3}##4}

或者我们必须修补biblatex的补丁,但这似乎很烦人。

相关内容