# overfull hbox when I insert hline

I've got an issue related to table of contents. I want a horizontal line before each section, so I put

    \renewcommand{\cftsecfont}{
\hline
%other stuff that I need
}


This is perfect in terms of what I see, but I get a warning because (I guess) the compiler expects to find \hline within a table. So I replaced it with

line(1,0){length}


The problem now is that if length is long enough (I need the line to arrive on top of the page number), I get an overfull hbox.

Any idea? I already searched related problems with no luck.

-
Welcome to TeX.sx! –  Papiro Jul 3 '13 at 12:49
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  mafp Jul 3 '13 at 13:07

You are providing only spare information. However I guess you are looking for \hrulefill. So you modification can be:

\documentclass{article}
\usepackage{tocloft}
\usepackage{blindtext}
\renewcommand{\cftsecfont}{\hrulefill\par\nobreak\hskip -\leftskip\bfseries}
\begin{document}
\tableofcontents
\Blinddocument
\end{document}


-
+1 for a really minimum MWE :) –  Harish Kumar Jul 4 '13 at 0:10
Thank you that is what I was looking for (I had tried with \hrulefill only without success) –  ALPI Jul 4 '13 at 9:34