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 13915 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply