Titles too wide and not hyphenated correctly

In my master thesis, I have several complicated titles that are longer than one line and that are not hyphenated but go further than the textwidth (see MWE below).

Additionally, while the hyphenation seems to work ok in most cases in the TOC, in some cases were the title is just a little bit too long, the page numbers are out of alignment (I was not able to reproduce this in a simple example, see picture). How can I fix this? For the compound numbers I use the bpchem package.

  \documentclass[a4paper, 11pt, titlepage]{article}
\usepackage[T1]{fontenc}

\begin{document}

\section{Experimental}

\subsection{4,4''-bis[2-(4-methoxy-2,6-dimethylphenyl)ethynyl]-5,5''-bis(methoxymethoxy)-2,2':6',2''-terpyridine }

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\end{document}

-

Section 3.2 of the bpchem manual shows how to add extra hyphenation to an IUPAC name. The short version is that you need to add additional \- and \| where hyphenation is allowed. Aside from that, you may need to adjust the default ToC margins so that if a word runs slightly long due to hyphenation rules, it won't interfere with the page numbers. This can be done at a lower level with the \@pnumwidth and \@tocrmarg lengths, or you can use a package like tocloft to handle it at a higher level. A complete example including the ToC:

\documentclass[a4paper, 11pt, titlepage]{article}
\usepackage{bpchem}
\usepackage{lipsum}
\usepackage[T1]{fontenc}
\usepackage{tocloft}
\cftsetpnumwidth{1em}
\cftsetrmarg{3.5em}

\newcommand{\makesection}{%
\section{Experimental}

\subsection{\IUPAC{4,4''-bis[2-(4-meth\|oxy-2,6-di\|methyl\|phenyl)\|eth\|ynyl]\|\-5,5''\-bis\|(meth\|oxy\|meth\|oxy)-2,2':6',2''-ter\|pyr\|idine}}
\lipsum

\subsection{\IUPAC{4,4''-bis[2-(4-meth\|oxy-2,6-di\|methyl\|phenyl)\|eth\|ynyl]\|\-5,5''\-bis\|(meth}}

\lipsum

}

\begin{document}

\tableofcontents

\makesection
\makesection
\makesection
\makesection
\makesection

\end{document}


-
I "un-accepted" your answer as I realized after accepting that it only solves part of my problem. Do you (or anyone else) have an idea what I could do to solve the problem in the TOC? – Helen Apr 25 '12 at 14:18
I'm unable to reproduce your problem with the ToC. Can you verify my code works on your system the same way it does on mine? – Mike Renfro Apr 25 '12 at 16:48
Your code works on my system the same way. If you cut off one of the titles after "meth" so that it is only \subsection{\IUPAC{4,4''-bis[2-(4-meth\|oxy-2,6-di\|methyl\|phenyl)\|eth\|ynyl]‌​\|\-5,5''\-bis\|(meth}}you should get the effect i described above that the page number is misaligned. – Helen Apr 25 '12 at 17:49
Added some tocloft fixes to handle that problem. – Mike Renfro Apr 25 '12 at 18:31