It seems that Latex has a problem with the correct hyphenation of very long, one word (sub-)section titles in the title itself and the toc. With the following MWE:
\documentclass[12pt]{scrartcl}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\usepackage[ngerman]{babel}
\usepackage[left=2.5cm,right=2.5cm,
top=2.5cm,bottom=2.5cm]
{geometry}
\usepackage{sectsty,ragged2e}
\allsectionsfont{\RaggedRight}
\begin{document}
\tableofcontents
\section{Section}
\subsection{(5\textit{R},6\textit{E},8\textit{E})-5-[(2-methoxyethoxy)methoxy]-\textit{N}-methoxy-\textit{N}-methyldeca-6,8-dienamid}
\end{document}
i end up with overfull hboxes in the toc and the title of the subsection.
Is there any way to prevent this mess?



\iupaccommand provided by the\chemmacrospackage. You may also be interested in using its\cipcommand in order to avoid using\textit{R}over and over. – leandriis Aug 20 '22 at 19:56