# Add a horizontal rule under section title without any additional package

I would like to add a horizontal rule under section title, change colour and character of the title. Until now I have been able to change the color and character, but it revealed to me a hard task to add the horizontal rule under the title. What I have done until now is the following:

\RequirePackage%
{%
fontspec,%
xcolor,%
}
...
...
\definecolor[named]{SectionFontColour}{wave}{395}
\newfontfamily \SectionFont {ITC Avant Garde Gothic}
...
...
\renewcommand\section
{
\@startsection{section}% #1
{1}% #2
{\z@}% #3
{-2.5ex \@plus -1ex \@minus .2ex}% #4
{2.3ex \@plus.2ex}% #5
{%
\SectionFont%
\Large%
\mdseries%
\textcolor{SectionFontColour}%
} % #6


I would like to accomplish this task in the \section macro or in the \@statrsection macro. I would not use this way:

\let \oldsection \section
\renewcommand \section {\oldsection ... <some code that makes the rule>}


neither I would use additional packages here. And by the way, why the declaration of the \section does not take any parameter, when we call this macro (\section) we pass an argument to it? So the macro should be declared with a parameter, or not? Please help me to clarify these questions.

• Why do you want to avoid additional packages and certain approaches? Would you not wish to use them if those were the best strategies? – cfr Oct 26 '15 at 23:50
• Just for my curiosity, and for understand better how things work. – Gela Oct 27 '15 at 6:57

You can do something like this:

\documentclass{article}

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\bfseries\mytitle}}
\makeatother
\newcommand{\mytitle}[1]{#1\par\noindent\rule{\textwidth}{1pt}}
\begin{document}
\section{Some section}

\end{document}


• OK! Thank you very much! But, for me remains unclear the following: When we call the macro '\section' we pass an argument to it: '\section{Some section}' so the declaration of this macro should be something like this: '\renewcommand {\section}[1]{<body of the macro>}'. Why there is no need of [1] in declaration? – Gela Oct 27 '15 at 7:09
• @Gela No. The argument you give to \section is passed on to \mytitle macro. It is implicit here. – user11232 Oct 27 '15 at 7:29
• How would I go about removing the number? – M.O. May 5 '19 at 20:18