1

I'm trying to remove the interfaces-tocloft package from my documents, it causes problems in some and loads packages that I do not want in some occasions, so I've tried using titletoc (which is something more familiar to me that tocloft), but I can not get the same result. This is my example file using the interfaces-tocloft package:

% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
%\usepackage{titletoc}
\setlength{\parindent}{0pt}
\usepackage{tocloft}
\usepackage{interfaces-tocloft}

% Config hyperref
\hypersetup{
   linkcolor          = blue!50,
   colorlinks         = true,%
   }

% Table of contents
\def\rulecolor{\color{gray}}
\tocsetup{%
title=Contents\quad{\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill\null},
 title/after= \vspace{3pt},
 title/font= \sffamily\bfseries\Large,%
 title/top=10pt,%
 title/bottom=0pt,%
 twocolumns,
 section/skip=4pt plus2pt minus2pt,%
 subsection/skip=0pt plus2pt minus2pt,
 section/leaders,section/dotsep,%
 after=\vspace{-3pt}\noindent{\rulecolor\hrule height4.4pt depth-4pt\relax},
}

\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section} 
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}

And the output looks like this: tocloft-OK

This is my attempt using the titletoc package:

% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
\usepackage{titletoc}
\setlength{\parindent}{0pt}
%\usepackage{tocloft}
%\usepackage{interfaces-tocloft}

% Config hyperref
\hypersetup{
   linkcolor          = blue!50,
   colorlinks         = true,%
   }

\titlecontents{section}[15pt]{\addvspace{1em}\bfseries}%
    {\contentslabel[\thecontentslabel]{15pt}}%
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%

\titlecontents{subsection}[30pt]{}%
    {\contentslabel[\thecontentslabel]{15pt}}% numbered
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%

\titlecontents{subsubsection}[45pt]{}%
    {\contentslabel[\thecontentslabel]{15pt}}% numbered 
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]

% Table of contents
\def\rulecolor{\color{gray}}
\makeatletter
\renewcommand\tableofcontents{%
\begingroup%
\noindent{\sffamily\bfseries\Large\contentsname\quad\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill}\null%
\vspace*{-10pt}
\setlength{\columnsep}{10pt}%
 \begin{multicols}{2}%
    \@starttoc{toc}%
\end{multicols}%
\vspace*{-10pt}
\rulecolor\hrule height4.4pt depth-4pt\relax\null%
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section} 
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}

And the output looks like this: titletoc-NotOK

I can not find the right measures to make it look appropriate (therefore I have not added numberless sections). The idea is to look like this:

1 Section ......................
  1.1 Subsection I .............
      1.1.1 Subsubsection I ....
      1.1.2 Subsubsection II ...
      1.1.3 Subsubsection III ..

How can I achieve this using titletoc?

regards

1

Is this what you want?

enter image description here

To get this just requires the following small tweak of your code for subsubsections:

\titlecontents{subsubsection}[45pt]{}%
    {\hspace{1.00em}\contentslabel[\thecontentslabel]{25pt}}% numbered
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]

For completeness, here is the full code:

% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
\usepackage{titletoc}
\setlength{\parindent}{0pt}
%\usepackage{tocloft}
%\usepackage{interfaces-tocloft}

% Config hyperref
\hypersetup{
   linkcolor          = blue!50,
   colorlinks         = true,%
   }

\titlecontents{section}[15pt]{\addvspace{1em}\bfseries}%
    {\contentslabel[\thecontentslabel]{15pt}}%
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%

\titlecontents{subsection}[30pt]{}%
    {\contentslabel[\thecontentslabel]{15pt}}% numbered
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%

\titlecontents{subsubsection}[45pt]{}%
    {\hspace{1.00em}\contentslabel[\thecontentslabel]{25pt}}% numbered
    {}% numberless
    {\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]

% Table of contents
\def\rulecolor{\color{gray}}
\makeatletter
\renewcommand\tableofcontents{%
\begingroup%
\noindent{\sffamily\bfseries\Large\contentsname\quad\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill}\null%
\vspace*{-10pt}
\setlength{\columnsep}{10pt}%
 \begin{multicols}{2}%
    \@starttoc{toc}%
\end{multicols}%
\vspace*{-10pt}
\rulecolor\hrule height4.4pt depth-4pt\relax\null%
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section}
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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