Here's one possibility using the titletoc
package to generate the partial ToCs; a boolean switch \partialtoc
is provided to activate/deactivate the partial ToCs at will (in the example below \partialtocfalse
was used just before the appendix to prevent the partial ToC):
\documentclass[openany]{book}
\usepackage{titletoc}
\usepackage{etoolbox}
\newif\ifpartialtoc
\partialtoctrue
\makeatletter
\patchcmd{\@makechapterhead}
{\vspace*{50\p@}}
{\ifpartialtoc
\vspace*{0\p@}%
\hfill\smash{\raisebox{\height}{%
\begin{minipage}{.8\textwidth}
\printcontents{}{1}{\section*{\contentsname}}
\end{minipage}%
}%
}\vskip50pt\par
\else
\vspace*{50pt}%
\fi%
}
{}
{}
\pretocmd{\chapter}{\startcontents}{}{}
\makeatother
\begin{document}
\chapter{Test chaper one}
\section{Test section one one}
\section{Test section one two}
\section{Test section one three}
\section{Test section one four}
\chapter{Test chaper one}
\section{Test section two one}
\section{Test section two two}
\section{Test section two three}
\appendix
\partialtocfalse
\chapter{Test Appendix}
\end{document}
The output:

A zoomed-in image for the first page of chapter one:

Update:
In a comment, it has been requested to get a similar result using titlesec
and its \titleformat
command; here's one possibility:
\documentclass[openany]{book}
\usepackage{titlesec}
\usepackage{titletoc}
\newif\ifpartialtoc
\partialtoctrue
\titleformat{\chapter}[display]
{\startcontents\normalfont\huge\bfseries}
{\PartialToc\chaptertitlename\ \thechapter}
{20pt}
{\Huge}
\newcommand\PartialToc{%
\begingroup
\ifpartialtoc
\normalsize\normalfont
\vspace*{0pt}%
\hfill\smash{\raisebox{\height}{%
\begin{minipage}{.8\textwidth}
\printcontents{}{1}{\textbf{\large\contentsname}\vskip10pt}
\end{minipage}%
}%
}\vskip50pt\par
\else
\vspace*{50pt}%
\fi%
\endgroup
}
\begin{document}
\chapter{Test chapter one}
\section{Test section one one}
\section{Test section one two}
\section{Test section one three}
\section{Test section one four}
\chapter{Test chapter two}
\section{Test section two one}
\section{Test section two two}
\section{Test section two three}
\appendix
\partialtocfalse
\chapter{Test Appendix}
\end{document}
titlesec
andtitletoc
(using its commands for partialtocs
) should help here; as Gonzalo mentions, thedocumentclass
is important – cmhughes May 5 '14 at 16:36