The Spanish module for babel
is responsible for this, probably following some directive of the authority on the language. There is an additional option for disabling it:
\usepackage[spanish,es-lcroman,es-nosectiondot]{babel}
See section 2.3 in the documentation for the Spanish option (texdoc spanish
or here on TeXdoc.net).
There will be no need to act on \@seccntformat
.
In order to keep the period after the chapter number (although I don't see why), patch the \@chapter
command:
\usepackage{etoolbox}
\makeatletter
\patchcmd\@chapter{\numberline{\thechapter}}{\numberline{\thechapter.}}{}{}
\makeatother
My goal is to have {the section number}\heartsuit{the section title} with no space in-between the characters.
Then the following will do:
\documentclass{article}
\usepackage{tocloft,lipsum}
\makeatletter
\renewcommand\tableofcontents{%
\section*{\contentsname\@mkboth{}{}}%
\thispagestyle{empty}%
\@starttoc{toc}%
\thispagestyle{empty}%
\clearpage%
}
\renewcommand{\numberline}[1]{%
\@cftbsnum #1\@cftasnum\@cftasnumb}
\renewcommand{\@dotsep}{2}
\renewcommand{\cftpnumalign}{r}
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecpagefont}{\bfseries}
\renewcommand{\cftsecaftersnum}{$\heartsuit$}
\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}
I think the solution is to make the section numbers ragged on the right, just like all the page numbers are.
You probably mean \raggedleft
(or flush right). For this you can use the following definition of \numberline
and set \cftsecnumwidth
:
\renewcommand{\numberline}[1]{%
\makebox[\@tempdima][r]{\@cftbsnum #1\@cftasnum}\@cftasnumb}
\renewcommand{\cftsecnumwidth}{2em}
The package does not seem to offer a manner to control the box controlling the section number. Is this possible with titletoc
?
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 unit X
:
This is a simplied pseudo-code version for the typesetting of numbered [...] entries.
{\cftXfont {\cftXpresnum SNUM\cftXaftersnum\hfil} \cftXaftersnumb TITLE}%
{\cftXleader}{\cftXpagefont PAGE}\cftXafterpnum\par
In terms of the actual macro contents for section, the above pseudo-code is contained within \l@section
, \numberline
and \cftsecfillnum
(taken from tocloft.dtx
with comments added to highlight certain elements):
\renewcommand*{\l@section}[2]{%
\ifnum \c@tocdepth >\z@
\if@cfthaschapter
\vskip \cftbeforesecskip
\else
\addpenalty\@secpenalty
\addvspace{\cftbeforesecskip}
\fi
{\leftskip \cftsecindent\relax
\rightskip \@tocrmarg
\parfillskip -\rightskip
\parindent \cftsecindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima \cftsecnumwidth\relax
\let\@cftbsnum \cftsecpresnum
\let\@cftasnum \cftsecaftersnum
\let\@cftasnumb \cftsecaftersnumb
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{\cftsecfont #1}\nobreak% <----- This is \cftXfont; #1 relates to \numberline
\cftsecfillnum{#2}}%
\fi}
\renewcommand{\numberline}[1]{%
\hb@xt@\@tempdima{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}% <-- This is all similar to
% {\cftXpresnum SNUM\cftXaftersnum\hfil} \cftXaftersnumb TITLE}
\newcommand{\cftsecfillnum}[1]{%
{\cftsecleader}\nobreak% <--- This is {\cftXleader}
\makebox[\@pnumwidth][\cftpnumalign]{\cftsecpagefont #1}\cftsecafterpnum\par% <- This is
% {\cftXpagefont PAGE}\cftXafterpnum\par
}
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
:
\renewcommand{\cftsecpresnum}{\hfil}
\renewcommand{\cftsecaftersnum}{$\heartsuit$\@gobble}
The above would be similar to our above approach of using
\renewcommand{\numberline}[1]{%
\makebox[\@tempdima][r]{\@cftbsnum #1\@cftasnum}\@cftasnumb}
Here is an updated solution that aligns the ToC-entries at the indentation levels:
\documentclass{article}
\usepackage{tocloft,lipsum}
\makeatletter
\renewcommand\tableofcontents{%
\section*{\contentsname\@mkboth{}{}}%
\thispagestyle{empty}%
\@starttoc{toc}%
\thispagestyle{empty}%
\clearpage%
}
\renewcommand{\@dotsep}{2}
\renewcommand{\cftpnumalign}{r}
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsecpagefont}{\bfseries}
\renewcommand{\cftsecaftersnum}{\hfill$\bullet$\hfill\null}
\renewcommand{\cftsecnumwidth}{2em}% <--------------------------------------
% | <--------
\renewcommand{\cftsubsecaftersnum}{\hfill$\bullet$\hfill\null} % | |
\renewcommand{\cftsubsecindent}{2em}% Width of \section number in ToC ------- |
\renewcommand{\cftsubsecnumwidth}{2.5em} % |
% |
\renewcommand{\cftsubsubsecaftersnum}{\hfill$\bullet$\hfill\null} % |
\renewcommand{\cftsubsubsecindent}{4.5em}% Width of \section + \subsection number ------
\renewcommand{\cftsubsubsecnumwidth}{3.25em}
\renewcommand{\numberline}[1]{\makebox[\@tempdima][l]{\@cftbsnum #1\@cftasnum}\@cftasnumb}
\makeatother
\begin{document}
\tableofcontents
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\section{Section}\lipsum[4-11]\subsection{Subsection}\lipsum[4-11]\subsubsection{Subsubsection}\lipsum[4-11]
\end{document}
Best Answer
I wouldn't recommend to hardcode something like "Capítulo 1: First Things" in a sectional heading. The following code looks a little bulky because it does a more than you requested, but it induces a more LaTeXnish manuscript file.