How to avoid the "http:" part in hyperref's \url?
It's better to use a different command, so that its usage is clear:
\documentclass{article}
\usepackage{xcolor}
\usepackage[
colorlinks,
linkcolor=magenta
]{hyperref}
\newcommand\rurl[1]{%
\href{http://#1}{\nolinkurl{#1}}%
}
\begin{document}
This is a link \rurl{ipython.org} written in abbreviated form.
\end{document}
Of course you lose the tricks \url
and \href
are able to do with complex URI, for handling special characters, but short URI like this one should not have this problem.
The color in the image shows that it's indeed a link to a Web page.
You can load the package url
and redefine the command \url
as follows:
\DeclareUrlCommand\url{\color{magenta}\def\UrlLeft{http://}\urlstyle{tt}}
Note that the xcolor
package is required, too, if you want to give a color to the link.
Now you can simply write
\url{ipython.org}
and http://
is added automatically.
Complete example
\documentclass{article}
\usepackage{hyperref}
\usepackage{xcolor,url}
\DeclareUrlCommand\url{\color{magenta}\def\UrlLeft{http://}\urlstyle{tt}}
\begin{document}
\url{ipython.org}
\end{document}
Output:
Of course, you can leave the \url
command as is and define a new command \shorturl
so to have
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{xcolor,url}
\DeclareUrlCommand\shorturl{\color{magenta}\def\UrlLeft{http://}\urlstyle{tt}}
\begin{document}
\url{local-link}
\shorturl{ipython.org}
\end{document}
Output: