7

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?

  • Please provide a complete small document that shows the problem, not just fragments. – David Carlisle Nov 9 '13 at 19:01
  • Add a % after the final braces in lines 2 and 4. – egreg Nov 9 '13 at 19:02
  • @egreg that would be a start but 30pt sounds a lot for two word spaces, which is why I was asking for an example:-) – David Carlisle Nov 9 '13 at 19:04
  • @DavidCarlisle Yes, of course. – egreg Nov 9 '13 at 19:06
  • If I try the code I get Overfull \hbox (3.1333pt too wide) which is to be expected because of the two spaces. The 30pt is quite large and can't be explained only by your code snippet. – egreg Nov 9 '13 at 19:07
5

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}

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.