2

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.

3

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}

\newcommand*{\doi}[1]{\href{https://doi.org/#1}{\nolinkurl{#1}}}

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

The image shows the DOI "10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P" typeset in the document surrounded by a box indicating it is a clickable link.

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}}

instead.

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.