Take the 2-minute tour ×
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.

Is it a good practice if we always locally precede \href with \sloppy as follows?

if you are interested to know the details, 
please contact me at {\sloppy
\href{mailto:asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}
{asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}}.
share|improve this question
    
Best email address ever... –  Pureferret Sep 2 '12 at 12:04
    
How did you get the idea to do that? –  Martin Schröder Sep 3 '12 at 6:34
    
@MartinSchröder: Because I previously assumed that \sloppy can work in a word scope. I did not know it must be in a paragraph scope. –  Fifa Earth Cup 2014 Sep 3 '12 at 7:38
add comment

1 Answer

up vote 20 down vote accepted

No. Placed there the command \sloppy has no effect:

\documentclass{article}
\usepackage{hyperref}
\usepackage[width=7cm]{geometry}
\begin{document}

If you are interested to know the details, 
please contact me at {\sloppy
\href{mailto:asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}
{asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}}.

If you are interested to know the details, 
please contact me at
\href{mailto:asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}
{asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}.

\end{document}

No sloppy effect

The command \sloppy only works with complete paragraphs, so one would need to write

{\sloppy
If you are interested to know the details, 
please contact me at {
\href{mailto:asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}
{asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}}.
\par
}

or use sloppypar. However, this is often not satisfactory. Some discussion may be found in l2tabu. In your case, I suggest you use

\url{asdfkoafdkfaldfkafsdfkdf@kdsoffkdlfasdfjaldf.xxx}

url example

Hyperref should be able to deduce the link type and it provides more break points LaTeX can use. For a more realistic example, where there are more .'s in the email address, this gives rather good results:

If you are interested to know the details, 
please contact me at 
\url{asdf.koafdkfa.ldfkaf.sdfkdf@kdso.ffkdlfas.dfjaldf.xxx}.

Better url example

share|improve this answer
add comment

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.