1

I'm trying to set a custom colour for hyperref's link underlining. The MWE below shows what I'm doing. But the colour comes out different - it's the same kind of yellow but a different saturation, if I have to guess. I also haven't figured out how to match the line width to the line width I'm using for the section heading underlines.

\PassOptionsToPackage{svgnames,table,dvipsnames}{xcolor}
\documentclass[a4paper,10pt,oneside,DIV=9]{scrartcl}

% Packages
\usepackage{scrlayer-scrpage}
\usepackage{xcolor} % showframe loads this
\usepackage[normalem]{ulem}
\usepackage{hyperref}

% demo only
\usepackage{lipsum}
\usepackage{mwe}

% theme colours and lengths
\definecolor{MyThemeColour}{cmyk}{0.10,0.10,1.00,0} % personal yellow

% outdent and underline section headings
\newlength{\mysecnumhang}
\setlength{\mysecnumhang}{30pt}
\renewcommand*{\sectionformat}{%
  \makebox[\mysecnumhang][l]{\thesection\autodot\enskip}%
}
\renewcommand{\sectionlinesformat}[4]{%
    \hspace{-\mysecnumhang}\expandafter\headuline{#3#4}%
}
\newcommand\headuline{%
    \bgroup\markoverwith{\textcolor{MyThemeColour}{\rule[-0.75ex]{1pt}{1pt}}}\ULon% 2pt 2pt
}

% make the PDF link underlining use my default colour
\hypersetup{%
  linkbordercolor=MyThemeColour,%
}
\makeatletter
\Hy@AtBeginDocument{%
  \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
  \def\@pdfborderstyle{/S/U/W 2}% Overrides border style set with colorlinks=true
}
\makeatother

\begin{document}
\section{Lipsum}
\lipsum[1]\footnote{\lipsum[2][1-3]}\footnote{\lipsum[3][1-7]

\lipsum[4][1-7]}

\end{document}

(Compiling using lualatex in case that makes a difference.`

2

use

\PassOptionsToPackage{svgnames,table,dvipsnames,rgb}{xcolor}

then all colors are internally converted into the rgb modell. A yellow in cmyk is not the same as yellow in rgb.

  • Perfect, thank you (& I would never have worked this out on my own!). – Lyndon Drake Jun 4 at 18:31
  • Any thoughts on how to set the line width? – Lyndon Drake Jun 4 at 18:31
  • I do not really understand what you mean by line width. I get "1 Lipsum" underlined. – Red-Cloud Jun 4 at 18:37
  • No worries, I figured it out - thanks again – Lyndon Drake Jun 4 at 18:41

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.