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 URLs in the rendered PDF to appear as follows:

<http://website/blah>

I have declared the URLS in my document using the 'url' package, in the form:

\url{https://tex.stackexchange.com/}

Then, I have the following command:

\DeclareUrlCommand\url{\def\UrlLeft{<}\def\UrlRight{>}%
\urlstyle{tt}}

The problem, is that while this adds the chevrons, the URL is no longer clickable in the final PDF. What is the right way to add the triangular brackets and have the URL clickable?

share|improve this question
    
Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Christian Hupfer Aug 2 at 15:16

1 Answer 1

up vote 5 down vote accepted

The \url command can be redefined the same way as hyperref. The following example first defines url command \guilurl, which uses single guillemots as angle brackets. Then \url is redefined using \guilurl:

\documentclass{article}

\usepackage[T1]{fontenc}% \guilsinglleft and \guilsinglright
\usepackage{lmodern}
\usepackage{amstext}

\usepackage{hyperref}

\DeclareUrlCommand{\guilurl}{%
  \def\UrlLeft{\text{\guilsinglleft}}%
  \def\UrlRight{\text{\guilsinglright}}%
  \urlstyle{tt}%
}
\makeatletter
\DeclareRobustCommand*{\url}{%
  \hyper@normalise\guilurl@
}
\newcommand*{\guilurl@}[1]{%
  \hyper@linkurl{\guilurl{#1}}{#1}%
}
\makeatother

\begin{document}
\url{http://website/blah}
\end{document}

Result

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.