[Tex/LaTex] Mysterious overfull \hbox

sectioningwarnings

I want each section title to be underlined, with the section number on the right. Furthermore I want to use parskip. This is what I did to get that:

\documentclass[12pt,a4paper]{article}

\usepackage[explicit]{titlesec}
\titleformat{name=\section}[block]{\normalfont\Large}{}{0pt}{\makebox[\textwidth]{#1 \hfill \thesection}}[\vspace{1ex}\titlerule]

\usepackage[parfill]{parskip}

\begin{document}
\section{Introduction}
\end{document}

However, now I get an error:

Overfull \hbox (30.0pt too wide) in paragraph at lines 9--9
|[]|

I turned on \usepackage{showframe}, but visually everything is within the borders.

How can I fix this, or hide the warning?

Best Answer

The parts of the heading are internally paragraphs and so you need to reset \parfillskip to allow them to reach the right hand edge.

\documentclass[12pt,a4paper]{article}

\usepackage[explicit]{titlesec}



\titleformat{name=\section}[block]{\parfillskip0pt\normalfont\Large}{}{0pt}{{#1 \hfill \thesection}}[\vspace{1ex}\titlerule]

\usepackage[parfill]{parskip}

\begin{document}
\section{Introduction}

X\dotfill X
\end{document}
Related Question