0

I would like to include a clickable URL in a text written in LaTeX. For that I included the package hyperref. The result obtained by \url gives a clickable link written in \ttfamily (the default font). My question is how to set the font for \url so that I can obtain a clickable link written in the font "Euclid" rather than \ttfamily.

\usepackage{hyperref}
\url{http://stackoverflow.com/}
Werner
  • 603,163
keynes
  • 1,617

1 Answers1

2

In general: hyperref loads package url in background. So to change the font the right command is \urlstyle{…} (default is tt for teletype, i.e. \ttfamily), cf. manual of url.

Since you did not provide a minimal working example (MWE) I suppose you used the truetype font Euclid Regular (a free font), which has to be set with fontspec, and the TeX file must be compiled with LuaLaTeX or XeLaTeX.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{euclid.ttf} % if properly installed "\setmainfont{Euclid}" is preferred
\usepackage{kantlipsum} % just for some dummy text
\usepackage{hyperref} % loads "url" in background
\setlength{\parindent}{0pt} % for the example
\begin{document}
\kant[50]
\bigskip

\url{http://stackoverflow.com/} -- \url{http://tex.stackexchange.com/questions/162164/}

\urlstyle{rm}
\url{http://stackoverflow.com/} -- \url{http://tex.stackexchange.com/questions/162164/}

\bigskip

\kant[51]
\end{document}

Because for the test I did not install euclid.ttf in the fonts folder of my system I had to give the filename in \setmainfont instead of the preferred fontname (Euclid).

Speravir
  • 19,491
  • 1
    The Euclid font is just a clone of Computer Modern. – egreg Feb 24 '14 at 21:51
  • @egreg: I didn’t know, though the glyphs looked very familiar. So everything would work without loading an additional font here … – Speravir Feb 24 '14 at 22:07
  • @Speravir Thank you for your answer. I think that I have to use the package url, then \urlstyle{same} and just write \url{http://mp0806.cineca.it/icfd.php} and all is going well! a – keynes Feb 24 '14 at 23:15
  • @Strömungsmechanik: For a clickable link you will need hyperref, and this package loads itself url. But read, waht egreg wrote: You do not need at all “Euclid”. Just leave out the loading of fontspec and the \setmainfont line, because then the default is taken, and this is “Computer Modern Roman”. – Speravir Feb 24 '14 at 23:46
  • @Strömungsmechanik: You were tricked by automatism. Yes writing \url{http://mp0806.cineca.it/icfd.php} should work and worked here in my test. – Speravir Feb 24 '14 at 23:56