My problem is that there exists an overlap between the symbol to introduce and the section title; it is manifest with two \heartsuit
s
\documentclass{article}
\usepackage{tocloft}
\usepackage{lipsum}
%\contentslabel{3em}
\renewcommand\tableofcontents{%
\section*{\contentsname\@mkboth{}{}}%
\thispagestyle{empty}%
%\small%
\@starttoc{toc}%
\thispagestyle{empty}%
\clearpage%
}
\makeatother
\makeatletter
\renewcommand{\@dotsep}{2}
%%\renewcommand{\cftdot}{\ensuremath{\ast}}
\renewcommand{\cftpnumalign}{r}
%\renewcommand{\cftsecpresnum}{SOMETHING }
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecpagefont}{\bfseries}
%\renewcommand{\cftsecpresnum}{SOMETHING }
\renewcommand{\cftsecaftersnum}{$\heartsuit$}
\renewcommand{\cftsecaftersnumb}{$\heartsuit$}
%\renewcommand{\cftsecaftersnumb}{\\}
% \newlength{\mylen} % a "scratch" length
% \settowidth{\mylen}{\bfseries\cftsecpresnum\cftsecaftersnum} % extra space
% \addtolength{\cftsecnumwidth}{\mylen} % add the extra space
%\makeatother
\begin{document}
\tableofcontents
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\section{1}\lipsum[4-11]
\end{document}
The modifying commands come straight from the manual of tocloft
.
My goal is to have {the section number}\heartsuit{the section title}
with no space in-between the characters.
I think the solution is to make the section numbers ragged on the right, just like all the page numbers are.
The package does not seem to offer a manner to control the box controlling the section number. Is this possible with titletoc
? (its readme is very succinct and I do not understand half of what is written)
EDITion:
@Werner: I have a snag with the code. I want to use the same pattern for the subsections and subsubsections as the one of the sections. So I use
\renewcommand{\cftsecaftersnum}{$\bullet$}
%\renewcommand{\cftsecnumwidth}{2em}
\renewcommand{\cftsubsecaftersnum}{$\bullet$}
%\renewcommand{\cftsubsecnumwidth}{0em}
\renewcommand{\cftsubsubsecaftersnum}{$\bullet$}
\renewcommand{\numberline}[1]{\makebox[\@tempdima][r]{\@cftbsnum #1\@cftasnum}\@cftasnumb}
but the beginnings of the subsections and subsubsections is not adequate:
(I use roman numbers for my sections and sub(sub)sections)
Ideally, the number subsection (and subsubsection) must be aglin with the first letter of the sections it belongs to
so
II$\bullet$Title
II.1$\bullet$subtitle
II.1.1$\bullet$subtitle
But it is not the case with the above code.
Best Answer
Then the following will do:
You probably mean
\raggedleft
(or flush right). For this you can use the following definition of\numberline
and set\cftsecnumwidth
:This is perhaps only partially true. However, for an inexperienced user, it's not that obvious how one can manipulate the macros to achieve what you're looking for. I'll just show some information below, since the control of the boxes really depends on what you want to do.
According to the
tocloft
documentation, the construction of the ToC entry has the following form for sectional unitX
:In terms of the actual macro contents for section, the above pseudo-code is contained within
\l@section
,\numberline
and\cftsecfillnum
(taken fromtocloft.dtx
with comments added to highlight certain elements):It's clear from
\numberline
that the default is "ragged right" (or left aligned) due to the\hfil
on the right. However, we can achieve a "ragged left" (or right aligned) look by changing\cftXpresnum
to be\hfil
and let\cftXaftersnum
(insert a$\heartsuit$
by also)\@gobble
the right-hand\hfil
:The above would be similar to our above approach of using
Here is an updated solution that aligns the ToC-entries at the indentation levels: