Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to break camel case text that is handed to the \url{} macro of url.sty. The solution here does not work for text in captions, so it seems, ans in particular does not work for \url{}.

Is there a way to break the camel case as in:

\documentclass{article}

\usepackage{url}

\begin{document}
\noindent{}Here some text, and
then \url{BreakThisCamelCaseForMeItWasChosenToMakeSomeTasksEasierButAlas.txt},
and then some more text to indicate the text width, showing that
the URL should break earlier.
\end{document}
share|improve this question

1 Answer

up vote 5 down vote accepted

enter image description here

\documentclass{article}

\usepackage{url}

\makeatletter
\g@addto@macro\UrlSpecials{\camelurl}
\def\camelurl{%
\count@`a
\loop
\mathcode\count@"8000
\uccode`\~\count@\uppercase{\edef~{\mathchar\the\count@\noexpand\breakifupper}}%
\ifnum\count@<`\z
\advance\count@\@ne
\repeat}

\def\breakifupper#1{%
\ifcat .\noexpand#1%
\ifnum`#1>40
\ifnum`#1<91
\penalty\z@
\fi\fi\fi
#1%
}

\makeatother


\begin{document}
\noindent{}Here some text, and
then \url{BreakThisCamelCaseForMeItWasChosenToMakeSomeTasksEasierButAlas.txt},
and then some more text to indicate the text width, showing that
the URL should break earlier.
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.