5

I read some answers on that questions, but it is still not working as expected. The code says: link yellow, border green : the result is not the one I expect. If I change the colors, the result remains the same.

enter image description here

\documentclass{article}
\usepackage{xcolor,hyperref}

\hypersetup{%
    colorlinks=true,
    linkcolor=yellow,
    linkbordercolor=green,
    pdfborderstyle={/S/U/W 1pt}}

\begin{document}

\href{%
    https://studio.code.org/s/course3/stage/2/puzzle/1}{%
    Labyrinthe}

\end{document}
4
  • 2
    Whenever you say that code doesn't work as expected, it's usually a good idea to say exactly what you expect (even if it might be more or less obvious from the code). Feb 7, 2018 at 10:11
  • The code says : link yellow, border green : the result is not the one expected, isn't it ;-)
    – Tarass
    Feb 7, 2018 at 10:13
  • 1
    It was a more general statement, it might not always be obvious from the code what the expected outcome would be (and I think there are cases where users have misconceptions about what code does, and thus have wrong expectations). That said, urlcolor, not linkcolor, but I can't give any good answer for the border. Feb 7, 2018 at 10:21
  • I thaught url is for http://... and link for the friendly name. thank you.
    – Tarass
    Feb 7, 2018 at 10:31

1 Answer 1

7

You need to reset the border style AtBeginDocument:

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}

\hypersetup{%
    colorlinks=true,
    urlcolor=yellow,
    urlbordercolor=green,
    pdfborder={1 1 1},
    }

\AtBeginDocument{\hypersetup{pdfborderstyle={/S/S/W 1}}}
\begin{document}

\href{%
    https://studio.code.org/s/course3/stage/2/puzzle/1}{%
    Labyrinthe}

\end{document}

enter image description here

Use pdfborderstyle={/S/U/W 1} if you want to underline.

2
  • 1
    Yellow and green? I can't make this work to see yellow and green. My border color never changes from the cyan border, nor the pink text with this code. Can you please collaborate? Thank you. May 23, 2019 at 0:12
  • @KitOstrihon I must have missed your comment, and you are quite right, I mixed up linkcolor and urlcolor ... Jun 30, 2021 at 21:54

You must log in to answer this question.

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