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 want to set color, font and similar style attributes for the text in a \url from the hyperref package. How do I go about doing it? All I have found are comments saying that I probably don't want to do that. I want to because I am using ttf fonts for my texts and I want my urls to be in that ttf and not the default (typewriter font?) that the hyperref package gives me. I started with just trying to get it in italics but didn't even succeed with that:

\documentclass{memoir}
\usepackage{hyperref}
\begin{document}
Lala \url{\itshape www.example.com}.
\end{document}

Figure showing it not working

I am guessing there is some hook or something but I just can't find it. Maybe I have gone blind?

share|improve this question
add comment

2 Answers

up vote 16 down vote accepted

Internally \url uses \UrlFont. You can change it with \urlstyle (see the documentation of url in url.sty) or by redefining \UrlFont:

\documentclass{memoir}
\usepackage{hyperref,xcolor}


\begin{document}
Lala \url{www.example.com}.

\urlstyle{sf}
Lala \url{www.example.com}.

\renewcommand\UrlFont{\color{red}\rmfamily\itshape}
Lala \url{www.example.com}.
\end{document}
share|improve this answer
1  
The package option urlcolor in the package hyperref does the same thing, i.e. \usepackage[urlcolor=red]{hyperref}. –  Ronny Oct 25 '12 at 13:02
add comment

Use \href instead:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{http://www.example.com}{\textit{www.example.com}}.
\end{document}

This takes two arguments: the first is the actual url, the second is the link text. The above code produces

Sample output

share|improve this answer
    
Also, it seems to not change the font into that typewriter one but keeps happily running with my ttf font. :) –  jonalv Oct 26 '12 at 7:52
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.