In https://tex.stackexchange.com/a/512752/13492, it was shown how to produce both a short and a detailed table of contents (TOC) in a memoir document. And so that each of the two TOCs is listed as an entry in the other TOC but not in itself. (This method preserves any pagestyle the author uses.)
However, as soon as I load biblatex in such a document, on the 2nd pdflatex pass, it generates an error in creating the TOC.
The error:
(./test.toc
./test.toc:9: LaTeX Error: Something's wrong--perhaps a missing \item.
...
l.9 ...hapter}{Detailed Contents}{iii}{section*.2}
%
The toc file:
\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}%
The source:
\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}
Note that I deliberately commented out the \bibresource line, the fileconents block that creates the .bib file, and the \backmatter...\printbibliography -- because even if they are uncommented, exactly the same error occurs.
There is no TOC error if the \usepackage[...]{biblatex} is omitted! So there is some very strange (to me) interaction between biblatex and the two-TOCs code.
Here is the .toc file with everything the same except that the biblatex loading line is commented out (and everything works OK):
\@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}%
Package versions:
There are currently the lastest at CTAN.
memoir2018/12/12 v3.7hbiblatex2019/08/31 3.13ahyperref2019/09/28 v7.00a
\newcommand\MurderShort[9]{}and\newcommand\MurderLong[9]{}but then inside the definitions of\newcommand\shorttableofconentsand\newcommand\longtableofcontentsto leave\renewcommand\MurderShort[5]{}and\renewcommand\MurderLong[5]{}? I tried that, and same error. If not that, what did you mean? In any case, why does the error occur only whenbiblatexis also loaded? – murray Oct 24 '19 at 00:49\defcounter {refsection}{0}\relax, compare the toc with and without biblatex (you probably have to delete the toc in between). So,\renewcommand\MurderShort[5]{}could be changed to \renewcommand\MurderShort[9]{#1#2#3#4}` etc, this eats nine tokes and reinsert the first four (untested, I'm currently on a tablet), – daleif Oct 24 '19 at 06:25refsectioncounter is only useful if there is an actual ToC entry,\renewcommand\MurderShort[9]{}would also work. (I tested with\renewcommand\MurderShort[9]{}and it worked.)\renewcommand\MurderShort[9]{##1##2##3##4}doesn't quite work because the macro expansion eats the group, so it would need to be\renewcommand\MurderShort[9]{##1{##2}{##3}##4}. Do you want to write up a short answer? – moewe Oct 24 '19 at 06:28