I am using sectsty to configure my section styles. I have read that perhaps titlesec is more powerful. A solution to my question below using titlesec is completely satisfactory.
Currently I am setting the fonts for section and subsection as follows.
\sectionfont{% % Change font of \section command
\noindent
\usefont{OT1}{phv}{b}{n}% % bch-b-n: CharterBT-Bold font
\sectionrule{0pt}{0pt}{-5pt}{2pt}}
\subsectionfont{\noindent\usefont{OT1}{phv}{b}{n}}
I am then adjusting the spacing as follows.
\renewcommand\section{\@startsection{section}{1}{\z@}%
{\bigskipamount}%
{\bigskipamount}%
{\normalfont\large\bfseries\SS@sectfont}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{\bigskipamount}%
{\medskipamount}%
{\normalfont\normalsize\bfseries\SS@subsectfont}}
The template for this adjustment comes from this SE question:
How to adjust the title spacing using sectsty package.
A somewhat equivalent template for titlesec can be found from this SE question:
Reducing spacing after headings.
Now my issue is the following.
When I do this \renewcommand\section..., the first paragraph is indented. I don't want this.
With titlesec, one can add an option noindentafter to the package call or use \titlespacing* to remove this indentation. See this SE question: Cancelling first-line indents after section titles. I cannot find similar things for sectsty, nor has experimentation succeeded.
Why am I using sectsty then?
Well, I like the font and sectionrule options.
I have not been able to get the same font using titlesec and the \titleformat option---which is somewhat confusing to me. The command \sectionrule appears to be specific to sectsty.
Thus I would like one of the following solutions.
- Obtain the same font and section rule using
titlesec. - Remove the indentation using
sectsty.
Option (1) would be preferable, but Option (2) is acceptable.
Two MWEs. The first is set up for sectsty and the second for titlesec.
\documentclass[]{article}
\usepackage{sectsty}
\sectionfont{% % Change font of \section command
\noindent
\usefont{OT1}{phv}{b}{n}% % bch-b-n: CharterBT-Bold font
\sectionrule{0pt}{0pt}{-5pt}{2pt}}
\subsectionfont{\noindent\usefont{OT1}{phv}{b}{n}}
\begin{document}
\section{Section Title}
This is not indented
\makeatletter
\renewcommand\section{@startsection{section} {1}{\z@}%
{\bigskipamount}%
{\bigskipamount}%
{\normalfont\large\bfseries\SS@sectfont}}
\makeatother
\section{Next Section}
This is indented now \texttt{:frowning:}
\end{document}
\documentclass[]{article}
\usepackage{titlesec}
\titleformat{\section}
{\sffamily \normalsize \bfseries \usefont{OT1}{phv}{b}{n}}{\thesection}{1em}{}
\begin{document}
\section{Section Title}
This is not indented
\titlespacing{\section}
{0pt}
{\bigskipamount}
{\medskipamount}
\section{Next Section}
This is indented now \texttt{:frowning:}
\titlespacing*{\section}
{0pt}
{\bigskipamount}
{\medskipamount}
\section{Final Section}
But viola, it is no longer indented by adding \texttt{*}
\end{document}

:-)-- personally I didn't feel it was beneficial in this case, but if you're offering to help then I'll certainly provide what you ask for!:-)– Sam OT Jan 07 '21 at 12:05