2

I'm trying to get the combine class to work together with etoc. Particularly I have an article/chapter which has its own local toc. See the following chapter1.tex:

\documentclass{memoir}
\usepackage{etoc}
\etocsettocdepth{paragraph}
\begin{document}

\etocsettocdepth.toc{paragraph}
\chapter{A chapter}
\etocsettocstyle{\section*{\contentsname}}{}
\localtableofcontents*
\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

By itself this file compiles fine, except of

Package etoc Warning: You may consider using \etocsettocdepth.toc as a drop-in replacement to the memoir own \settocdepth if you wish to exploit etoc to its fullest. Similarly consider using \etocsettocdepth and \etocsetnexttocdepth rather than memoir's \maxtocdepth. on input line 4.

If then I try to get this loaded into the following main file of combine class both the main and the local tocs break:

\documentclass[memoir]{combine}
\usepackage{etoc}

\begin{document}

\tableofcontents

\begin{papers}

\coltoctitle{Article number 1}
\coltocauthor{Author number 1}
\label{art1}
\import{chapter1}

\end{papers}
\end{document}
4
  • Instead of combine have you considered docmute, it will just ignore the preamble of included (\input or \include), I tend to use that instead of combine. Though I've never used etoc
    – daleif
    Commented Aug 17, 2015 at 14:13
  • @daleif, no I had not looked into it so far. A first attempt now looks promising, I've solved above problem with ease. Let me see how it works with my real files. I'm not sure though if I can harmonise my different documents' preambles, which would be required.
    – muk.li
    Commented Aug 17, 2015 at 14:27
  • I use it for conference abstracts. The participants get a general template and the instruction that they are not allowed to add anything to the preamble. It works fine.
    – daleif
    Commented Aug 17, 2015 at 14:42
  • The warning issued by etoc under class memoir will be a simple informative message, which will cause less alarm, starting with version 1.08g.
    – user4686
    Commented Aug 29, 2015 at 20:29

1 Answer 1

3

Independently of etoc there seems to be currently (up-to-date TL2015) an incompatibility of combine vs memoir.

Bottom of answer addresses etoc+book+combine compatibility ; I have made no attempt for etoc+memoir+combine because I observe already problems with memoir+combine, which I describe first.

Test of book with combine: ok

No problems with the following files using combine and the book class:

File testcombine-book.tex

\documentclass[book]{combine}

\begin{document}

\tableofcontents

\begin{papers}

\coltoctitle{Article number 1}
\coltocauthor{Author number 1}

\label{art1}
\import{testcombine-book-chap1}

\coltoctitle{Article number 2}
\coltocauthor{Author number 2}

\label{art2}
\import{testcombine-book-chap2}

\end{papers}
\end{document}

File testcombine-book-chap1.tex:

\documentclass{book}

\begin{document}

\tableofcontents

\chapter{A chapter (FIRST PAPER)}

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

File testcombine-book-chap2.tex:

\documentclass{book}

\begin{document}

\tableofcontents

\chapter{A chapter (SECOND PAPER)}

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

Compilation proceeds with no errors and gives expected result.

Test of memoir with combine: problem

On the other hand the very similar files using memoir class create a problem:

% file testcombine-memoir.tex
\documentclass[memoir]{combine}
% there is a problem with memoir+combine independently of etoc
% tested 2015-08-30, up-to-date TeXLive 2015

\begin{document}

\tableofcontents

\begin{papers}

\coltoctitle{Article number 1}
\coltocauthor{Author number 1}

\label{art1}
\import{testcombine-memoir-chap1}

\coltoctitle{Article number 2}
\coltocauthor{Author number 2}

\label{art2}
\import{testcombine-memoir-chap2}

\end{papers}
\end{document}

% file testcombine-memoir-chap1.tex
\documentclass{memoir}

\begin{document}

\tableofcontents*

\chapter{A chapter (FIRST PAPER)}

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

% file testcombine-memoir-chap2.tex
\documentclass{memoir}

\begin{document}

\tableofcontents*

\chapter{A chapter (SECOND PAPER)}

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

Compilation of these files end up in this error:

