[Tex/LaTex] How to draw a rule without knowing its specific width

rules

I am trying to improve my CV which I am writing using LaTeX. I want to show section headings something like this

enter image description here

But I do not know how to;

  1. Add white space next to the section title, which is equal to what appears before the text as shown in the example figure.

  2. Add a rule exactly the same as what is appeared in the margin, starting right after the text and ending at the end of the textwidth size. This is hard for me, because the size of the rule is different based on the text size which occupies part of the text width of the paper.

Here is the MWE which makes part of the problem.

enter image description here

%pdfLaTeX
\documentclass{article}

\usepackage{marginnote}
\usepackage{color}
\definecolor{darkcandyapplered}{rgb}{0.64, 0.0, 0.0}

\newcommand{\stitle}[2] {%
    \noindent\textcolor{darkcandyapplered}{\large \bf #1}%
    \reversemarginpar\marginpar%
    {\raggedleft \textcolor{darkcandyapplered}{\rule{2.35cm}{8.5pt}} \\*[-.8pc]}%
    \\[#2\baselineskip]}

\begin{document}

\stitle{Education}{0}

\end{document}

Best Answer

You could use the sectioning commands, with the help of titlesec:

\documentclass{article}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}

\definecolor{darkcandyapplered}{rgb}{0.64, 0.0, 0.0}

\titleformat{\section}
  {\Large\bfseries}
  {}
  {0pt}
  {\betweenrules}

\titlespacing*{\section}
  {0pt}% space at left
  {1ex}% space above
  {2ex}% space below

\newcommand{\betweenrules}[1]{%
  \makebox[0pt][r]{\color{darkcandyapplered}\vrule width 2cm height 1.5ex \hspace{1em}}%
  #1% the title
  \hspace{1em}%
  \color{darkcandyapplered}%
  \leaders\hrule height 1.5ex\hfill
}

\begin{document}

\lipsum[3]

\section{Education}

\lipsum[1-2]

\end{document}

Adjust the parameters to suit.

enter image description here