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 want the label and title of subsection typsetting as a paragraph but NEVER break down in a subsection title. Say, the code below

\documentclass{article}
\usepackage{titletoc}

\titlecontents*
{subsection}
{}
{\thecontentslabel:\nobreakspace}{}
{\nobreakspace(\thepage)}[.\quad]

\begin{document}
\tableofcontents



\section{A section}
\subsection{A subsection}
\subsection{Another subsection}
\subsection{A very long subsection}
\subsection{Again a subsection}
\subsection{A longest subsection in the article!}

\end{document}

I want the label of subsection 1.3 and 1.5 start in a new line respectively, like

1.1: A subsection (1)   1.2: Another subsection (1)
1.3: A very long subsection (1)   1.4: Again a subsection (1)
1.5: A longest subsection in the article! (1).
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can put the whole label into a box by adding \mbox to the label argument of \titlecontents. Also, I guess that you want to set the relevant parts of the TOC ragged-right to avoid labels running into the margin.

\titlecontents*%
{subsection}%
{\raggedright}%
{\thecontentslabel:\nobreakspace\mbox}{\mbox}%
{\nobreakspace(\thepage)}[.\quad]
share|improve this answer
    
Follow-up question suppress pagebreaks in titletoc's titlecontents* blocks about increasing pagebreak penalty –  Markus Schmassmann May 16 '12 at 16:11
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.