Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to add a fancy looking chapter start page to a book. We're using the memoir class and make use of tikz for fancy section and chapter headings. Now, I need to add a list of the sections that occur in the chapter, on the chapter's start page. I've tried using something like:

\documentclass[oneside]{memoir}
\usepackage{tikz}
\usepackage{titletoc}
\usepackage{lipsum}

\begin{document}
\tableofcontents
\chapter{A chapter}
\startcontents[chapters]
\begin{tikzpicture}[overlay]
    \node[fill=blue] {\printcontents[chapters]{}{1}{}};
\end{tikzpicture}
\section{Section}
\lipsum[1]
\section{Section 2}
\lipsum
\chapter{Second chapter}
\startcontents[chapters]
\printcontents[chapters]{}{1}{}
\section{Section}
\lipsum[2]
\section{Another section}
\lipsum
\end{document}

but this doesn't seem to work well. My actual code redefines the \chapter command and inserts the tikzpicture as part of the chapter page. I'm aiming for something like this: The goal

I'd appreciate a pointer as to how I can get a mini toc inside a TikZ node OR how to get access to a list of the sections that allows me to loop through them OR any other way to accomplish my goal.

share|improve this question
add comment

1 Answer

up vote 24 down vote accepted

You can use a minipage for this.

enter image description here

Here an example:

\documentclass[oneside]{memoir}

\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\usepackage{titletoc}
\usepackage{lipsum}

\usepackage{calc}

\definecolor{yourcolor}{HTML}{008bb2}

%define new chapter style (just for a nicer look)
\makechapterstyle{mystyle}{%
  \chapterstyle{default}
  \renewcommand*{\chapnumfont}{\normalfont\Huge\sffamily\bfseries}
  \renewcommand*{\chaptitlefont}{\normalfont\huge\sffamily\itshape\color{yourcolor}}
  \settowidth{\chapindent}{\chapnumfont 111}
  \renewcommand*{\chapterheadstart}{}
  \renewcommand*{\chapnamefont}{\hfill\color{yourcolor}\normalfont\Huge\sffamily\bfseries}
  \renewcommand*{\printchapternum}{%
  \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}]
  \node[fill=yourcolor,circle,text=white] {\thechapter};
  \end{tikzpicture}\\[1ex]
  \hrule height 1.5pt}
  \renewcommand*{\printchaptertitle}[1]{%
    {\chaptitlefont ##1}}
}

%use new chapter style
\chapterstyle{mystyle}

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{\noindent\hspace{-2cm}\begin{tikzpicture}
    \node[rounded corners,align=left,fill=yourcolor, blur shadow={shadow blur steps=5}]{%
        \color{white}%
        \begin{minipage}{8cm}%minipage trick
        \printcontents[chapters]{}{1}{}
        \end{minipage}};
    \end{tikzpicture}}

\begin{document}
\tableofcontents
\chapter{A chapter}
\startcontents[chapters]
%print minitoc
\printmyminitoc



\section{Section}
\lipsum[1]
\section{Section 2}
\section{test}
\section{abc}
\lipsum
\chapter{Second chapter}
\end{document}
share|improve this answer
    
How to do this, for \documentclass[twoside]{book}. when i change memoir to book, i get error! –  mohammad azadi Nov 19 '12 at 16:59
    
You get this error because the example uses commands from memoir class. You need to modify the the code to work with book. –  someonr Apr 11 '13 at 18:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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