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?

10
  • Please provide a complete small document that shows the problem, not just fragments. Nov 9, 2013 at 19:01
  • Add a % after the final braces in lines 2 and 4.
    – egreg
    Nov 9, 2013 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:-) Nov 9, 2013 at 19:04
  • @DavidCarlisle Yes, of course.
    – egreg
    Nov 9, 2013 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, 2013 at 19:07

1 Answer 1

6

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}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .