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.

I met a problem about how to make the long link into a multi-lines one.

The following is LaTeX code:

\documentclass[11pt]{article}

\usepackage[colorlinks,citecolor=black,linkcolor=black]{hyperref}
\PassOptionsToPackage{hyphens}{url}

\begin{document}
\section{example}

test \footnote{photo from:Ferroelectrics-Physical-Effects,M.Lallart,2011,InTech, \\ \url{http://www.intechopen.com/books/ferroelectrics-physical-effects/photo-induced-effect-in-quantum-paraelectric-materials-studied-by-transient-birefringence-measuremen} }:

\end{document}

I referred to the suggestions of this Forcing linebreaks in \url But I still could not make \url work in sloppypar. That means when I delete \url{content} only put "content" in sloppypar it will work but I need \url to highlight or distinguish the url link.

How can I realize this?

I use XeLaTeX.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The problem have been solved. Thank you @Herbert You really give me a lot of help.

I should change the \PassOptionsToPackage{hyphens}{url} to \usepackage[hyphens]{url} and that will works : enter image description here

I guess I have used the wrong code to Pass Option.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

As Werner already mentioned use the hyphens option and for the footnote do not use the sloppypar environment:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[hyphens]{url}
\usepackage[colorlinks,citecolor=black,linkcolor=black]{hyperref}

\begin{document}

foo\footnote{%
Toshiro Kohmoto and Yuka Koyama (2011). Photo-induced Effect in Quantum    Paraelectric Materials Studied by Transient Birefringence Measurement, 
Ferroelectrics~--~Physical Effects, Dr. Mickal Lallart (Ed.), ISBN: 978-953-307-453-5, InTech, DOI: 10.5772/17132. Available from:
\url{http://www.intechopen.com/books/ferroelectrics-physical-effects/photo-induced-effect-in-quantum-paraelectric-materials-studied-by-transient-birefringence-measuremen}}

\end{document}

enter image description here

share|improve this answer
    
thank you for your answer. I follow your suggestion but it still does not work. the effect is like this :weibolink in my weibo(sorry I could not upload image in tex.stackexchage.com). I use '\RequirePackage[colorlinks,citecolor=black,linkcolor=black]{hyperref} ' and '\PassOptionsToPackage{hyphens}{url}' to include my url. –  sikisis May 23 '13 at 6:32
    
please provide a complete example code in your question. –  Herbert May 23 '13 at 6:36
    
give all the code? I am using someone's template to finish my bachelor thesis. Put all these up? –  sikisis May 23 '13 at 6:43
    
no, only the code with hyperref, url and one word and the footnote –  Herbert May 23 '13 at 6:45
1  
Thank you for your kind advice! @texenthusiast I will take care of it. –  sikisis May 23 '13 at 7:10
show 6 more comments

As stated in the url package documentation:

Package Option: hyphens
Ordinarily, breaks are not allowed after “-” characters because this leads to confusion. (Is the “-” part of the address or just a hyphen?) The package option “[hyphens]” allows breaks after explicit hyphen characters. The \url command will never ever hyphenate words.

This is exactly the problem with your URL. Using the hyphens package options allows it to break at -:

enter image description here

\documentclass{article}
\usepackage[hyphens]{url}% http://ctan.org/pkg/url
...
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.