[Tex/LaTex] Control breaking of overlong section titles

line-breakingsectioning

I have following code:

\section{This is some long text and probably it will be broken}

I would like to prevent word division like:

This is some long text and pro-
bably it will be broken

And the second issue is to break it in a nice way, for example:

This is some long text and probably it will be
broken

looks bad, because only word 'broken' will be placed in second line. It would be nicer to do it in this way:

This is some long text and probably
it will be broken

Best Answer

You can use a manual line change in the title (and the optional argument of the \section command to prevent the line change from appearing in the headings and in the ToC). Another option would be to use the \sloppy command and non-breaking spaces (but this will probably produce a bad box):

\documentclass{article}

\begin{document}
\tableofcontents

\section[This is some long text and probably it will be broken]{This is some long text and probably\\ it will be broken}

\section{\sloppy This is some long text and probably it~will~be~broken}

\end{document}
Related Question