I have adapted the pretty table of contents solution written by Gonzalo Medina with the modification to the "blue box style" that Stephan Lehmke helped me with to design a somewhat consistent look-and-feel for chapter heads and table of contents, as illustrated below. However, I am facing one last problem that has me stomped.

For the MWE example below, the table of contents looks like the following, where I have changed some of the colors for the chapter names.

Table of contents

A "typical" chapter head, that includes a mini table of contents looks as follows:

Correct chapter head

However, a "typical" Appendix head has the Appendix title repeated in the mini table of contents:

Incorrect Appendix head

Note that I can achieve (!) the same look for a chapter if I include the package titletoc at the beginning of the preamble rather than at the end, as illustrated below.
Incorrect chapter head

In other words, in order to include the proper amount of material in the mini table of contents at the beginning of a chapter, I need to include titletoc after I include the code to create the "pretty table of contents"; somehow, titletoc must redefine some macros which, perhaps (?) are rewritten when \appendix is interpreted - or perhaps are not defined in titletoc in the first place.

So, how do I get rid of the extra "Appendix title" in the mini table of contents?


\usepackage{lipsum}   % for testing purpose only
\usepackage{hyphenat}       % I use it to prevent hyphenation of table of contents items

%%% Do not include titletoc here - do it at the end

%%% colors definitions
\definecolor{MainRed}{rgb}{.6, .1, .1}
\definecolor{GoldDecoration}{RGB}{170, 120, 70}

% Colored section, subsections, as well as
% chapter and section name in the head - included for completeness

%% RedBox style -- adapted from BlueBox style, pp:43-44
% http://mirror.csclub.uwaterloo.ca/CTAN/info/latex-samples/MemoirChapStyles/MemoirChapStyles.pdf
% with modifications from 
% https://tex.stackexchange.com/questions/49864/automatically-adjusting-size-of-a-box-based-on-other-content
% and others modifications of my own

  \leavevmode\leaders\hrule height 3\p@ \hfill \kern \z@}
    \makebox[0pt][c]{#1\strut} \\[.5ex]
        %\printcontents[chapters]{}{1}{}%  Useless?

%%%%%% use the newly defined style

%%% Pretty ToC
%%%%% adapted from https://tex.stackexchange.com/questions/35825/pretty-table-of-contents/35835
% a modification of the leftbar environment defined by the framed package
% will be used to place a vertical colored bar separating the page number and the
% title in chapter entries
  \def\FrameCommand{\textcolor{GoldDecoration}{\vrule width 2pt depth 6pt}\hspace*{15pt}}%


% redefinitions for chapter entries


% redefinitions for section entries
  \hskip1em\hbox to \@pnumwidth{{\cftsectionpagefont #1\hfill}}}

% redefinitions for subsection entries
  \hskip1em\hbox to \@pnumwidth{{\cftsubsectionpagefont #1\hfill}}}

%%%% End of Pretty ToC


% include after the change above


    \chapter{First Chapter}
        \section{First section}
        \subsection{First subsection}
        \section{Second section}
    \chapter{Second Chapter}
        \section{First section}

    \chapter{First Appendix}
        \section{First section}
        \section{Second section}

Note that I have included a few extra lines (such as the color selection for section heads) as various attempts I have made have resulted in changing other elements; those included are the ones needed for the "complete look and feel".


The problem here is that memoir defines a "new" sectioning structure named appendix which gets its own \l@appendix. This doesn't exist in LaTeX standard classes. A chapter in the appendix is just a chapter.

titletoc now "hooks" into the commands \l@..., saving the old definitions at the time the package is loaded (this is the positional effect you have noticed; it would probably be better for titletoc to save the old definitions \AtBeginDocument, then it wouldn't make a difference when the package is loaded).

You are redefining the \l@appendix, but titletoc doesn't know about \l@appendix and thus doesn't hook into it.

I (naively!) mimicked titletocs chapter hook for appendix like this:


(inserted immediately before \makeatother in your MWE)

This should make an appendix behave like a chapter as far as titletoc is concerned. You might make a less naive definition if you need chapters and appendices to behave differently. At least in my test, the redundant appendix heading disappeared.

  • This works very well, thank you. I really, really appreciate the explanation too. – André Apr 10 '12 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.