# DOI links inside \texttt{} with \url{} line breaking

As in the title, is there any way to have \doi{}, apart from automatically inserting a link to an article, output into \texttt{} and break the line just like \url{} does? Unfortunately, I can't use anything that involves .bib files.

If you load hyperref you can use its \nolinkurl command to print a string as if it were a URL (fonts, linebreak and all) but without a link. You can then use \href to link the DOI to the proper target

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{hyperref}

\begin{document}
\doi{10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P}
\end{document}


Of course

\newcommand*{\doi}[1]{\nolinkurl{#1}}


would do the same without a link.

If you don't load hyperref and only use the url package, you can try

\newcommand*{\doi}[1]{\url{#1}}