6

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?

  • 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}. – user31729 Aug 2 '14 at 15:16
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.