# Very long name of Section reflects badly in TOC

I have too long name of Section that reflects badly in TOC.

Name of section doesn't have spaces in its name.

I can not know how pledge it to move part of name to the next line automatically.

(Idea to split name manually is bad).

 \begin{document}
\tableofcontents
\part{New Part}
\chapter{Name of the Chapter}

%Can not fit on the page, and can not be divided automatically
\section{This\_Is\_very\_Long\_Name\_of\_Section\_That\_Can\_Not\_Fit\_On\_Page\_And\_Push\_Out\_Of\_The\_Page\_Field}
\section{This\_Is\_very\_Long\_Name\_of\_Section \ That\_Have\_Spaces On\_Its Name \ And\_Will\_Be Bring\_On\_The\_Next\_Line}

\end{document}


Also, name of section creates automatically, and I previously cannot know how long will be it.

-
This surely needs a Minimal Working Example starting with \documentclass and ending with \end{document} and containing only the section and the table of contents, and all packages that influence their appearance. One of the reasons is that I don't understand how the section title fits in the page, when the TOC line does not (since TOC line is in a smaller font). –  yo' Oct 17 '12 at 7:15
Try \section{\url{very_long_name}}. Requires url package. I'm not sure if \url is a fragile macro, in this case this will not work. –  JLDiaz Oct 17 '12 at 8:22

Use \_\protect\linebreak[0] instead of \_ then it will allow (but not encourage) breaking after the _

Or if you want to allow the lines to fall short at the breaks,

\def\myunderscore{\_\nobreak\hfil\protect\penalty0\hfilneg}
\tableofcontents

\section{abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz\myunderscore abcxyz}

-
You could also introduce possible linebreak points using the package babel and the command "-. –  Ronny Oct 17 '12 at 9:27
Note if you got [0] in the output from the first version, it would appear that there is a mistake in your document somewhere. –  David Carlisle Oct 17 '12 at 12:31