[Tex/LaTex] Long file path get out of right margin on PDF

hyphenationlyx

A simple LyX document consisting of one long file path, is wrapped inside the LyX GUI to the next line; but when exported to PDF it 'continues' after the right margin end.

I'd expect it to be automatically wrapped on the slashes.
How can I define some rule to do this?

This is the file path:

/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm

Best Answer

You could load the url package -- I suggest you set the options spaces, obeyspaces, and hyphens when loading the package -- and use that package's \path macro to typeset the long path name.

enter image description here

\documentclass{article}
\usepackage[hyphens,obeyspaces,spaces]{url}
\begin{document}
\noindent
\path{/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm/aaaa/bbbb/cccc/dddd/eeee/ffff/gggg/hhhh/iiii/jjjj/kkkk/llll/mmmm}
\end{document}
Related Question