% gives 
% ERROR: LaTeX Error: Command \sf@@memsub@label already defined.

% --- TeX said ---
%                Or name \end... illegal, see p.192 of the manual.

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

% l.9 \begin{document}
% referring to testcombine-memoir-chap1

and a similar one when importing the second paper.

etoc vs combine compatibility problems

This being said, etoc is currently incompatible with the combine class: I can add use of etoc to the book class files above:

\usepackage{etoc}
% inside main file, also add this :
% make coltoctitle and coltocauthor level known to etoc
\etocsetlevel{coltoctitle}{1}
\etocsetlevel{coltocauthor}{2}

and compilation proceeds then with no error, but the mechanism for local tables of contents is broken.

etoc records some ids in the .toc files for local TOCs. I see this information correctly appearing in the .aux files of the imported papers, which get updated on each compilation of the main file. But this information does not make its way to the .toc files of the imported papers, those are not re-generated, and the ones which are created on compiling individually each sub-paper contain naturally a wrong id for the local TOCs.

If the sub .toc files were regenerated as the .aux files are, local table of contents of etoc could become functional.

Solving this, if at all possible, needs some effort analyzing the combine class code and its interaction with etoc: the .toc files are correctly regenerated in the absence of etoc.

However the code dealing with file opening and closing by etoc is not entirely easily patchable, as some piece is not wrapped-up in a macro but added to the add begin document hook literally. Thus solving this issue will presumably also require a new version of etoc.

update: reinstauring compatibility etoc vs combine (book class)

Here are steps to be taken in the main master file to achieve (at least in a simple case) compatibility of etoc vs combine.

A command \PatchEtocOpenOut is defined which must be issued before each use of the \import command from the combine class.

File testcombine-etoc-book.tex:

\documentclass[book]{combine}

\usepackage{etoc}
% make coltoctitle and coltocauthor level known to etoc
\etocsetlevel{coltoctitle}{1}
\etocsetlevel{coltocauthor}{2}

% class combine modifies the output streams names
% Inner macro of package etoc must be patched
% (etoc versions 1.08g and earlier)
\makeatletter
\newcommand*\PatchEtocOpenOut {%
% \PatchEtocOpenOut must be issued before
% each use of \import command (after main TOC)
  \Etoc@toctoks {}%
  \def\Etoc@openouttoc
  {%
      \if@filesw
         \immediate \openout \c@ltocfnum \jobname .toc\relax
      \fi
      \global\let\Etoc@openouttoc\empty 
  }%
}
\makeatother

\begin{document}

\tableofcontents

\begin{papers}

\coltoctitle{Article number 1}
\coltocauthor{Author number 1}
\label{art1}
\PatchEtocOpenOut % must be issued before each \import
\import{testcombine-etoc-book-chap1}

\coltoctitle{Article number 2}
\coltocauthor{Author number 2}
\label{art2}
\PatchEtocOpenOut % must be issued before each \import
\import{testcombine-etoc-book-chap2}

\end{papers}
\end{document}

File testcombine-etoc-book-chap1.tex:

\documentclass{book}
\usepackage{etoc}
\etocsettocdepth{paragraph}
\etocarticlestyle

\begin{document}

\chapter{A chapter (FIRST PAPER)}

\localtableofcontents

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}
\end{document}

File testcombine-etoc-book-chap2.tex: (this second chapter has a main toc and two local tocs; all three are produced as expected via compilation of the master file above with the combine class.)

\documentclass{book}
\usepackage{etoc}
\etocsettocdepth{paragraph}

\begin{document}

\etocsettocstyle
  {\section*{\contentsname{} of second paper}}
  {\vspace{.5cm}\hrule}

\tableofcontents

\etocsettocstyle{\subsection*{\contentsname{} for this chapter}}{}

\chapter{First chapter (SECOND PAPER)}
\localtableofcontents

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}

\chapter{Second chapter (SECOND PAPER)}
\localtableofcontents

\section{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\paragraph{A paragraph}

\end{document}

Compilation of testcombine-etoc-book.tex proceeds with no error and produces expected output with correct import of the two sub-files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .