0

I'm using ModernCV to create my CV and I've spent a long time playing around with link styles. I find coloured links to stand out too much or clash with other colours on the page, and the standard underline to be too strong, especially under headings or bold text.

The solution I've landed on is to underline all links with a lightgray underline. This is just subtle enough and works well throughout the document.

I understand the default solution is supposed to be to configure the outline settings in the hypersetup, but I have never got this to work. If I set pdfborder to anything other than 0 0 0 I'll always get horrible boxes around links that I can't configure.

The main package I've found that allows you to control the colour of underlines is soul, with the \setulcolor command to customise soul's custom \ul command. The main problem I had with that was that whenever I tried to use that in conjunction with a hyperlink I got an error about too many }s that I couldn't explain.

How can I successfully set the link underline to lightgray?

1 Answers1

0

The solution I found is customised from this lifesaver of an answer, using hyperref and soul together to replace the old href function.

The solution provided there actually gave me the error "Package soul Error: Reconstruction failed", but this answer told me I just needed to add an \mbox.

So, here's how to make all links underlined with a lightgray underline:

\usepackage{hyperref,xcolor, soul}
\setulcolor{lightgray}
\let\oldhref\href
\renewcommand{\href}[2]{\oldhref{#1}{\hrefstyle{#2}}}
\newcommand{\hrefstyle}[1]{\ul{\mbox{#1}}}

Which results in nice subtle links looking like this:

lightgray underlined links

  • 1
    that won't work with links containing special chars like # or %. And you are naturally suppressing line breaks by putting everything in a mbox. – Ulrike Fischer Aug 16 '23 at 11:32
  • Thanks those are helpful warnings. Definitely worth being aware of. I'm not sure why I would want a linebreak in link text, but certainly the special character one could trip me up at some point. – Robin Winslow Aug 16 '23 at 13:04
  • Well long link text like "platform engineering" could lead to overful lines if they can't break. Beside this if you don't want linebreak than why using soul? the main point of the package is to enable line breaking. – Ulrike Fischer Aug 16 '23 at 13:14
  • You could use [hikelinks], but that would affect everything, not just \hypertarget. – John Kormylo Aug 16 '23 at 14:31
  • @UlrikeFischer my solution works so far, but I'm very willing to believe it's not the best solution, it's just the best that I found. Please go ahead and suggest a better one and I'll see if I can make it work. – Robin Winslow Aug 24 '23 at 12:06
  • I have an answer in the question you linked too for an underline that is also printed. For a PDF-underline use \hypersetup{pdfborderstyle={/S/U/W 1}, urlbordercolor=lightgray} (but that doesn't work in all pdf viewers). – Ulrike Fischer Aug 24 '23 at 12:37
  • Yeah it's the "that doesn't work in all pdf viewers" that's the problem. It doesn't work in any of the PDF viewers I tried, and I am not interested in a PDF that won't reliably look the way I want it to look - that's kind of the point of a PDF, in my view. It's far better to use a hacky solution that might not scale to all possible documents, but does work for my specific document and will work in all viewers, than a generic solution that will work on all documents but not in all viewers. The goal is to produce the best possible document. – Robin Winslow Aug 24 '23 at 13:38