I am trying to typeset a document with the following style for a section title:
The text is centred. There is a thick line on either side of the text extending to the margin The rule is vertically centred relative to the height of the title.
So far, I have tried using the titlesec package, and I have consulted similar queries other people have had about text with lines on either side. However, none of those were trying to define a section heading using this style.
This is the code that I got so far:
\makeatletter
\def\vhrulefill{\leavevmode\leaders\hrule height 1ex depth \dimexpr0.4pt-0.7ex\hfill\kern\z@}
\makeatother
\titleformat{\section}[runin]%
{\LARGE\bfseries}%
{}{0pt}{\vhrulefill\space}[\space\vhrulefill\null]%
\begin{document}
\section{Foo}
Bar!
\end{document}
The end result of this has been that the text following the section does not break to a new line. Instead, it squeezes the title and the rule and encroaches upon the title.
Could someone suggest a better way of defining the section heading with this kind of rule on either side?
Best wishes


\parafter\vhrulefill\null? – wipet Apr 06 '20 at 18:50