1

I was trying to get the formatting of my href links to look like an HTML link, i.e. blue text with a blue underline. Manually I was able to do it like this:

\documentclass{article}
%\usepackage{xkeyval}
\usepackage[hyperindex,hidelinks]{hyperref}
\usepackage{xcolor}
\begin{document}
\title{Test href}
\section{Test of href formatting}
This has an href \href{https://www.google.com}{\textcolor{blue}{\underline{JIRA-2670}}}.
\end{document}

But I was just curious if there was a more automatic way of doing this without having to manually format each link?

Thanks for any help or tips.

Russ

2
  • \hyperref doesn't produce an url link, you need \href. Commented Sep 4 at 19:06
  • My bad, I had \href in my source, but mistyped the command. Are easier ways to get the formatting like I want? I will edit the source above! Thx. Commented Sep 4 at 19:16

1 Answer 1

0

For pity's sake, don't use underlines if you're also going to colorize the link text. In my opinion, the hyperref design of making the two things incompatible is good (though not so much the design of framing the links by default). But if you insist to overload the text, you can do this:

Note: The underlines thicker and with colours differing from the text only to make the code easier to understand. It's not a good idea either in a real text.

mwe

\documentclass[a6paper]{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage[
colorlinks=true, 
breaklinks=true, 
urlcolor= magenta, 
linkcolor=cyan, 
linkbordercolor=orange,
urlbordercolor=green,
% pdfborderstyle={/S/U/W 3}, % opps, only work with colorlink=false
% pdfborder={0 0 1}          % opps, only work with colorlink=false
]{hyperref}

% make underline compatible with colorlinks  
% https://tex.stackexchange.com/a/26085

\AtBeginDocument{
  \hypersetup{
    pdfborder={0 0 1},
    pdfborderstyle={/S/U/W 1.5}}}

\begin{document}
\section{foo} \label{bar}
Awesome heavily underlined links to the section 
\ref{bar} named \hyperref[bar]{foo} and to a very
nice  external   \href{http://example.com}{URL of example}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .