# Rule after small caps subsection

I know that this question has been answered before for section and chapter titles, but I cannot seem to apply it to subsection titles. I would like to globally change the format of subsection titles to the one presented in the MWE:

\documentclass[]{article}
\usepackage[T1]{fontenc}

\newcommand\ruleafter{\vspace*{-.5cm}\noindent\rule{\textwidth}{1pt}\vspace*{-.2cm}}

%opening
\title{}
\author{}

\begin{document}

\subsection{\textsc{Subsection title}}\ruleafter

\end{document}


I have tried using titlesec, but without success. Any suggestions? Thanks in advance!

PS: The questions considering the section and the chapter format, respectively:

How can I make a bold horizontal rule under each section title?

Add a rule after chapter title using titlesec

• Welcome to TeX.Stackexchange! Can you add links to the answers for section and chapter titles? – user36296 Feb 5 '18 at 13:26

If you don't mind using titlesec then:

\documentclass[]{article}
\usepackage[T1]{fontenc}

\usepackage{titlesec}

\titleformat{\subsection}
{\scshape\bfseries} % format
{\thesection}% label
{1pt}% sep
{\hspace{1ex}} % before-code
[\rule{\textwidth}{1pt}]

%opening
\title{}
\author{}

\begin{document}

\subsection{Subsection title}

\end{document}

• Thanks! But now the text is not boldface anymore, and adding the option removes small caps, in turn. – User2935032946 Feb 6 '18 at 6:59
• The command \sc, along with all similar two letter commands, has been obsolete for 25 years. – egreg Feb 6 '18 at 9:01
• @YulanvanOppen Sorry, forgot the bold face. The second mandatory argument to \titleformat is the formatting of the title. I updated the answer. – Phelype Oleinik Feb 6 '18 at 9:04
• @egreg Indeed, I didn't realize until he asked for bold too. Thanks! \scshape and \bfseries are okay to use? – Phelype Oleinik Feb 6 '18 at 9:05
• @PhelypeOleinik Yes, these are good. On the other hand, not many font familes provide boldface small caps. – egreg Feb 6 '18 at 9:10