I am trying to add a horizontal line (like \hrule
) that starts just after each section's heading, fills the rest of the line, and is vertically aligned with the heading, as shown below.
To do so, I have defined a \newcommand
called \raisedrule
that generates the desired horizontal line (following this post). However, I am having difficulty incorporating it into the definition of the sections' headings.
I have tried using the titlesec
package, but I have not found a way to generate a line that is shorter than the text's width. I have also tried using the sectsty
package, using the following code:
\documentclass{article}
\newcommand{\raisedrule}[2][0em]{\leaders\hbox{\rule[#1]{1pt}{#2}}\hfill}
\usepackage{sectsty}
\sectionfont{
\setmainfont{Arial} \raisedrule[0.32em]{0.75pt}
}
\usepackage{fontspec}
\begin{document}
\section*{SECTION HEADING}
\end{document}
which, not only gives a "Leaders not followed by proper glue." error, but I don't think would generated the required output anyway.
Note that, as shown in the code, I also want to change the font of the heading, which may be important for the solution.
Any help would be greatly appreciated.
\hrulefill
is enough.