0

i use the \path{} command to print out a path to a directory in my *.tex File. I searched a lot around the internet to solve the problem to automatically linebreak the path-url.

I found some hints and maybe solutions, like \usepackage[hyphens]{url}, \setlength{\emergencystretch}{2pt} or

%\def\UrlBreaks{
%\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
%\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
%\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D%
%\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N%
%\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X%
%\do\Z\do\_}%

But non of them the solution i want. it work's with this solutions but sometimes i get to much space between the words before and after the path-url of the next line in text will not correctly break. The text gos over my defined textwidth. So i want a solution where the path-url breaks the word correctly to my selected babel language; for my work in german.

Here two example of some of my path-urls:

  • HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates\AuthRoot
  • \%APPDATA\%\Microsoft\Crypto

Is there such a way? Or how can i get a superb, clean and good working url line break with using the path{} command? thanks!

1
  • your stated aim is rather incompatible with using url package, url does not use hyphenation and language setting at all, it is mainly designed to split on / and . etc, for URLs, it could be configured to split on \ as in your example, but it doesn't normally break words, if you add the entire alphabet as in your code block then it will break anywhere without using any word patterns. Spacing and over/under full lines depend on paragraph settings and code you have not shown, whether the paragraph is set \raggedright or \sloppy fro example. Commented Feb 8, 2016 at 13:51

1 Answer 1

1

Whether TeX can break the lines without over or underfull boxes is as much related to the paragraph settings as the url setting.##This shows several widths set raggedright with no overfull boxes.

enter image description here

\documentclass{article}
\usepackage{url}
\parindent0pt

\begin{document}

{\raggedright
X\dotfill X

\path|HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates\AuthRoot|

\path|\%APPDATA\%\Microsoft\Crypto|

X\dotfill X
}

\bigskip

\begin{minipage}{.5\textwidth}\raggedright

X\dotfill X

\path|HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates\AuthRoot|

\path|\%APPDATA\%\Microsoft\Crypto|

X\dotfill X
\end{minipage}

\bigskip

\begin{minipage}{.25\textwidth}\raggedright

X\dotfill X

\path|HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\SystemCertificates\AuthRoot|

\path|\%APPDATA\%\Microsoft\Crypto|

X\dotfill X
\end{minipage}


\end{document}
1
  • thanks, but this is not an option to me. I solved it by using \begin{sloppypar} ... \end{sloppypar} and rewrite the text on these places.
    – Opa114
    Commented Feb 9, 2016 at 14:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .