Dear TeX(stackexchange) community, I'm trying to create automatically my own TOCs: using \keyword
command I define the entries of my own toc list so that each belonging to same chapter will be printed at beginning of chapter using \listofkeywords
.
There is a problem for first chapter: no .key1 file created and no toc printed. That's my MWE:
\documentclass[oneside,11pt,fleqn]{memoir}
\usepackage{titletoc}
\setcounter{tocdepth}{0}
\usepackage[compact,toctitles]{titlesec}
\titleformat{\chapter}[block]
{\huge}{\chaptertitlename\ \thechapter:\ }{0pt}{\huge}[\addtocounter{cherrychapter}{1}]
\title{H\&R}
%%% COUNTERS
\newcounter{cherrychapter}%[chapte]
\setcounter{cherrychapter}{0}
\newcommand\keyword[1]{%
\noindent%
{#1}%
\phantomsection% comment out if hyperref is noy used
\thecherrychapter\thechapter\addcontentsline{key-\thecherrychapter}{figure}{#1}
}
\makeatletter
\newcommand\listkeywordsname{KEYWORDS}
\newcommand\listofkeywords{%
\thecherrychapter\thechapter
\section*{\listkeywordsname}\@starttoc{key-\thecherrychapter}
\thecherrychapter\thechapter}
\makeatother
\begin{document}%BEGIN
\maketitle
\tableofcontents*
\part{A}
\chapter{aa}
\listofkeywords
\keyword{bb}
\section{aaa}
\keyword{bbb}
\subsection{aaaa}
\keyword{bbbb}
\chapter{cc}
\listofkeywords
\keyword{dd}
\section{ccc}
\keyword{ddd}
\subsection{cccc}
\keyword{dddd}
\end{document}
Thank you for aid. Best regards.
\addcontentsline
? Are you willing to write your keywords to a file and read that back in?memoir
redefines the internal\@starttoc
. I think a more robust solution will be provided by the packageglossaries
tex.stackexchange.com/questions/89107/…titletoc
andmemoir
's emulation oftocloft
etc. features is also doubtful