You seem to be using the commands from the sectsty
package but loading titlesec
. You can use either one of those packages, but using their own commands; the examples below show possible solutions using each package:
Here's one way to achieve it using the extended \titleformat
syntax from titlesec
package:
\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}{\thesubsubsection}{1em}{}
\begin{document}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\end{document}
And here's an example using the simplified \titleformat*
command:
\documentclass{article}
\usepackage{titlesec}
\titleformat*{\section}{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}
\titleformat*{\subsection}{\normalfont\fontfamily{phv}\fontsize{14}{17}\bfseries}
\titleformat*{\subsubsection}{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}
\begin{document}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\end{document}
And here's an example using sectsty
:
\documentclass{article}
\usepackage{sectsty}
\sectionfont{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}
\subsectionfont{\normalfont\fontfamily{phv}\fontsize{14}{17}\bfseries}
\subsubsectionfont{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}
\begin{document}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\end{document}
Just for completeness's sake, here's one solution without additional packages, redefining the original commands:
\documentclass{article}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\fontfamily{phv}\fontsize{14}{17}\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\fontfamily{phv}\fontsize{14}{17}\selectfont}}
\makeatother
\begin{document}
\section{Test Section}
\subsection{Test Subsection}
\subsubsection{Test Subsubsection}
\end{document}
As egreg mentions in his comment, the presence of \bfseries
allows not to specify \selectfont
.
Simply add these lines to your preamble
\renewcommand{\cftsecafterpnum}{\hspace*{7.5em}}
\renewcommand{\cftsubsecafterpnum}{\hspace*{7.5em}}
and adjust 7.5em
to your needs.
MWE
\documentclass[12pt]{article}
\usepackage{setspace, tocloft}
%Modifies line spacing of the ToC
\setlength\cftparskip{-1.2pt}
\setlength\cftbeforesecskip{1.3pt}
\setlength\cftaftertoctitleskip{2pt}
\renewcommand{\cftsecafterpnum}{\hspace*{7.5em}}
\renewcommand{\cftsubsecafterpnum}{\hspace*{7.5em}}
%Makes dots after sections/subsections: Sections 1., 2.1., etc
\makeatletter
\renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}
\makeatother
%Makes the dots (above) appear in ToC
\let \savenumberline \numberline
\def \numberline#1{\savenumberline{#1.}}
\begin{document}
\tableofcontents
\begin{section}{Section 1}
\begin{subsection}{Section 1.1}\end{subsection}
\begin{subsection}{Section 1.2}\end{subsection}
\end{section}
\begin{section}{Section 2}\end{section}
\end{document}
Output
A remark
If you want to add dots after sections and subsections numbers, you can use
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}
instead of
\let \savenumberline \numberline
\def \numberline#1{\savenumberline{#1.}}
Best Answer
Update the following macros to not have
\bfseries
in them:\cfttoctitlefont
,\cftsecfont
, and\cftsecpagefont
:Another quick-fix would be to set
\bfseries
to be equivalent to\mdseries
(or nothing) within a group that has a limit scope around the ToC only:But this may affect content within the headers/footers as well.