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 would like to have partial tocs (mini-tocs) for each section. I would like to achieve this with the titletoc package. As you can see from the code below, it pretty much does the job but the problem is that the settings for the main toc in the beginning do not necessarily apply for the mini-tocs. For example, the mini-toc is indented like the corresponding sub-toc of the main toc -- of course that's not what one wants... I would like it to be left aligned as the section heading. Another problem is that for the mini-tocs, I would like to have more space between the subsection entries (but no space between the subsubsection entries). How can I do this? As you can see, the first problem can be solved with an addmargin environment (which is a bit ugly though), but I couldn't figure out how to solve the second problem (adjusting the space between the subsection entries in the mini-tocs).

\documentclass[
paper=128mm:96mm]{scrartcl}
\linespread{1.12}

% font stuff
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[american]{babel}

% page structure
\usepackage{calc}
\usepackage[includefoot,top=5.5mm,bottom=4.5mm,left=5.5mm,right=5.5mm,footskip=4mm]{geometry}
\usepackage{scrpage2}
\usepackage{titlesec}
\usepackage{titletoc}

%%% settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% page style and layout
\pagestyle{scrheadings}
\clearscrheadfoot

% enlarge font sizes of headings by two levels
\addtokomafont{section}{\huge}
\addtokomafont{subsection}{\LARGE}
\addtokomafont{subsubsection}{\Large}

% spacings
\titlespacing{\section}{0mm}{0ex plus 1ex minus .2ex}{0ex plus .2ex}
\titlespacing{\subsection}{0mm}{0ex plus 1ex minus .2ex}{-.2ex plus .2ex}
\titlespacing{\subsubsection}{0mm}{0ex plus 1ex minus .2ex}{-.4ex plus .2ex}
\setcounter{secnumdepth}{3}% add numbering down to subsubsection

% table of contents
\AtBeginDocument{\renewcaptionname{american}{\contentsname}{\hspace{-0.08em}\Large Outline}}% change name of toc
\setcounter{tocdepth}{3}
\titlecontents{section}[1.2em]{\addvspace{0.6em}\bfseries}{\contentslabel{1.2em}}{\hspace*{-1.2em}}{}[]% define format for section of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{subsection}[3em]{}{\contentslabel{1.8em}}{\hspace*{-1.8em}}{}[]% define format for subsection of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{subsubsection}[5.6em]{}{\contentslabel{2.6em}}{\hspace*{-2.6em}}{}[]% define format for subsubsection of toc; entries: section, left, above, before with label, before without label, filler and page, after


%%% document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\tableofcontents
\clearpage
\section{Section 1}
\startcontents[]% kind
%\begin{addmargin}{-1.08em}% ugly but solves the first problem
\printcontents[]{}{2}{}% kind, prefix, top, init-code
%\end{addmargin}
\clearpage
\subsection{Subsection 1.1}
\subsubsection{Subsubsection 1.1.1}
\subsection{Subsection 1.2}
\section{Section 2}
\subsection{Subsection 2.1}
\subsubsection{Subsubsection 2.1.1}
\subsubsection{Subsubsection 2.1.2}
\subsection{Subsection 2.2}
\subsubsection{Subsubsection 2.2.1}
\subsubsection{Subsubsection 2.2.2}
\clearpage
\end{document}
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

For the "partial" ToC, use \titlecontents to define the formats psubsection and psubsubsection (note the prefix) and issue \printcontents[]{p}{2}{} in the document body. See p. 17 of the titlesec/titletoc documentation for details.

\documentclass[
paper=128mm:96mm]{scrartcl}
\linespread{1.12}

% font stuff
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[american]{babel}

% page structure
\usepackage{calc}
\usepackage[includefoot,top=5.5mm,bottom=4.5mm,left=5.5mm,right=5.5mm,footskip=4mm]{geometry}
\usepackage{scrpage2}
\usepackage{titlesec}
\usepackage{titletoc}

%%% settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% page style and layout
\pagestyle{scrheadings}
\clearscrheadfoot

% enlarge font sizes of headings by two levels
\addtokomafont{section}{\huge}
\addtokomafont{subsection}{\LARGE}
\addtokomafont{subsubsection}{\Large}

% spacings
\titlespacing{\section}{0mm}{0ex plus 1ex minus .2ex}{0ex plus .2ex}
\titlespacing{\subsection}{0mm}{0ex plus 1ex minus .2ex}{-.2ex plus .2ex}
\titlespacing{\subsubsection}{0mm}{0ex plus 1ex minus .2ex}{-.4ex plus .2ex}
\setcounter{secnumdepth}{3}% add numbering down to subsubsection

% table of contents
\AtBeginDocument{\renewcaptionname{american}{\contentsname}{\hspace{-0.08em}\Large Outline}}% change name of toc
\setcounter{tocdepth}{3}
\titlecontents{section}[1.2em]{\addvspace{0.6em}\bfseries}{\contentslabel{1.2em}}{\hspace*{-1.2em}}{}[]% define format for section of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{subsection}[3em]{}{\contentslabel{1.8em}}{\hspace*{-1.8em}}{}[]% define format for subsection of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{subsubsection}[5.6em]{}{\contentslabel{2.6em}}{\hspace*{-2.6em}}{}[]% define format for subsubsection of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{psubsection}[1.8em]{\addvspace{0.6em}}{\contentslabel{1.8em}}{\hspace*{-1.8em}}{}[]% define format for section of toc; entries: section, left, above, before with label, before without label, filler and page, after
\titlecontents{psubsubsection}[4.4em]{}{\contentslabel{2.6em}}{\hspace*{-2.6em}}{}[]% define format for subsection of toc; entries: section, left, above, before with label, before without label, filler and page, after


%%% document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\tableofcontents
\clearpage
\section{Section 1}
\startcontents[]% kind
\printcontents[]{p}{2}{}% kind, prefix, top, init-code
\clearpage
\subsection{Subsection 1.1}
\subsubsection{Subsubsection 1.1.1}
\subsection{Subsection 1.2}
\section{Section 2}
\subsection{Subsection 2.1}
\subsubsection{Subsubsection 2.1.1}
\subsubsection{Subsubsection 2.1.2}
\subsection{Subsection 2.2}
\subsubsection{Subsubsection 2.2.1}
\subsubsection{Subsubsection 2.2.2}
\clearpage
\end{document}
share|improve this answer
1  
Excellent, thanks a lot. –  Marius Hofert Feb 12 '12 at 12:56
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.