# Crash \@undeclaredcolor when citing a website with @misc and natbib

I am having troble when citing a website through the entry @misc with natbib, style unsrtnat. For old versions of TexLive (2012) all works fine, but for more recent ones the entry url makes the compilation crash with the following message. Minimal example reproducing the error

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames,svgnames]{xcolor}

\usepackage[utf8]{inputenc}
\usepackage[numbers]{natbib}
\usepackage{doi}

\title{Minimal example}
\author{molm }
\date{March 2018}

\begin{document}

\maketitle
\def\sb#1{{\color{red}***[#1]***}}

\section{Introduction}
Reference to website \cite{knuthwebsite}
\bibliographystyle{unsrtnat}
\bibliography{main}

\end{document}


Bib file

@misc{knuthwebsite,
author    = "Donald Knuth",
title     = "Knuth: Computers and Typesetting",
url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

• Updated the question with a snippet that reproduces the error. Package xcolor, doi and the declaration of the definition produces the conflict. Can you see why? – Marc Olm Mar 22 '18 at 10:00
• For instance, to mark in a different color introduced changes from a previous version – Marc Olm Mar 22 '18 at 10:10
• Redefining \sb is a sure recipe to go into troubles. – egreg Mar 22 '18 at 10:10

The command \sb is supposed to be a substitute for _ when it's not available and indeed \url uses it when processing its argument. Your redefinition makes \url fail.
Use a different name and never do \def unless you know precisely what you're doing and why.