(Message in three parts, because LaTeX-L rejects long messages) Below there are two enclosed files corresponding to titletoc with templates added, and a trial file. The main goal is to show a different approach to TOC attributes and how entries could be grouped in a single paragraph. I'm currently working in some improvements and many bugs remain to be fixed, but it provides a mock-up of the main ideas. I have not finished yet partial tocs and hence I removed the code from the sent files; the processcontents is just a copy of the code by James Kilfiger. The attributes of standard toc entries (JB1) are: pre-action: Code to be executed before the entry, post-action: Code to be executed after the entry, decls: declarations (usually paragraph format ones), left-margin: the left margin related to the entry text (*not* the label), right-margin: the right margin related to the entry text, right-adjust: a correction for leaders (the leader chars are not centered in the enclosing box, but aligned to right), this parametes adjusts the entry text so that its right margin and the leaders are algned, label-format: It should include code for making the label hangs, label-width: title-format: self-explanatories title-format-nolabel: if present, overrides the title format in unlabeled entries, page-format: It should include code for making the page hangs, leaders-text: leaders-width: self-explanatories The attributes of "paragraphed" toc entries (JB2) are: pre-action: Only that of the very first grouped entry is executed, decls: left-margin: right-margin: label-format: title-format: title-format-nolabel: page-format: As before, except that neither the label nor the page hang, punct-sep: Default separator, punct-end: Ending puntuation, only that of the very last grouped entry is executed. =f0 [.] \COpunct@end, punct-sup: Separator when the following entry is one level above (eg, subsection section) punct-sup-sup: Id. two levels above (eg subsubsection section) punct-sub: Id. one level below (eg, section subsection) Since the right-margin is usually set for all of entries, the command \contentsmargin[correction]{right} is provided. The default values for the corresponding attributes are taken from a couple of internal macros set by it. \bye \bye Javier ps. As I'm gettting more and more involved in an Omega project, I'm not sure if I can continue with this discussion. I will try it, anyway. =========================== xtitlesec.sty begins \ProvidesPackage{xtitletoc} \RequirePackage{xparse} \RequirePackage{template} % The following tags are used: % ttl@ : the generic one, shared with titlesec % ttle@ : ending puntuation for block format % ttll@ : section level % ttlx@ : file extension \newif\ifttl@numsec \newif\ifttl@fromblock \providecommand\titleline{% \@ifnextchar[{\ttl@line}{\ttl@line[s]}} \def\ttl@line[#1]#2{% \vskip\topskip \hrule \@height \z@ \nobreak \vskip-\topskip \begingroup \parindent\z@ \everypar{}% \leftskip\z@ \rightskip\z@ \@makebox[\hsize][#1]{\ttl@makeline{#2}}% \par \endgroup \hrule height \z@ \nobreak} % Fillers: \providecommand\titlerule{\@ifstar{\ttl@row}{\ttl@rule}} \let\ttl@leaders\xleaders \def\ttl@row{\@ifnextchar[{\ttl@row@i}{\ttl@row@i[\wd\z@]}} \def\ttl@row@i[#1]#2{% \ifvmode\expandafter\titleline\fi {\sbox\z@{#2}% \hspace{-#1}% \hskip\wd\z@ \ttl@leaders\hb@xt@#1{\hss\box\z@}% \hfill\kern\z@}} \def\ttl@rule{\@ifnextchar[{\ttl@rule@i}{\ttl@rule@i[.4pt]}} \def\ttl@rule@i[#1]{% \ifvmode\expandafter\titleline\fi {\leaders\hrule height #1\hfill\kern\z@}} \providecommand\filright{% \gdef\es@filleft##1{\hskip##1}% \gdef\es@filright##1{\hfill}% \let\\\@centercr \advance\rightskip\z@ \@plus 1fil\relax} \providecommand\filleft{% \gdef\es@filleft##1{\hfill}% \gdef\es@filright##1{\hskip##1}% \let\\\@centercr \advance\leftskip\z@ \@plus 1fil \parfillskip\z@} \providecommand\filcenter{\filleft\filright \gdef\es@filleft##1{\hfill}} \providecommand\fillast{% \gdef\es@filleft##1{\hfill}% \gdef\es@filright##1{\hfill}% \let\\\@centercr \filleft\advance\rightskip\z@ \@plus -1fil \parfillskip\z@ \@plus 2fil\relax} % User interface % ~~~~~~~~~~~~~~ % Tools: \DeclareOption{dotinlabels}{\def\[log in to unmask] \DeclareOption{nodotinlabels}{\let\ttl@idot\@empty} \DeclareOption{leftlabels}{% \renewcommand\numberline[1]{\hb@xt@\@tempdima{#1\ttl@idot\hfil}}% \newcommand\contentslabel[2][\thecontentslabel\ttl@idot]{% \hspace*{-#2}\hb@xt@#2{#1\hfil}}} \DeclareOption{rightlabels}{% \renewcommand\numberline[1]{\hb@xt@\@tempdima{\hss#1\ttl@idot\enspace}}% \let\contentslabel\relax \newcommand\contentslabel[2][\thecontentslabel\ttl@idot\enspace]{% \hspace*{-#2}\hb@xt@#2{\hfil#1}}} \newcommand\contentspage[1][\thecontentspage]{% \hb@xt@\@pnumwidth{\hfil#1}% \hspace*{-\@pnumwidth}} \newcommand\contentspush[1]{% \sbox\z@{#1}% \advance\leftskip\wd\z@ \leavevmode\llap{\box\z@}}