1

I'm trying to make a document (using lualatex) with internal and external links, using the xcolor and hyperref packages. I want my link setup like this:

  • no boxes around links (underlined in a defined color would be ok)
  • internal links: normal font
  • external links: blue color, italic font

From others here on stackexchange, I thought it should work like this:

\documentclass[11pt, oneside, a4paper]{article}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref} % hyperfootnotes=false
    \hypersetup{colorlinks, citecolor=, linkcolor=, urlcolor=blue}
    \renewcommand\UrlFont{\color{blue}\rmfamily\itshape} % I thought this should make it italic, but it does not
    \newcommand{\changeurlcolor}[1]{\hypersetup{urlcolor=#1}}

\begin{document}
    Here is some basic url: \href{https://tex.stackexchange.com/questions}{https://tex.stackexchange.com/questions}.
    But why is my link not \textit{italic}?
\end{document}

I guess there is something very basic I'm missing?

3

\UrlFont is for urls, but you have here a "simple" href text, for this only the urlcolor applies. Use either \url or in the \href \nolinkurl:

\documentclass[11pt, oneside, a4paper]{article}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref} % 
    \hypersetup{colorlinks, citecolor=, linkcolor=, urlcolor=blue}
    \renewcommand\UrlFont{\color{blue}\rmfamily\itshape} % I thought this should make it italic, but it does not
    \newcommand{\changeurlcolor}[1]{\hypersetup{urlcolor=#1}}

\begin{document}
    Here is some basic url: 
    \url{https://tex.stackexchange.com/questions}.

    \href{https://tex.stackexchange.com/questions}{\nolinkurl{https://tex.stackexchange.com/questions}}.
    But why is my link not \textit{italic}?
\end{document}

enter image description here

2
  • Works, I see the point, thanks. How could I potentially \renewcommand the \href definition to always act like this? Tried \renewcommand{\href}{\href{#1}{\nolinkurl{#2}}}, but this is obiously wrong. – s6hebern Feb 13 '20 at 7:26
  • 1
    Hmm... maybe \let\hreforig=\href \renewcommand{\href}{\hreforig{#1}{\nolinkurl{#2}}}? But I didn't test it... it works only if \href is a very simple definition. I wouldn't do that, better stick with your own macro name... – Rmano Feb 14 '20 at 12:33

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.