4

I am trying to add line after every section, at present I am adding it after every section, how do I add this once so that I don't have to explicitly add it every time. The code I used is:

\section*{$21^{st}$ March 2015}
\vspace{-0.6cm}
\noindent\textcolor{red}{\rule{\textwidth}{1mm}} \\ \\
3

Such changes are best done with the titlesec package. With a standard documentclass you can write:

\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{}[{\color{red}\titlerule[1mm]}]

since according the documentation of titlesec

\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{}

provides the standard section title format, and we just add the rule in the final optional argument for material after the title.

Sample output

\documentclass{article}

\usepackage{color,titlesec}

\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{}[{\color{red}\titlerule[1mm]}]

\begin{document}

\section*{21\textsuperscript{st} March 2015}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.