I have a problem with TableOfContents, specifically I have the names of my subsections that are path are therefore characterized by the presence of the characters "/" and "_". My goal is to break the line at "/" in both the subsection titles and TableOfContents.
I attach below what I have managed to do so far and the output I have.
You can notice how apparently the line-breaking logic is inconsistent and how the page numbers associated with the subsection are not aligned in column.
I thank you in advance for your helpfulness
\documentclass[12pt,a4paper]{article}
\AddToHook{cmd/section/before}{\clearpage}
\usepackage[a4paper,
left= 4.5 em,
right= 4.5em,
bottom=10em]{geometry}
\usepackage[export]{adjustbox}
\usepackage{hyperref} %[hidelinks]
\usepackage{url}
\usepackage{tocloft}
\cftsetindents{sec}{0em}{1.25em}
\newcommand{\CustomSubSection}[1]
{
\raggedright
\subsection{\texorpdfstring{\protect\path{#1}}{}}%
}
\begin{document}
\tableofcontents
\section{SectionName1}
\CustomSubSection{SubSezione_1_2/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/long/path}
\CustomSubSection{aaaa/bbbbbbbbbbbbb/cccccccccccccc/ddddddddddddddddddddddddddd/Confirmation}
\CustomSubSection{aaaa/aaaa_Run_sys/aaaa_subsystem/CheckAutoaaaaaaaaStatus_sys/Check_aaarnedOraaaaSn}
\end{document}