How can i make a titleformat that fills in the whole line? Something like that:
«counter» «name» « ------ rule fill --------»
Normal text....
I managed to do it using the runin type but it has several problems:
\newcommand{\crulefill}{\leavevmode\leaders\hrule height 0.7ex depth\dimexpr 0.5pt-0.7ex\hfill\kern 0pt}
\titleformat{\section}[runin] {\bfseries\Large} {\fboxrule=0.5pt\fcolorbox{black}{white!0}{{\color{black}\thesection.}}\rule[.7ex]{10pt}{.5pt}\ } {0pt} {\upshape\bfseries\Large} [\ \crulefill\vspace*{1.5ex}~\\hspace*{6pt}]
- \vspace defines the separation between the normal text and the section.
- \hspace defines the separation in the first line of the normal text (the indentation)
- When there is no text between a section and a subsection, the space is too large, but when there is text, the space is fine.