2

Is it possible to make the below url look more like a word/excel link?

Here is a small latex example:

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{hyperref} \hypersetup{ colorlinks=true, urlcolor=blue } \urlstyle{same}

\begin{document} Url: \url{https://stackexchange.com/} \end{document}

The result is:

enter image description here

I would like something, which looks like:

enter image description here

Any idea how to do that?

Update

I came by this solution, which is very close to what I want however it changes the font for the URL, which is not desired:

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\usepackage{hyperref}
\hypersetup{colorlinks,urlcolor=blue}
\makeatletter
\DeclareUrlCommand\ULurl@@{
  \def\UrlFont{\ttfamily\color{blue}}
  \def\UrlLeft{\uline\bgroup}
  \def\UrlRight{\egroup}}
\def\ULurl@#1{\hyper@linkurl{\ULurl@@{#1}}{#1}}
\DeclareRobustCommand*\ULurl{\hyper@normalise\ULurl@}
\makeatother

\begin{document} Url: \ULurl{https://stackexchange.com/} \end{document}

1 Answers1

2

From your code:

  • add a % symbol to remove the blank space before the url
  • remove the \ttfamily font specifier to keep the same font or even use \normalfont to always format the url the same way

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\usepackage{hyperref}
\hypersetup{colorlinks,urlcolor=blue}
\makeatletter
\DeclareUrlCommand\ULurl@@{% <-- add this to remove space before url
%   \def\UrlFont{\ttfamily\color{blue}} <-- remove \ttfamily to keep the font
    \def\UrlFont{\color{blue}}%
    \def\UrlLeft{\uline\bgroup}%
    \def\UrlRight{\egroup}}
\def\ULurl@#1{\hyper@linkurl{\ULurl@@{#1}}{#1}}
\DeclareRobustCommand*\ULurl{\ULurl@}
\makeatother

\begin{document} Url: \ULurl{https://stackexchange.com/} \end{document}

NBur
  • 4,326
  • 10
  • 27