0

I want to have a rule in the middle of a line which starts at end of a section and goes all the way to the right margin of a page.

I have seen several posts with solutions and the best one I found is by using this:

\documentclass{article}

\usepackage{linegoal}

\begin{document}

\newcommand{\centerrule}{\leavevmode\rule[.2em]{\linegoal}{.1em}

\section{section \centerrule}

\end{document}

This works fine, but I would like to apply the \centerrule with titlesec package. Which doesn't work. No matter how I add it, the rule is either in front of the \section or under it. Is there any way to achieve this?

1
  • Check out leaders and the example on page 225 of the TeXbooku sing {\leaders\hrule}. Jun 15, 2020 at 20:07

1 Answer 1

1

This uses leaders. The tricky bit was figuring out how to raise the \hrule.

\documentclass{article}
\usepackage{showframe}
\usepackage{blindtext}

\def\leaderfill{\leaders\hrule height4.5pt depth-4pt\hfill\space}

\begin{document}

\section[section]{section \leaderfill}

\section[blindtext]{\sloppy\blindtext \leaderfill}

\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.