Page LayoutMisalignment of page number in table of contetns in case of path

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Pak
Posts: 1
Joined: Wed Jan 17, 2024 10:26 pm

Misalignment of page number in table of contetns in case of path

Post by Pak »

Good evening everyone!
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}
Attachments
Cattura.PNG
Cattura.PNG (22.17 KiB) Viewed 4090 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Post Reply