0

I try to underline my links. So far, I tried to use the solution in this post but it doesn't seem to work. I also try with \underline inside the \href but the result isn't great. Here is the code I use:

\documentclass[a4paper]{paper}  

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}

\usepackage{hyperref}
\hypersetup{
   colorlinks=true,
   citecolor=black, 
   urlcolor=blue,
   allbordercolors={0 0 0},
   pdfborderstyle={/S/U/W 1}]{hyperref},
}


\begin{document}
\href{https://tex.stackexchange.com/questions/47713/underlined-links-with-hyperref-possible}{Underlined links with hyperref possible?} \lipsum[1]
\href{https://tex.stackexchange.com/questions/47713/underlined-links-with-hyperref-possible}{\underline{Underlined links with hyperref possible?}} \lipsum[1]

\end{document}

I would like to have something like that :

enter image description here

Is there an easy solution ?

1

The pdfborderstyle doesn't work for two reasons:

  • You moved the settings into \hypersetup but didn't remove the {hyperref}. If you look in the log you find a warning about it:
Package hyperref Warning: Invalid value `{/S/U/W 1}]{hyperref}'
(hyperref)                for option `pdfborderstyle'.
  • hyperref is the opinion that coloring a link and adding a border is too much. So as soon as you use the colorlinks option it will disable the border at begin document. If you really want both you have to reset the border later.

This here works if you have a pdf viewer which supports this border style:

\documentclass[a4paper]{paper}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[colorlinks=true]{hyperref}
\AtBeginDocument{%
 \hypersetup{
   urlcolor=blue,
   urlbordercolor=blue,
   pdfborder={1 1 1},
   pdfborderstyle={/S/U/W 1}   
}}


\begin{document}
\href{https://tex.stackexchange.com/questions/47713/underlined-links-with-hyperref-possible}{Underlined links with hyperref possible?} \lipsum[1]
\end{document}

enter image description here

| improve this answer | |

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.