I have long paths as section headings and need proper line breaks. I don't need hyphens or any break rules.
\section{Important Paths}
\subsection{trunk/Averylong/Bverylong/Cverylongverylong/Dverylongverylong/Everylong/Fverylong\_file\_Name.txt}
\subsection{trunk/Averylong/Bverylong/Cverylongverylong/Dverylongverylong/Everylong/Fverylong file Name.txt}
The only way I can archive this is to add a hspace after each char. The output is exactly what I want it to be. But this doesn't seem to be a sane solution.
\subsection{t\hspace{0pt}r\hspace{0pt}u\hspace{0pt}n\hspace{0pt}k\hspace{0pt}/\hspace{0pt}A\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}B\hspace{0pt}v\hspace{0pt}e\hspace{0pt}rvy\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}C\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}D\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}E\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}v\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}F\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt} \hspace{0pt}f\hspace{0pt}i\hspace{0pt}l\hspace{0pt}e\hspace{0pt} \hspace{0pt}N\hspace{0pt}a\hspace{0pt}m\hspace{0pt}e\hspace{0pt}.\hspace{0pt}t\hspace{0pt}x\hspace{0pt}t\hspace{0pt}}
The output is:
1.1 even reaches over the end of the pdf.
I have created a simple document on sharelatex.
\documentclass[11pt,a4paper,fleqn]{scrartcl}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[raggedright]{titlesec}
\usepackage[hidelinks]{hyperref}
\usepackage{xcolor}
% Color definitions
\colorlet{mygray}{gray!30}
% Customize headings
\titleformat{\section}
{\normalfont\sffamily\Large\fontfamily{phv}\selectfont}
{\thesection.}{.5em}{}[{\vspace{.2ex}\titleline{\color{mygray}\titlerule[2pt]}}]
\titleformat{\subsection}
{\normalfont\sffamily\large\fontfamily{phv}\selectfont}
{\thesubsection.}{.5em}{}[{\vspace{.2ex}\titleline{\color{mygray}\titlerule[1.5pt]}}]
\titleformat{\subsubsection}
{\normalfont\sffamily\normalsize\fontfamily{phv}\selectfont}
{\thesubsubsection.}{.5em}{}[{\vspace{.2ex}\titleline{\color{mygray}\titlerule[1pt]}}]
\begin{document}
\author{A}
\title{B}
\maketitle
%Table of Contents
\newpage
\renewcommand*\contentsname{Table of Contents}
\tableofcontents
\thispagestyle {empty}
\newpage
\setcounter{page}{1}
\section{Important Paths}
\subsection{trunk/Averylong/Bverylong/Cverylongverylong/Dverylongverylong/Everylong/Fverylong\_file\_Name.txt}
\subsection{trunk/Averylong/Bverylong/Cverylongverylong/Dverylongverylong/Everylong/Fverylong file Name.txt}
\subsection{t\hspace{0pt}r\hspace{0pt}u\hspace{0pt}n\hspace{0pt}k\hspace{0pt}/\hspace{0pt}A\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}B\hspace{0pt}v\hspace{0pt}e\hspace{0pt}rvy\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}C\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}D\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}E\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}v\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt}/\hspace{0pt}F\hspace{0pt}v\hspace{0pt}e\hspace{0pt}r\hspace{0pt}y\hspace{0pt}l\hspace{0pt}o\hspace{0pt}n\hspace{0pt}g\hspace{0pt} \hspace{0pt}f\hspace{0pt}i\hspace{0pt}l\hspace{0pt}e\hspace{0pt} \hspace{0pt}N\hspace{0pt}a\hspace{0pt}m\hspace{0pt}e\hspace{0pt}.\hspace{0pt}t\hspace{0pt}x\hspace{0pt}t\hspace{0pt}}
\end{document}
Is there a simple solution to archive this?
//UPDATE: As suggested by by David Carlisle I applied the raggedright and slash approach. It works fine for the section headings but breaks the toc for some paths. E.g.:
\subsection{trunk\slash trunk\slash Averylong\slash Bverylongverylong\slash Cverylongverylong\slash AdditionalCompilerSupportDefines.h}
this one breaks the toc
I'v created an other sharelatex document to illustrate the toc problem.
//UPDATE: Resolved: The package tocstyle provides a hook to apply raggedright to the toc. See https://tex.stackexchange.com/a/45164/115878 & sharelatex document
\path
from theurl
package may help, need to test with your doc.\protect\path{trunk/Averylong/Bverylong/Cverylongverylong/Dverylongverylong/Everylong/Fverylong_file_Name.txt}
wotks fine. Note there is then no need to escape_
– daleif Oct 7 '16 at 10:35\path
, that is a different matter of which I have to time at the moment, sorry – daleif Oct 7 '16 at 10:47\DeclareUrlCommand\sfpath{\def\UrlFont{\fontfamily{phv}}}
, note the\sffamily
in your headings are probably being overwritten by\fontfamily
. – daleif Oct 7 '16 at 11:08\slash
instead of/
and line breaking will be allowed – David Carlisle Oct 7 '16 at 11:13